Skip to content

fix: promote role:system messages from messages array to system param in Bedrock translator - #2189

Merged
nacx merged 4 commits into
envoyproxy:mainfrom
Killusions:fix/anthropic-mid-conversation-system
Jun 10, 2026
Merged

fix: promote role:system messages from messages array to system param in Bedrock translator#2189
nacx merged 4 commits into
envoyproxy:mainfrom
Killusions:fix/anthropic-mid-conversation-system

Conversation

@Killusions

@Killusions Killusions commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

In the Anthropic-to-AWS-Bedrock translator, Claude Code with mid-conversation-system beta sends system prompts as {"role": "system"} in the messages array. The SDK has no system role constant so these hit the default error case. This promotes them to the top-level system param before conversion.

Fixes #2206

⚒️ with ❤️ by @siemens

… in Bedrock translator

Some clients (e.g. Claude Code with the mid-conversation-system beta) send system prompts as {"role": "system"} entries in the messages array. The Anthropic SDK does not define a system role constant, so these messages would hit the default case and return an error. This promotes those entries to the top-level system parameter before the message conversion loop.

Signed-off-by: Linus Schlumberger <linus.schlumberger@siemens.com>
@Killusions
Killusions requested a review from a team as a code owner June 3, 2026 22:01
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 3, 2026
@codecov-commenter

codecov-commenter commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.73%. Comparing base (bcc8031) to head (1c472f6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2189   +/-   ##
=======================================
  Coverage   84.73%   84.73%           
=======================================
  Files         144      144           
  Lines       21117    21134   +17     
=======================================
+ Hits        17893    17908   +15     
- Misses       2144     2145    +1     
- Partials     1080     1081    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Killusions

Copy link
Copy Markdown
Contributor Author

@nacx This was an oversight in #2103 and now surfaced due to changes in Claude Code's behavior, could you maybe have a look?

@nacx
nacx enabled auto-merge (squash) June 10, 2026 16:26
@nacx
nacx merged commit 2bb3904 into envoyproxy:main Jun 10, 2026
30 checks passed
hustxiayang pushed a commit to hustxiayang/ai-gateway that referenced this pull request Jun 12, 2026
… in Bedrock translator (envoyproxy#2189)

**Description**

In the Anthropic-to-AWS-Bedrock translator, Claude Code with
mid-conversation-system beta sends system prompts as {"role": "system"}
in the messages array. The SDK has no system role constant so these hit
the default error case. This promotes them to the top-level system param
before conversion.

Fixes envoyproxy#2206

Signed-off-by: Linus Schlumberger <linus.schlumberger@siemens.com>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
Signed-off-by: yxia216 <yxia216@bloomberg.net>
hustxiayang pushed a commit to hustxiayang/ai-gateway that referenced this pull request Jun 16, 2026
… in Bedrock translator (envoyproxy#2189)

**Description**

In the Anthropic-to-AWS-Bedrock translator, Claude Code with
mid-conversation-system beta sends system prompts as {"role": "system"}
in the messages array. The SDK has no system role constant so these hit
the default error case. This promotes them to the top-level system param
before conversion.

Fixes envoyproxy#2206

Signed-off-by: Linus Schlumberger <linus.schlumberger@siemens.com>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
Signed-off-by: yxia216 <yxia216@bloomberg.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Anthropic system messages dropped in Bedrock translator

3 participants