Skip to main content
Stateful agents maintain conversational history and state across interactions using sessions. The ACP SDK leverages this concept by maintaining a descriptor for each session and storing its contents at resource servers. This allows agents to access the complete history of interactions within a session, provided that the same session is used consistently across runs.

ACP Client Sessions

The ACP SDK provides a convenient way to maintain session through the session() context manager. When using a session, the SDK automatically handles session ID management, ensuring that all runs within the session share the same ID. This makes it easy to build stateful conversations where agents can reference previous interactions:
session.py

ACP Server sessions

When building ACP agent, the context argument contains a session instance containing session’s ID, history and latest state from all the previous runs in the same session.
stateful_agent.py