router.session

class agentopera.router.session.SessionManager(repository: SessionRepository, agent_runtime: DistAgentEngine, session_timeout_minutes: int = 30, cleanup_interval_sec: int = 60)[source]

Bases: object

async start()[source]

Starts the session manager background task.

async shutdown()[source]

Gracefully stops the background task.

async start_session(session_id: str) Session[source]

Gets or creates session by ID.

async start_new_session(session_id: str) Session[source]

Creates a brand-new session.

async get_session(session_id: str) Session | None[source]

Gets session and updates last-used time.

async register_agent(session_id: str, agent_id: AgentId)[source]
async interrupt_streaming_agents(session_id: str)[source]

Sends a transient cancel signal to all currently streaming agents in a session. This does not end the session or mark it as inactive.

async unmark_agent_streaming(session_id: str, agent_id: AgentId)[source]
async expire_old_sessions()[source]
async end_session(session_id: str)[source]
class agentopera.router.session.Session(*, session_id: str, start_time: ~datetime.datetime = <factory>, last_updated: ~datetime.datetime = <factory>, agents_streaming: ~typing.Set[~agentopera.engine.types.agent.agent_id.AgentId] = <factory>)[source]

Bases: BaseModel

session_id: str
start_time: datetime
last_updated: datetime
agents_streaming: Set[AgentId]
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

touch()[source]

Update last active time.

mark_agent_streaming(agent_id: AgentId)[source]

Mark an agent as currently streaming.

unmark_agent_streaming(agent_id: AgentId)[source]

Unmark an agent from live-streaming mode

end_session()[source]

Marks session as complete.

class agentopera.router.session.InMemorySessionRepository[source]

Bases: SessionRepository

async save_session(session: Session)[source]

Stores session in-memory.

async get_session(session_id: str) Session[source]

Retrieves session from memory, or creates a new one if not found.

async delete_session(session_id: str)[source]

Deletes session from memory.