Repository navigation
fix(client): keep tools when anthropic tool_choice is none - #16535
Merged
cephalization merged 1 commit intoOct 6, 2026
Merged
cephalization merged 1 commit into
cephalization merged 1 commit into
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
BlueX888
force-pushed
the
fix/prep-anthropic-tool-choice-none-drops-tools
branch
from
September 26, 2026 03:42
ea3d7b7 to
df346ee
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
cephalization
self-requested a review
October 5, 2026 16:31
cephalization
approved these changes
Oct 6, 2026
cephalization
enabled auto-merge (squash)
October 6, 2026 14:00
_ToolKwargsConversion.to_anthropic returned an empty dict when the
stored prompt's tool_choice was "none", dropping the tools list from
the replayed request even though _ToolChoiceConversion.to_anthropic
already maps "none" to {"type": "none"}. Let that mapping run so a
captured prompt replays with both tools and tool_choice.
cephalization
force-pushed
the
fix/prep-anthropic-tool-choice-none-drops-tools
branch
from
October 6, 2026 14:42
df346ee to
e51d2a0
Compare
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.
Related to #6662 (
tool_choice: nonesupport for Anthropic, delivered for the playground in #15683). No separate issue was filed for this client-side gap.Summary
to_chat_messages_and_kwargsdropped the entiretoolslist from the replayed request when a stored Anthropic prompt hadtool_choice: none, so a request captured with tools but tool use disabled replayed without any tools.Why
_ToolKwargsConversion.to_anthropicinpackages/phoenix-client/src/phoenix/client/helpers/sdk/anthropic/messages.py:513-514returned an empty dict as soon as the stored tool choice was"none":ans["tools"]was already set at that point, so the early return discarded it along with the tool choice._ToolChoiceConversion.to_anthropic(same file, lines 560-561) already maps"none"to{"type": "none"}, and_ToolChoiceConversion.from_anthropic(lines 612-613) already accepts it, so the early return bypassed existing handling on one side of a round trip that otherwise works. The server-side playground sendstool_choice: nonetogether with the tools for the same stored prompt (src/phoenix/server/api/helpers/playground_clients.py:2253-2254and:2276-2278), so capture and replay must round-trip both.Changes
return {}in_ToolKwargsConversion.to_anthropicso the existing_ToolChoiceConversion.to_anthropicmapping emits{"type": "none"}whiletoolsis kept.tool_choice: {"type": "none"}case to theTestToolKwargsround-trip parametrization.TestToolKwargs.test_tool_choice_none_keeps_tools, which captures a request with tools andtool_choice: noneviacreate_prompt_version_from_anthropicand assertsto_chat_messages_and_kwargsreturns both.Testing
On the unpatched tree the two new tests fail (
to_anthropicreturns{};kwargs.get("tools")isNone). With the fix, frompackages/phoenix-client/:I have read the CLA Document and I hereby sign the CLA.