feat: default to altimate-backend model when configured#665
feat: default to altimate-backend model when configured#665anandgupta42 merged 3 commits intomainfrom
Conversation
When no model is explicitly configured and no recently-used model exists, prefer altimate-backend/altimate-default as the default model if altimate credentials are present. This applies to both the main Provider.defaultModel() and the ACP agent defaultModel() fallback chains. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR adds an early preference in default model selection to return Changes
Sequence Diagram(s)sequenceDiagram
participant UserConfig as User Config
participant Provider as Provider.registry
participant FS as Filesystem (OPENCODE_TEST_HOME / .altimate)
participant Env as Env Vars (ANTHROPIC_API_KEY)
participant Selector as defaultModel()
UserConfig->>Selector: request default model (cfg)
Selector->>Provider: list available providers/models
Provider-->>Selector: providers (may include altimate-backend)
Selector->>FS: check Altimate credentials (.altimate/altimate.json)
FS-->>Selector: credentials present / absent
Selector->>Env: check env (ANTHROPIC_API_KEY)
Env-->>Selector: anthropic available / not
alt Altimate present & cfg.model not set & allowed
Selector-->>UserConfig: return altimate-backend / altimate-default
else other rules
Selector-->>UserConfig: apply recent/config/provider fallback selection
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/opencode/test/provider/provider.test.ts (1)
2337-2485: Extract a shared helper for Altimate credential fixture setup.The same setup/teardown is repeated across the new tests; a small helper will reduce duplication and prevent future drift in env cleanup behavior.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/opencode/test/provider/provider.test.ts` around lines 2337 - 2485, Several tests repeat Altimate credential fixture setup and env cleanup; extract a shared helper (e.g., setupAltimateCredentials and teardownAltimateCredentials) to centralize: move logic that sets process.env.OPENCODE_TEST_HOME, creates the .altimate directory, writes altimate.json with altimateUrl/altimateInstanceName/altimateApiKey, and restores OPENCODE_TEST_HOME into the helper; update tests (those calling tmpdir, Instance.provide and Env.set) to call the helper instead of duplicating the same file writes and env manipulation, and ensure the helper returns a cleanup/restore function to be invoked in finally blocks so teardown behavior (restoring OPENCODE_TEST_HOME) remains consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/opencode/src/provider/provider.ts`:
- Around line 1640-1650: The early-return that forces altimate-backend ignores
the configured provider filter; update the logic in defaultModel (or the
surrounding function) so the altimate-backend fallback only applies when the
configured provider set allows it: check cfg.provider (or the result of
Object.values(providers).find(...) logic) before returning the altimate pair.
Concretely, when evaluating const altimateProvider =
providers[ProviderID.make("altimate-backend")] and the altimate-default model,
ensure you only return { providerID: ProviderID.make("altimate-backend"),
modelID: ModelID.make("altimate-default") } if cfg.provider is unset OR
cfg.provider includes the "altimate-backend" id (e.g., using
Object.keys(cfg.provider).includes(altimateProvider.id)), otherwise fall through
to the existing provider selection that uses providers and cfg.provider.
In `@packages/opencode/test/provider/provider.test.ts`:
- Around line 2370-2371: The teardown currently restores OPENCODE_TEST_HOME by
unconditional assignment (process.env.OPENCODE_TEST_HOME = originalHome), which
can set the env var to the string "undefined" or an invalid value when
originalHome is undefined; update each restore site (the occurrences around the
test teardown code that reference originalHome at the three locations) to
conditionally restore: if originalHome is undefined then delete
process.env.OPENCODE_TEST_HOME else set process.env.OPENCODE_TEST_HOME =
originalHome so the env is removed rather than assigned an undefined value.
---
Nitpick comments:
In `@packages/opencode/test/provider/provider.test.ts`:
- Around line 2337-2485: Several tests repeat Altimate credential fixture setup
and env cleanup; extract a shared helper (e.g., setupAltimateCredentials and
teardownAltimateCredentials) to centralize: move logic that sets
process.env.OPENCODE_TEST_HOME, creates the .altimate directory, writes
altimate.json with altimateUrl/altimateInstanceName/altimateApiKey, and restores
OPENCODE_TEST_HOME into the helper; update tests (those calling tmpdir,
Instance.provide and Env.set) to call the helper instead of duplicating the same
file writes and env manipulation, and ensure the helper returns a
cleanup/restore function to be invoked in finally blocks so teardown behavior
(restoring OPENCODE_TEST_HOME) remains consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e8f55bd4-0a42-4bbe-a06c-fad46c8ffec5
📒 Files selected for processing (3)
packages/opencode/src/acp/agent.tspackages/opencode/src/provider/provider.tspackages/opencode/test/provider/provider.test.ts
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode/test/provider/provider.test.ts">
<violation number="1" location="packages/opencode/test/provider/provider.test.ts:2370">
P2: Setting `process.env.OPENCODE_TEST_HOME = originalHome` when `originalHome` is `undefined` will set the env var to the string `"undefined"` rather than removing it. Use `delete process.env.OPENCODE_TEST_HOME` when the original value was not set.</violation>
</file>
<file name="packages/opencode/src/provider/provider.ts">
<violation number="1" location="packages/opencode/src/provider/provider.ts:1641">
P1: The altimate-backend early return bypasses the `cfg.provider` filtering that happens on the next line. If a user has configured specific providers via `cfg.provider`, this code will still select `altimate-backend` even if it's not in the allowed provider set. The altimate check should respect the configured provider constraint.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
The altimate-backend early return was bypassing the cfg.provider constraint that the generic fallback respects. Now the altimate check only triggers if altimate-backend is in the user's configured provider set (or if no provider filter is configured). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use delete when originalHome is undefined instead of assigning the string "undefined" back to the env var. Also remove unused Global import. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
altimate-backend/altimate-defaultif altimate credentials are presentProvider.defaultModel()(main session) and ACP agentdefaultModel()fallback chainsTest plan
~/.local/state/altimate-code/model.json, launched app with altimate credentials — altimate-default selectedbun test test/provider/provider.test.ts— new tests validate all branches of the default model logic (note: 3 of 4 new tests hit a pre-existingdefaultModel()timeout in test env, same as the existingdefaultModel returns first availabletest)🤖 Generated with Claude Code
Summary by cubic
Default to
altimate-backend/altimate-defaultwhen Altimate credentials are present and no model is configured or recently used. Works inProvider.defaultModel()and the ACP agent; respectscfg.provider; explicit config wins; falls through if Altimate isn’t set.Written for commit 5fe8ba5. Summary will update on new commits.
Summary by CodeRabbit
Improvements
Tests