Skip to content

feat(models): add Claude Sonnet 5 support - #260

Open
parashuchandra wants to merge 2 commits into
jwadow:mainfrom
parashuchandra:feat/claude-sonnet-5-support
Open

feat(models): add Claude Sonnet 5 support#260
parashuchandra wants to merge 2 commits into
jwadow:mainfrom
parashuchandra:feat/claude-sonnet-5-support

Conversation

@parashuchandra

@parashuchandra parashuchandra commented Jul 24, 2026

Copy link
Copy Markdown

Summary

This PR bundles two related fixes needed to get Claude Sonnet 5 working
end-to-end with Claude Code CLI 2.x through the gateway:

  1. Register claude-sonnet-5 as a known model
  2. Fix a request-validation bug that blocks Claude Code CLI 2.x from
    working with any model (not just Sonnet 5) — found while testing not work with cursor #1

1. Claude Sonnet 5 support

  • kiro/config.py: add claude-sonnet-5 to FALLBACK_MODELS, so it's
    recognized as a known model during DNS-failure recovery instead of an
    unverified passthrough.
  • kiro/model_resolver.py: fix a gap in normalize_model_name's
    no-minor-version pattern. Models without a minor segment (claude-sonnet-4,
    claude-sonnet-5) only stripped an 8-digit date suffix, not a latest or
    trailing-numeric suffix — unlike the with-minor-version pattern, which
    already handled all three. This meant claude-sonnet-5-latest failed to
    normalize and incorrectly resolved as unverified passthrough.
  • README.md: list Claude Sonnet 5 in Available Models.
  • tests/unit/test_config.py: new TestClaudeSonnet5Support — fallback
    registration, name normalization (plain/date/latest suffixes), cache
    resolution (source=cache, is_verified=True), and family-isolated
    suggestions.

2. Accept role=system inline in AnthropicMessage

Claude Code CLI 2.x sends messages with role="system" inline in the
messages array (e.g. injected <system-reminder> context), rather than
exclusively via the top-level system field. AnthropicMessage.role only
accepted user/assistant, so these requests failed with a 422
literal_error — before ever reaching normalize_message_roles() in
converters_core.py, which already exists to convert unknown roles to
user downstream (same lineage as the alternating-roles fix in #64).

Reproduced directly: running claude -p "..." against the gateway failed
with:

Add claude-sonnet-5 to FALLBACK_MODELS so the gateway recognizes it as
a known model when /ListAvailableModels is unreachable (DNS failure
recovery), and so it is verified (source=cache, is_verified=True)
rather than passed through as an unrecognized model.

Also fix a pre-existing gap in normalize_model_name's no-minor-version
pattern: models without a minor segment (e.g. claude-sonnet-4,
claude-sonnet-5) only stripped an 8-digit date suffix, not a 'latest'
or trailing-numeric suffix, unlike the with-minor-version pattern which
already handled all three. This meant 'claude-sonnet-5-latest' failed
to normalize to 'claude-sonnet-5' and would incorrectly resolve as an
unverified passthrough model.

- kiro/config.py: register claude-sonnet-5 in FALLBACK_MODELS
- kiro/model_resolver.py: extend no_minor_pattern to strip 'latest'
  and trailing-numeric suffixes, matching standard_pattern's behavior
- tests/unit/test_config.py: add TestClaudeSonnet5Support covering
  fallback registration, name normalization (plain/date/latest
  suffixes), cache resolution, and family-isolated suggestions
- README.md: list Claude Sonnet 5 in Available Models
@cla-bot

cla-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: parashuchandra.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

Claude Code CLI 2.x sends messages with role='system' inline in the
messages array (e.g. injected <system-reminder> context), rather than
exclusively via the top-level 'system' field. The AnthropicMessage
model's role Literal only accepted 'user'/'assistant', so these
requests failed with a 422 literal_error before ever reaching
normalize_message_roles() in converters_core.py, which already exists
to convert unknown roles to 'user' downstream (fixes issue jwadow#64 lineage).

Widen the Literal to include 'system' so validation succeeds and the
existing normalization logic can do its job.

- kiro/models_anthropic.py: widen AnthropicMessage.role Literal
- tests/unit/test_models_anthropic.py: add TestAnthropicMessageRole
  covering user/assistant (no regression), system (new), and invalid
  roles still rejected
@cla-bot

cla-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: parashuchandra.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@ankitcharolia

Copy link
Copy Markdown

@parashuchandra could you give a try to this gateway: https://github.com/ankitcharolia/kiro-gateway and all models are automatically added , no model needed to be updated

It works quite well with All AI harness and actively being developed. The most important thing is that it is ACP compliant

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