Skip to content

Support claude-fable-5-1 and claude-mythos-5-1 - #179

Closed
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/fable-5-1
Closed

Support claude-fable-5-1 and claude-mythos-5-1#179
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/fable-5-1

Conversation

@iceteaSA

@iceteaSA iceteaSA commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Adds model support for Fable 5.1 and Mythos 5.1, released this week. Claude Code 2.1.257 already defaults to claude-fable-5-1 (confirmed on the wire), so a plugin session that selects it currently falls through to default handling.

What's here

  • Model specs (models.ts) for claude-fable-5-1 and claude-mythos-5-1: 1M context, 128K max output, $10/$50 in/out per MTok. Cache read drops to $0.25/MTok (down from $1 on 5.0); 1h cache write stays $20.
  • Adaptive-thinking normalization extended to the 5.1 ids — manual/disabled thinking is stripped to adaptive, same as Fable 5. Effort variants (low..max) pass through.
  • Forced tool_choice stripped for 5.1 only. 5.1 rejects tool_choice: any / {type:"tool"} with a 400 (new vs 5.0). The normalizer deletes the field on every request path — main turns, lane-start, and cache prewarm. Fable 5 and Opus are untouched.
  • Server-side safety fallback: OAuth 5.1 requests opt into the server-side-fallback-2026-07-01 beta exactly like Fable 5 / Opus 5.
  • Distinct recovery family key (fable-5-1), checked before the fable-5 prefix so a 5→5.1 model switch can't cross-contaminate an in-flight recovery cycle.
  • Shared weekly Fable scope: a claude-fable-5-1 request counts against the same claude-weekly-scoped-fable window as Fable 5, matching how the plans meter both.
  • Pi catalog entries for both ids.

Verification

1322 tests pass (0 fail; the one flaky relay-worker-miniflare parallel timeout solo-greens). Typecheck, format, biome clean. Cross-family review (GLM) approved 0 must; the normalization, tool_choice strip, family key, and scoped-quota matcher each carry a mutation-proven test.

Mythos 5.1 is Glasswing-only, so its path is present but unexercised here.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Adds model support for the newly released Fable 5.1 and Mythos 5.1. Without it, sessions using these models fall through to default handling.

New Features

  • Registers claude-fable-5-1 and claude-mythos-5-1 with 1M context, 128K max output, and $10/$50 per MTok pricing.
  • Cache reads drop to $0.25/MTok (from $1 on 5.0); 1h cache writes stay $20.
  • Adds both models to the Pi provider catalog.

Behavior Changes

  • Strips forced tool_choice for 5.1 only; 5.1 rejects it with a 400 error.
  • Normalizes manual/disabled thinking to adaptive for 5.1, matching Fable 5.
  • Opts Fable 5.1 requests into the server-side fallback beta; Mythos 5.1 is excluded.
  • Uses a distinct recovery family key (fable-5-1) so a 5→5.1 switch stays isolated.
  • Shares the weekly Fable quota scope with Fable 5.

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

Review in cubic

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 15 files

Architecture diagram
sequenceDiagram
    participant User as Plugin Session
    participant Catalog as Pi/OpenCode Model Catalog
    participant Core as Core Model Registry
    participant Transform as Request Normalizer
    participant OAuth as OAuth Header Builder
    participant Recovery as Recovery and Fallback Manager
    participant Quota as OAuth Quota Matcher
    participant Anthropic as Anthropic API

    Note over User,Anthropic: Runtime flow for Claude Fable 5.1 and Mythos 5.1

    User->>Catalog: Select model by id
    Catalog->>Core: Resolve model specification
    Core-->>Catalog: Model name, capabilities, limits, pricing
    Catalog-->>User: 1M context, 128K output, reasoning and tool support

    User->>Recovery: Start request with selected model
    Recovery->>Recovery: Classify recovery family
    alt Fable 5.1
        Recovery->>Recovery: Use isolated fable-5-1 recovery state
    else Mythos 5.1
        Recovery->>Recovery: No content-filter recovery downgrade
    end

    Recovery->>Transform: Normalize request body
    Transform->>Transform: Map manual or disabled thinking to adaptive
    Transform->>Transform: Preserve effort low, medium, high, xhigh, or max
    alt Forced tool_choice is any or tool
        Transform->>Transform: Strip tool_choice
    else Other tool_choice or no tool_choice
        Transform->>Transform: Preserve request field
    end
    Transform-->>Recovery: Normalized request body

    Recovery->>Quota: Match model to OAuth quota scope
    Quota-->>Recovery: Shared claude-weekly-scoped-fable window

    Recovery->>OAuth: Build OAuth request headers
    OAuth->>OAuth: Attach server-side-fallback-2026-07-01 beta
    OAuth-->>Recovery: Authorization and Anthropic beta headers

    Recovery->>Anthropic: POST messages with normalized body and headers
    alt Successful response
        Anthropic-->>Recovery: Stream or complete response
        Recovery-->>User: Return model response
    else Recoverable content-filter refusal for Fable 5.1
        Anthropic-->>Recovery: Refusal response
        Recovery->>Recovery: Activate fable-5-1 recovery cycle
        Recovery->>Anthropic: Retry with configured fallback model
        Anthropic-->>Recovery: Fallback response
        Recovery-->>User: Return response with recovery status
    else HTTP 400 caused by forced tool_choice
        Anthropic-->>Recovery: Request validation error
        Recovery-->>User: Return API error
    end

    opt Cache prewarm or lane-start request
        User->>Transform: Prepare model-specific request
        Transform->>Transform: Apply the same 5.1 normalization rules
        Transform-->>User: Request body for cache or lane operation
    end

    Note over Core,Catalog: Mythos 5.1 is cataloged as limited and is intended for Glasswing-only usage
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/opencode/src/index.ts Outdated
Comment thread packages/opencode/src/server-fallback.ts Outdated
Comment thread packages/core/src/models.ts
Comment thread packages/opencode/src/fable-fallback.ts Outdated
Comment thread packages/opencode/src/tests/transform.test.ts Outdated
Comment thread packages/opencode/src/index.ts Outdated
ualtinok added a commit that referenced this pull request Sep 2, 2026
Reconcile the two contributed implementations against captured Claude Code 2.1.258 traffic, including model metadata, billing identity, conditional thinking-prefix controls, Pi support, and documentation.

Co-authored-by: iceteaSA <171169159+iceteaSA@users.noreply.github.com>
@ualtinok

ualtinok commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Integrated into main in db02924 after reconciling this implementation with #180 and verifying the final request behavior against captured Claude Code 2.1.258 traffic. The squash commit retains your co-author attribution. Thank you for the model support and test coverage.

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.

2 participants