fix(models): accept opus-4.8 and hoist inline system messages - #246
Open
sour2001 wants to merge 1 commit into
Open
fix(models): accept opus-4.8 and hoist inline system messages#246sour2001 wants to merge 1 commit into
sour2001 wants to merge 1 commit into
Conversation
- Add claude-opus-4.8 to FALLBACK_MODELS so requests resolve from cache instead of being rejected as unknown pass-through models. - Hoist inline 'role: system' messages into the top-level system field in AnthropicMessagesRequest and AnthropicCountTokensRequest. Fixes 422 "Input should be 'user' or 'assistant'" from clients (Claude Code, LangChain, OpenAI-style callers) that inline the system prompt in the messages array. - Add comprehensive tests for both changes (edge cases: multiple system messages, merge with existing string/list system, block content, empty content, count_tokens endpoint).
|
Thanks for the PR! 🎉 Before merge, we need a one-time CLA confirmation. Full CLA text: Please reply once with: You need to write once, all further messages from me can be ignored. |
Author
|
I have read the CLA and I accept its terms |
musa-2066462
approved these changes
Jul 16, 2026
musa-2066462
left a comment
There was a problem hiding this comment.
I just tested this code locally and it works perfectly.
U just need to change the anthropic model to this :
export ANTHROPIC_MODEL="claude-opus-4-8-20260528"
|
@sour2001 @musa-2066462 could you give a try to this gateway: https://github.com/ankitcharolia/kiro-gateway It supports all necessary endpoints for OpenAI and Anthropic. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
Two related fixes so
claude-opus-4.8works end-to-end through the gateway. Both surfaced as422errors when pointing a client (Claude Code) at the Anthropic endpoint.1. Add
claude-opus-4.8toFALLBACK_MODELSThe fallback model list topped out at
claude-opus-4.7. When Kiro's/ListAvailableModelsdoesn't return 4.8 (or the gateway falls back to the static list), the resolver treated it as an unknown pass-through model, which Kiro then rejected. Added the ID so it resolves from cache like the other current models. The name normalizer already handles the common input shapes (claude-opus-4-8,claude-4.8-opus-high, date suffixes) — they all map toclaude-opus-4.8.2. Hoist inline
role: "system"messagesAnthropic's schema only accepts
user/assistantinside themessagesarray; the system prompt belongs in the top-levelsystemfield. Some clients (Claude Code, LangChain, OpenAI-style callers) inlinerole: "system"messages instead, which failed with:Added a
mode="before"validator onAnthropicMessagesRequestandAnthropicCountTokensRequestthat moves inline system messages into the top-levelsystemfield before per-message validation runs. It:system(string or list-of-blocks form) rather than clobbering itApplied to both request models for consistency (messages + count_tokens).
Test coverage
All new tests follow the existing Arrange-Act-Assert + print-diagnostics style.
tests/unit/test_models_anthropic.py::TestInlineSystemMessageHoisting— 10 tests: single/multiple inline system messages, merge with existing string/list system, block-form content, empty content, count_tokens endpoint, and typed-object passthrough.tests/unit/test_config.py::TestFallbackModelsIntegration::test_opus_4_8_present_and_resolves— verifiesclaude-opus-4.8is in the list and resolves from cache for both dot and dash client formats.Full suite: 1702 passed.