fix: switch to Responses API and remove duplicate assistant message#33
Open
fix: switch to Responses API and remove duplicate assistant message#33
Conversation
…ponses API
With the Responses API, when the outer loop manually pushed
step.response.messages back into context.messages and re-called streamText,
the provider had to re-convert {role:'tool'} history to function_call_output
format across separate API calls — an unreliable round-trip that broke the
second tool trigger.
Setting maxSteps: MAX_STEPS delegates all tool-call cycles within a single
user turn to the SDK, which manages the function_call / function_call_output
pairing internally and consistently. The outer loop now only handles
context compaction, retries, and per-user-turn iteration.
https://claude.ai/code/session_01FLbdEJ2hYu4mwmkLvFiNbx
The Responses API defaults store=true, which uploads conversation data for model improvement. Set store:false unconditionally so data is not retained server-side. Reasoning effort is still applied when configured. https://claude.ai/code/session_01FLbdEJ2hYu4mwmkLvFiNbx
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.
Responses API instead of Chat Completions
since onResponse already accumulates step.response.messages; the
duplicate caused consecutive assistant messages which broke multi-turn
conversations in the Responses API
https://claude.ai/code/session_01FLbdEJ2hYu4mwmkLvFiNbx