feat: add sync_agent_on_message_added config to SessionManager#1507
Open
tommy-stevenson wants to merge 1 commit intostrands-agents:mainfrom
Open
feat: add sync_agent_on_message_added config to SessionManager#1507tommy-stevenson wants to merge 1 commit intostrands-agents:mainfrom
tommy-stevenson wants to merge 1 commit intostrands-agents:mainfrom
Conversation
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.
Description
Adds a configurable
sync_agent_on_message_addedattribute toSessionManagerthat allows session manager implementations to opt out of syncing agent state after each message is added, while preserving backward compatibility.Motivation
Session managers that use append-only storage backends (such as AgentCoreMemorySessionManager) create a new event for each
sync_agentcall. Currently,SessionManagersyncs the agent state after everyMessageAddedEvent, which results in redundant events with identical agent state when the state hasn't changed between messages. This redundancy increases storage costs, API call volume, and I/O operations unnecessarily.Per-message syncing is redundant because:
append_messageon eachMessageAddedEventAfterInvocationEventsync is usually what matters for session resumptionThis change allows session manager implementations to disable per-message syncing while still maintaining proper state persistence through the existing
AfterInvocationEventsync, which captures the final agent state including any conversation manager updates.Public API Changes
SessionManagernow includes async_agent_on_message_addedclass attribute that controls whether the agent is synced after each message is added: