adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Bug: The "thought: true" flag is lost in conversation history on subsequent requests

Open jinookkoo opened this issue 1 year ago • 1 comments

Describe the bug In a multi-agent system configured with stream_mode=sse and planner: builtin(thinkingConfig(include_thoughts=True)), the thought: true flag from model reasoning parts is lost in subsequent requests within the same agent's conversational turn.

When an agent's conversation history is compiled for the next model request, all previous message parts—including those originally marked as thought: true—are converted into plain text parts. This loss of metadata makes it impossible to distinguish and filter out the model's reasoning content in callbacks like before_model_callback, as the identifying thought flag is no longer present.

To Reproduce Steps to reproduce the behavior:

Configure a multi-agent system with the following settings: run_config: stream_mode=sse model: gemini2.5flash planner: builtin(thinkingConfig(include_thoughts=True)) Initiate a conversation with an agent. The initial response will correctly contain reasoning parts with the thought flag, such as parts:[{text:"thinking...", thought:true}]. Continue the conversation with the same agent for another turn. Inspect the contents payload being prepared for the next model request. You will see that the thought parts from the previous turn have been converted into regular text parts, losing the thought: true attribute. For example, parts: [{text:"thinking..."}].

Expected behavior The thought: true flag on message parts should be preserved throughout the entire conversation history for an agent. This would allow developers to access this flag in callbacks (e.g., before_model_callback) to reliably identify and handle the model's reasoning content separately from its final answer.

Additional context The central issue is the loss of the thought metadata when the conversation history is constructed for new requests. It appears that the history is "flattened," causing all previous content to be treated as standard text. This prevents the implementation of logic that needs to differentiate between the model's internal thoughts and the user-facing response. A secondary observation is that during an agent transfer, a {text:"For context:"} part is prepended, which works as expected, but the core issue remains within a single agent's ongoing session

jinookkoo avatar Jun 12 '25 06:06 jinookkoo

Hi @jinookoo and thanks to everyone who participated in this thread.

We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

Thanks for your contribution and understanding!

surajksharma07 avatar Oct 08 '25 08:10 surajksharma07