This ticket is a follow-up to #7658.
While the current protocol mandates saving every turn, it doesn't clearly define what constitutes a "turn". This leads to a problem of "sub-turns", where an agent's multiple attempts to use a tool for a single user prompt are saved as separate, noisy memories.
We need to refine the protocol with a clearer definition.
Proposed Definition of a "Turn":
A single "turn" encompasses the entire agent process from receiving a user's PROMPT to delivering the final RESPONSE that awaits the next user prompt. All intermediate steps (tool calls, self-corrections, errors, and retries) are considered part of this single turn.
Proposed Protocol Refinement:
- The agent must internally accumulate its thought process, including all tool attempts and self-corrections, throughout its entire process for a given prompt.
- The
add_memory tool must only be called once per turn, at the very end, just before delivering the final response to the user.
- The
thought parameter for the add_memory call should be a consolidated summary of the entire internal monologue for that turn.
- The
response parameter should be a consolidated log of all responses generated during the turn, including self-corrections, error messages, and the final response to the user.
This change will significantly increase the signal-to-noise ratio of the stored memories. It also acknowledges the current limitation of not having agent lifecycle hooks and places the responsibility of consolidating the turn on the agent itself.
This ticket is a follow-up to #7658.
While the current protocol mandates saving every turn, it doesn't clearly define what constitutes a "turn". This leads to a problem of "sub-turns", where an agent's multiple attempts to use a tool for a single user prompt are saved as separate, noisy memories.
We need to refine the protocol with a clearer definition.
Proposed Definition of a "Turn": A single "turn" encompasses the entire agent process from receiving a user's
PROMPTto delivering the finalRESPONSEthat awaits the next user prompt. All intermediate steps (tool calls, self-corrections, errors, and retries) are considered part of this single turn.Proposed Protocol Refinement:
add_memorytool must only be called once per turn, at the very end, just before delivering the final response to the user.thoughtparameter for theadd_memorycall should be a consolidated summary of the entire internal monologue for that turn.responseparameter should be a consolidated log of all responses generated during the turn, including self-corrections, error messages, and the final response to the user.This change will significantly increase the signal-to-noise ratio of the stored memories. It also acknowledges the current limitation of not having agent lifecycle hooks and places the responsibility of consolidating the turn on the agent itself.