_response_messages_turn_start_index compared the agent's result["messages"]
prefix against the API layer's bare {"role", "content"} dicts with whole-dict
equality. The agent's copies carry timestamp / _db_persisted (append_message)
and reasoning / finish_reason on assistant rows, so the check failed every
turn, turn_start fell to 0, and the fallback re-appended the full prior
transcript on top of itself: stored conversation_history grew 3 -> 8 -> 17
instead of 2 -> 4 -> 6, and that duplicated transcript was what the model was
replayed on the next turn.
Compare the prefix by what each message says (role, content, tool_calls,
tool_call_id) instead. The turn-only result shape and the compressed
transcript path are unchanged; a genuinely divergent transcript still falls
back to appending.
Fixes #95137
Fixes #101644
Refs #82513 (the doubling was the measured size driver; byte-capping stored tool
outputs is a separate design call since the stored history is replayed to the model)
Co-authored-by: berkantay <berkantay.5@gmail.com>
2 lines
10 B
Plaintext
2 lines
10 B
Plaintext
berkantay
|