fix: keep pre-tool assistant text in tool-call history - #21
Merged
Merged
Conversation
When a model emitted text before calling a tool, every adapter dropped it: the appended assistant turn went on the wire with content null (or with only tool_use/functionCall blocks). On the post-tool re-prompt the model had no record of having spoken, so it said the same sentence again — and since that turn is streamed to TTS, the caller hears it twice. appendAssistantToolCall now takes the pre-tool text and each adapter carries it in its native shape: OpenAI content alongside tool_calls, Anthropic and Bedrock a text block before the tool_use blocks, Gemini a text part before the functionCall part. Blank text is omitted rather than sent as an empty block, which Anthropic and Bedrock reject. The argument is optional, so existing callers keep compiling and get the old behaviour until they pass it. Contract tests [22] and [23] cover both paths for every adapter. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Releasing is a separate step owned by someone else; this branch should not carry a version bump. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
xquanluu
marked this pull request as ready for review
September 21, 2026 12:10
davehorton
approved these changes
Sep 21, 2026
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.
https://jambonz.freshdesk.com/a/tickets/3005