fix(model/openaimodel): stop replaying prior-turn reasoning to the API - #1395
fix(model/openaimodel): stop replaying prior-turn reasoning to the API#1395hanorik wants to merge 1 commit into
Conversation
|
The drop is the right call, and the conversion holds where it matters: no part marked as a thought contributes text to any emitted item, on any role and in any position, and a thought-marked call or response still survives with its pairing intact. Exercising it turned up one consequence worth a decision before this lands, and three smaller things after it. The run loop stops terminating on a reasoning-only turn. Driving the test those two runs come from — drop it in
|
Problem
model/openaimodelreports model reasoning to the caller as thought parts andthen sends those parts straight back to the API on the next turn as ordinary
assistant text.
convertContentsmatched every part onpart.Text != ""withno guard on
part.Thought, and nothing upstream strips thought parts. Thereasoning accumulated into the same
textPartsbuffer as the real answer andflushed with it into a single assistant message, so nothing separated the
model's private scratchpad from what it had actually said, and the following
turn was answered against it. A turn that produced only reasoning replayed as an
assistant message the model never sent.
Solution
Drop replayed reasoning rather than send it. The Responses API takes it back
only as an input item referencing the id of the item that produced it, and ADK
carries no such ids, so there is no correct way to replay it; adk-python's
Responses backend drops it for the same reason. Text and call/response are now
read independently rather than as arms of one switch, because a single part can
carry both — choosing between them either put the reasoning on the wire or
dropped the call and stranded its response in
callTracker. A thought-markedcall or response therefore survives while its reasoning text does not.
Two adjacent holes close with it. A thought carrying only a signature used to
reach the
defaultarm and fail the whole conversion, and is now dropped, sincea Responses request has nowhere to put one either way; and a part marked as a
thought that carries media or code is still rejected as an unsupported part
rather than vanishing from the request unannounced. A request left empty by the
drop now reports that, instead of
ErrNoContentsas though the caller had sentnothing. No exported API changes — the only new declaration is the unexported
replayedReasoning.