feat(models): add Claude Sonnet 5 support - #260
Conversation
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
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: parashuchandra.
|
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
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: parashuchandra.
|
|
@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 |
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:
claude-sonnet-5as a known modelworking with any model (not just Sonnet 5) — found while testing not work with cursor #1
1. Claude Sonnet 5 support
kiro/config.py: addclaude-sonnet-5toFALLBACK_MODELS, so it'srecognized as a known model during DNS-failure recovery instead of an
unverified passthrough.
kiro/model_resolver.py: fix a gap innormalize_model_name'sno-minor-version pattern. Models without a minor segment (
claude-sonnet-4,claude-sonnet-5) only stripped an 8-digit date suffix, not alatestortrailing-numeric suffix — unlike the with-minor-version pattern, which
already handled all three. This meant
claude-sonnet-5-latestfailed tonormalize and incorrectly resolved as unverified passthrough.
README.md: list Claude Sonnet 5 in Available Models.tests/unit/test_config.py: newTestClaudeSonnet5Support— fallbackregistration, name normalization (plain/date/latest suffixes), cache
resolution (
source=cache,is_verified=True), and family-isolatedsuggestions.
2. Accept
role=systeminline in AnthropicMessageClaude Code CLI 2.x sends messages with
role="system"inline in themessagesarray (e.g. injected<system-reminder>context), rather thanexclusively via the top-level
systemfield.AnthropicMessage.roleonlyaccepted
user/assistant, so these requests failed with a 422literal_error— before ever reachingnormalize_message_roles()inconverters_core.py, which already exists to convert unknown roles touserdownstream (same lineage as the alternating-roles fix in #64).Reproduced directly: running
claude -p "..."against the gateway failedwith: