agent.session controls a hydrated session, while server.sessions lists and manages both persisted and active sessions.
Imports
Hydrated session
str
The owning agent ID.
AgentTurn | None
The current unfinished turn, if one exists.
snapshot
replace_messages
RuntimeError while a turn is active.
clear_messages
agent.clear() remains available as a compatibility method.
replay_events
clear_events
turn
agent.turn() delegates to this method.
abort
True. Returns False when the session is idle.
Server session catalog
Pass the storage shared by server agents when persisted sessions must be discoverable before hydration:session_storage, active agents still appear. Persisted sessions are discovered from active agents’ storage backends.
list
AgentSessionPage.items is an immutable tuple and total_pages is computed from total and page_size.
get
AgentSessionInfo includes:
idpersistedandactive- copied
state message_countandevent_countcreated_atandupdated_at- live
last_activityandconnection_count
evict
delete
Existing storage data
Session discovery supports existing{agent_id}:state, {agent_id}:messages, and {agent_id}:event_log records. Legacy records receive a small session manifest when first discovered; no manual migration is required.