⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@tommy-stevenson
Copy link

Description

Adds a configurable sync_agent_on_message_added attribute to SessionManager that 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_agent call. Currently, SessionManager syncs the agent state after every MessageAddedEvent, 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:

  • Messages are already persisted via append_message on each MessageAddedEvent
  • Agent state rarely changes between messages within a single invocation
  • The final state captured by AfterInvocationEvent sync is usually what matters for session resumption

This change allows session manager implementations to disable per-message syncing while still maintaining proper state persistence through the existing AfterInvocationEvent sync, which captures the final agent state including any conversation manager updates.

Public API Changes

SessionManager now includes a sync_agent_on_message_added class attribute that controls whether the agent is synced after each message is added:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant