autoplay_sdk.agent_state.v2 (SessionState) as the only supported agent-state model.
SessionState v2
Overview
autoplay_sdk.agent_state.v2 provides the supported three-state FSM and enforces a clear timeout-only exit rule from active states. Timeouts and cooldowns are session-level settings rather than per-trigger values.
States
Transition rules
_timeout_to_thinking() is a private method called exclusively by tick(). Never call it directly in your code β use tick() on every incoming event or background pulse instead.Session-level timeout settings
Session-owned routing fields
These fields are persisted directly onSessionState and are the canonical delivery routing source:
SessionState.on_conversation_linked(link) transition rules:
ConversationEventType.NEW: always setconversation_linked=Trueand overwriteconversation_idConversationEventType.REPLY_EXISTING: set link fields only when currently unlinked; keep existingconversation_idwhen already linked- invariant: during a live session, this path never flips
conversation_linkedback toFalse
State and flag matrix
Per-state sub-dataclasses
Each state carries a typed sub-object that tracks its own metrics. These are reset when the session enters that state.ThinkingState
ProactiveState
ReactiveState
Public exports
Import
InvalidTransitionError from autoplay_sdk.agent_state.v2 with the rest of the v2 symbols.Key methods
Persistence
session_id, and treat conversation_id as derived session-owned routing state.
Example
See also
- Support AI agent context assembly β query-time RAG assembly (
rag_query). - Proactive onboarding agent β product framing for proactive experiences.
- Logging β
autoplay_sdk.agent_state.v2.session_statelogger and relatedevent_typekeys.