Repository navigation
fix(client): format string system messages in anthropic adapter - #16316
Merged
axiomofjoy merged 2 commits intoSep 25, 2026
Merged
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
axiomofjoy
enabled auto-merge (squash)
September 25, 2026 22:22
axiomofjoy
approved these changes
Sep 25, 2026
axiomofjoy
disabled auto-merge
September 25, 2026 23:04
Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.
fixes #16228
Description
In
packages/phoenix-client/src/phoenix/client/helpers/sdk/anthropic/messages.py,to_chat_messages_and_kwargsappended string system messages (message["content"]) verbatim without running them throughformatter.format(..., variables=variables).As a result, when formatting prompt versions for Anthropic (
to_chat_messages_and_kwargsorPromptVersion.format(sdk="anthropic")), variables in string system messages (e.g.You are {{ persona }}.) were ignored and sent as literal templates inkwargs["system"], while non-system messages and multi-part system messages had their variables formatted properly.This PR routes string system message content through
formatter.format(message["content"], variables=variables)in the Anthropic adapter, aligning it with:_ContentConversion.to_anthropic->_TextContentPartConversion.to_anthropic)_MessageConversion.to_anthropic)_SystemMessageConversion.to_openai)generate_content.py)Testing
packages/phoenix-client/tests/canary/sdk/anthropic/test_messages.pytesting single string system messages with variables, multiple system messages, andPromptVersion.format(..., sdk="anthropic").packages/phoenix-client/tests/canary/sdk/anthropic/test_messages.pypass.make lint-pythonandmake typecheck-pythonpass cleanly with zero errors.Contributor License Agreement (CLA)
I have read the CLA Document and I hereby sign the CLA