Skip to content

Conversation

@wydrox
Copy link

@wydrox wydrox commented Feb 3, 2026

Replaces #1307.

Summary

This PR adds support for customizable fallback chains and improves model ID matching to handle prefixed models (like antigravity-*).

Changes in this PR (Fixes for #1307)

  1. Resolved merge conflicts with dev branch.
  2. CLA Signed.
  3. Refactored Schema: Extracted shared FallbackChainSchema in src/config/schema.ts to deduplicate definitions.
  4. Fixed Logic Bug: findVariantInChain now strictly requires model match when entry.model is defined (prevents incorrect provider-only fallback).
  5. Added Tests: Comprehensive edge case tests in src/shared/agent-variant.test.ts covering model mismatches, chain ordering, and multi-provider entries.

Original Description

  • Fallback chains are hardcoded in model-requirements.ts
  • Variant resolution only works with exact provider/model matches
  • No support for custom model names like antigravity-gemini-3-pro

Solution

  1. Customizable fallback chains - Users can now define their own fallback chains in oh-my-opencode.json.
  2. Model ID normalization - Strips common routing prefixes when matching models.
  3. Improved variant fallback - Falls back to category/agent variant when model-based resolution fails.

Testing

All tests pass, including new edge case tests for the logic fix.


Summary by cubic

Adds customizable fallback chains for agents and categories and improves model matching (handles prefixed IDs like antigravity-*). Fixes #1307 by allowing user-defined chains to override built-ins and ensuring precise variant selection.

  • New Features

    • Add fallback_chain config to agents and categories for custom model/provider fallbacks.
    • Normalize model IDs by stripping common prefixes for matching.
    • Clear priority: agent fallback_chain → agent variant → category fallback_chain → category variant → built-in chains.
  • Bug Fixes

    • Require a model match when entry.model is set.
    • Correct handling of multi-provider entries with strict model checks.
    • Add tests for prefixed models, chain ordering, and mismatch edge cases.

Written for commit c1125a3. Summary will update on new commits.

- Add fallback_chain config option to agents and categories schema
- Implement model ID normalization to match prefixed models (e.g., antigravity-*)
- Add getEffectiveFallbackChain and getEffectiveCategoryFallbackChain functions
- Update resolveVariantForModel to use user-defined fallback chains
- Fall back to user config variant when model-based resolution fails
- Add comprehensive tests for new functionality

This allows users to define custom fallback chains in oh-my-opencode.json:
```json
{
  "agents": {
    "sisyphus": {
      "fallback_chain": [
        { "providers": ["google"], "model": "gemini-3-pro", "variant": "max" }
      ]
    }
  }
}
```
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

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.

1 issue found across 5 files

Confidence score: 3/5

  • Potential user-facing regression: src/config/schema.ts now requires model in fallback chain, which may reject previously valid provider-only configs at runtime/tests
  • Score reflects a medium-severity validation change that could block configuration usage, with uncertain confidence
  • Pay close attention to src/config/schema.ts - schema constraint may not match runtime expectations.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/config/schema.ts">

<violation number="1" location="src/config/schema.ts:106">
P2: Fallback chain schema requires `model`, but runtime logic/tests allow provider-only entries, so valid configs without a model will now be rejected.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


export const FallbackChainEntrySchema = z.object({
providers: z.array(z.string()),
model: z.string(),
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

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

P2: Fallback chain schema requires model, but runtime logic/tests allow provider-only entries, so valid configs without a model will now be rejected.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/config/schema.ts, line 106:

<comment>Fallback chain schema requires `model`, but runtime logic/tests allow provider-only entries, so valid configs without a model will now be rejected.</comment>

<file context>
@@ -101,6 +101,13 @@ export const BuiltinCommandNameSchema = z.enum([
 
+export const FallbackChainEntrySchema = z.object({
+  providers: z.array(z.string()),
+  model: z.string(),
+  variant: z.string().optional(),
+})
</file context>
Suggested change
model: z.string(),
model: z.string().optional(),
Fix with Cubic

@wydrox
Copy link
Author

wydrox commented Feb 3, 2026

recheck

@wydrox wydrox force-pushed the feature/customizable-fallback-chains branch from d9c33b4 to c1125a3 Compare February 3, 2026 16:27
@wydrox
Copy link
Author

wydrox commented Feb 3, 2026

recheck

@wydrox
Copy link
Author

wydrox commented Feb 3, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 3, 2026
leoisadev1 pushed a commit to leoisadev1/oh-my-opencode that referenced this pull request Feb 3, 2026
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