Fix: Kiro Gateway Anthropic system message compatibility - #271
Conversation
|
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. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Anthropic adapter to accept Claude Code鈥檚 non-standard inline system messages (i.e., messages[].role == "system") and promotes them into the effective system prompt so they keep system semantics rather than being rejected at validation time.
Changes:
- Expanded
AnthropicMessage.rolevalidation to allow a compatibility"system"role. - Added
split_anthropic_system_messages()and updated the Anthropic鈫扠iro conversion path to extract/merge inline system instructions into the system prompt while excluding them from conversation history. - Added regression tests covering inline system-message acceptance and payload promotion; updated
.gitignoreto ignore.venv/.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
kiro/models_anthropic.py |
Allows "system" as a compatibility role in AnthropicMessage. |
kiro/converters_anthropic.py |
Extracts inline system messages into the system prompt and skips them during message-history conversion. |
tests/unit/test_converters_anthropic.py |
Adds tests for inline system-message skipping/promotion and related behavior. |
fix_anthropic-system-message-compatibility_en.md |
English write-up of the change rationale/validation steps. |
fix_anthropic-system-message-compatibility_zh.md |
Chinese write-up of the change rationale/validation steps. |
.gitignore |
Ignores local virtualenv directory and normalizes the htmlcov/ entry. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| for message in messages: | ||
| if message.role == "system": | ||
| system_text = convert_anthropic_content_to_text(message.content) |
| class TestSplitAnthropicSystemMessages: | ||
| """Tests for promoting inline system messages to the system prompt.""" | ||
|
|
||
| def test_extracts_and_preserves_conversation_order(self): | ||
| messages = [ |
|
@ytchen175 could you give a try to this gateway: https://github.com/ankitcharolia/kiro-gateway It works quite well with All AI harness and actively being developed. The most important thing is that it is ACP compliant |
Branch:
mainTitle:
Fix: Kiro Gateway Anthropic system message compatibilityDescription
systemmessage inside the Anthropicmessagesarray.Root Cause
Claude Code sent a request containing
messages[1].role = "system". The gateway schema only accepteduserandassistantroles, so Pydantic rejected the request with HTTP 422 before conversion.Old Logic
AnthropicMessage.rolewas limited touserandassistant.New Logic
systemas a compatibility role inAnthropicMessage.systemfield.Why it works
DoD
Code Changes
kiro/models_anthropic.pysystemrole inAnthropicMessage.kiro/converters_anthropic.pytests/unit/test_converters_anthropic.py.gitignoreValidate Results
Result:
249 passed, 1 warning.Additional smoke checks:
claude-opus-5.git diff --check: passed.Commit Messages
Fix: Kiro Gateway Anthropic system message compatibility