Skip to content

feat: default to altimate-backend model when configured#665

Merged
anandgupta42 merged 3 commits intomainfrom
feat/altimate-default-model
Apr 8, 2026
Merged

feat: default to altimate-backend model when configured#665
anandgupta42 merged 3 commits intomainfrom
feat/altimate-default-model

Conversation

@mdesmet
Copy link
Copy Markdown
Contributor

@mdesmet mdesmet commented Apr 8, 2026

Summary

  • When no model is explicitly configured and no recently-used model exists, default to altimate-backend/altimate-default if altimate credentials are present
  • Applies to both Provider.defaultModel() (main session) and ACP agent defaultModel() fallback chains
  • Adds 4 tests covering: altimate as default, altimate preferred over other providers, explicit config takes precedence, fallthrough when altimate not configured

Test plan

  • Manual test: removed ~/.local/state/altimate-code/model.json, launched app with altimate credentials — altimate-default selected
  • bun 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-existing defaultModel() timeout in test env, same as the existing defaultModel returns first available test)

🤖 Generated with Claude Code


Summary by cubic

Default to altimate-backend/altimate-default when Altimate credentials are present and no model is configured or recently used. Works in Provider.defaultModel() and the ACP agent; respects cfg.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

    • Default model selection now prioritizes the Altimate backend when available with valid credentials.
    • Explicit model configuration in settings continues to override the default selection behavior.
  • Tests

    • Added automated tests to verify selection behavior across Altimate, Anthropic, and explicit configuration scenarios.

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>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e8ddd11f-1c09-4d35-b0d8-712981c18728

📥 Commits

Reviewing files that changed from the base of the PR and between a713809 and 5fe8ba5.

📒 Files selected for processing (2)
  • packages/opencode/src/provider/provider.ts
  • packages/opencode/test/provider/provider.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/opencode/src/provider/provider.ts
  • packages/opencode/test/provider/provider.test.ts

📝 Walkthrough

Walkthrough

The PR adds an early preference in default model selection to return { providerID: "altimate-backend", modelID: "altimate-default" } when that provider and model exist and no explicit model is configured. Tests were added to verify behavior across credential and config combinations.

Changes

Cohort / File(s) Summary
Altimate selection in agent
packages/opencode/src/acp/agent.ts
Inserted an early check to prefer the altimate-backend / altimate-default pair when no explicit model is configured.
Provider defaultModel logic
packages/opencode/src/provider/provider.ts
Added early-return branch in Provider.defaultModel() to select altimate-backend/altimate-default if present and allowed by config before previous fallbacks.
Tests for Altimate preference
packages/opencode/test/provider/provider.test.ts
Added four tests exercising Provider.defaultModel() with/without Altimate credentials and with explicit opencode.json model settings; added fs/promises usage for setup.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • anandgupta42
  • suryaiyer95

Poem

🐰 I hopped through configs, checked creds on the way,

Found Altimate waiting to brighten the day.
No model chosen? I lead the parade,
Till a user's preference sends Altimate to shade.
🥕✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required 'PINEAPPLE' word at the top as mandated by the template for AI-generated contributions, and lacks explicit documentation of changes per the template structure. Add 'PINEAPPLE' at the very top before any other content as required for AI-generated contributions, and ensure the description follows the template structure with Summary, Test Plan, and Checklist sections clearly delineated.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: defaulting to the altimate-backend model when configured, which matches the core functionality added across the modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/altimate-default-model

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b66d9f5 and a713809.

📒 Files selected for processing (3)
  • packages/opencode/src/acp/agent.ts
  • packages/opencode/src/provider/provider.ts
  • packages/opencode/test/provider/provider.test.ts

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

mdesmet and others added 2 commits April 8, 2026 23:18
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>
@anandgupta42 anandgupta42 merged commit dafd16a into main Apr 8, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants