Skip to content

Conversation

@youming-ai
Copy link

@youming-ai youming-ai commented Jan 29, 2026

What

Adds a fallback_models config option (string | string[]) so agents/categories can select the first available model at initialization time when the preferred model is unavailable.

Why

Provider connectivity and model availability vary across environments. This reduces brittle startup behavior when a single configured model cannot be used.

Changes

  • Add fallback_models to agent overrides and category config schema.
  • Update model resolution to try fallback_models (via availableModels or connected-providers cache) before built-in fallback chain and system default.
  • Fix Prometheus config merge so resolvedModel is not overwritten by override.model.
  • Apply category defaults (temperature/top_p/maxTokens/thinking/reasoningEffort/textVerbosity) when using override.category.
  • Add/adjust tests for resolver + inheritance; avoid relying on a real connected-providers cache.
  • Update docs (config + RFC).

Notes

Verification

  • bun run typecheck
  • bun test src/shared/model-resolver.test.ts src/agents/utils.test.ts

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b57fa36811

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 570 to 591
const parsedModel = parseModelString(actualModel)
const variantToUse = userCategories?.[args.category]?.variant ?? resolvedVariant
categoryModel = parsedModel
? (variantToUse ? { ...parsedModel, variant: variantToUse } : parsedModel)
: undefined
}
const variantToUse = resolved.config.variant ?? resolvedVariant
categoryModel = parsedModel

Choose a reason for hiding this comment

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

P2 Badge Preserve fallback-chain variant over category defaults

When a category has a default variant (e.g., ultrabrainxhigh) and the fallback chain selects a different model with its own variant (e.g., Claude → max), this line now forces the default variant because resolved.config.variant is always populated from the category defaults. That overrides resolvedVariant and can send an invalid variant to the fallback provider, causing the delegated task to fail whenever the primary model is unavailable. The previous behavior only prioritized an explicit user override; consider reverting to user-only precedence or using resolvedVariant when the model came from the fallback chain.

Useful? React with 👍 / 👎.

Copy link

@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.

No issues found across 15 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

This was referenced Jan 29, 2026
@youming-ai youming-ai force-pushed the feat/fallback_models-restored branch from 8d2aff9 to 31107ce Compare January 30, 2026 08:14
youming-ai added a commit to youming-ai/oh-my-opencode that referenced this pull request Jan 31, 2026
…el availability fallback

Resolved conflicts in src/agents/utils.test.ts (import statements)
@youming-ai youming-ai force-pushed the feat/fallback_models-restored branch from 2653c86 to de8f283 Compare January 31, 2026 09:27
youming-ai and others added 3 commits January 31, 2026 19:30
Allow agents and categories to specify fallback models when the preferred model is unavailable, and surface the option in schema/docs/tests.
…and update test expectations

Fix two issues with fallback_models feature:

- Update test expectations in model-resolver.test.ts to match actual log message format

- Fix applyCategoryOverride to not overwrite model when it was already resolved via fallback_models

- Ensures category config properly respects the resolved model from fallback chain

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <[email protected]>
@youming-ai youming-ai force-pushed the feat/fallback_models-restored branch from de8f283 to 056734f Compare January 31, 2026 10:31
youming-ai and others added 4 commits January 31, 2026 19:58
Fix comment numbering inconsistency in model resolution pipeline:

- Step 1: UI Selection

- Step 2: Config Override

- Step 3: User-configured fallback_models (was 1.5)

- Step 4: Category Default Model (was 2.5)

- Step 5: Provider fallback chain (was 3, with substeps 5.1/5.2)

- Step 6: System default (was 4)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <[email protected]>
Add tests for edge cases in fallback_models feature:

- Empty fallback_models array preserves override semantics

- Duplicate entries in fallback_models are correctly deduplicated

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <[email protected]>
…rors

Add runtime_fallback feature that automatically switches to fallback models when API errors occur:

- Intercepts session.error events with retryable status codes (429, 503, 529)

- Supports fallback_models from agent/category configuration

- Respects cooldown periods and max fallback attempts

- Shows toast notifications when fallback occurs

- Comprehensive test coverage (18 tests)

Configuration options:

- enabled: boolean (default true)

- retry_on_errors: number[] (default [429, 503, 529])

- max_fallback_attempts: number (default 3)

- cooldown_seconds: number (default 60)

- notify_on_fallback: boolean (default true)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <[email protected]>
Update documentation to reflect the completed runtime_fallback feature:

- configurations.md: Remove 'planned' note, add detailed usage instructions

- RFC-runtime-model-fallback.md: Mark as IMPLEMENTED with 18 passing tests

- Add implementation notes and architecture details

- Document resolved questions and key design decisions

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant