Automatic per-user conversation management with history, state, and expiry.
Every conversation between a user and your agent is tracked in a session. Sessions store the message history, custom state, and metadata needed to maintain context across multiple interactions.
How Sessions Work
When a message arrives, the interface looks up (or creates) a session keyed by three values:This means:
Each user gets a separate session per chat
Group chats have one session per user within the group
Sessions persist across messages until they expire
InterfaceSession
Each session contains:
Field
Type
Description
session_id
str
Unique identifier (auto-generated UUID)
platform
str
Platform name (e.g., "telegram")
platform_user_id
str
User’s ID on the platform
platform_chat_id
str
Chat/conversation ID
messages
List[Message]
Agent conversation history
session_state
dict
Arbitrary key-value state (mutable)
last_run_output
RunOutput
Most recent agent output
created_at
float
Creation timestamp
last_activity_at
float
Last message timestamp
Conversation History
The session’s messages list is passed to the agent on every call, giving it full context of the conversation:
User: "What is Python?"Agent: "Python is a programming language..."User: "Who created it?" ← agent sees both previous messagesAgent: "Python was created by Guido van Rossum..."
History is automatically truncated to max_session_history (default: 50 messages) to stay within token limits. The most recent messages are always kept.
Session State
Use session_state to store custom per-user data that persists across messages:
from definable.tool.decorator import tool@tooldef set_language(language: str, _session_state: dict = None) -> str: """Set the user's preferred language.""" _session_state["language"] = language return f"Language set to {language}."@tooldef get_preferences(_session_state: dict = None) -> str: """Get the user's preferences.""" lang = _session_state.get("language", "not set") return f"Language: {lang}"
State set in one message is available in all subsequent messages within the same session.
SessionManager
The SessionManager handles creation, lookup, and expiry of sessions. A default instance is created automatically, or you can provide your own.
Automatic Behavior
By default, sessions are:
Created on the first message from a user/chat combination
Reused on subsequent messages from the same user/chat
Expired after session_ttl_seconds of inactivity (default: 1 hour)
Cleaned up automatically when expired sessions are encountered
Custom SessionManager
from definable.agent.interface import SessionManager, TelegramInterface# Sessions expire after 2 hourssession_manager = SessionManager(session_ttl_seconds=7200)interface = TelegramInterface( agent=agent, bot_token="...", session_manager=session_manager,)
SessionManager API
Method
Description
get_or_create(platform, user_id, chat_id)
Get existing session or create a new one
get(platform, user_id, chat_id)
Get session or None if not found/expired
remove(platform, user_id, chat_id)
Remove a session manually
cleanup_expired()
Remove all expired sessions, returns count
active_session_count
Number of active (non-expired) sessions
Manual Session Access
session_manager = SessionManager(session_ttl_seconds=3600)# Get or createsession = session_manager.get_or_create("telegram", "user-123", "chat-456")# Check stateprint(session.session_state)print(len(session.messages))# Cleanupremoved = session_manager.cleanup_expired()print(f"Cleaned up {removed} expired sessions")print(f"Active sessions: {session_manager.active_session_count}")
Session TTL
Sessions expire based on last_activity_at. Every incoming message updates this timestamp via session.touch(). Once the time since last activity exceeds session_ttl_seconds, the session is considered expired and will be removed on the next access or cleanup.
# Short sessions for quick interactionsinterface = TelegramInterface(agent=agent, bot_token="...", session_ttl_seconds=300) # 5 minutes# Long sessions for complex workflowsinterface = TelegramInterface(agent=agent, bot_token="...", session_ttl_seconds=86400) # 24 hours
When a session expires, the next message from that user starts a fresh conversation with no history.
History Truncation
Long conversations are automatically truncated to prevent token limit issues:
interface = TelegramInterface( agent=agent, bot_token="...", max_session_history=20, # Keep only the 20 most recent messages)
The session’s truncate_history(max_messages) method removes the oldest messages, always keeping the most recent ones.
SessionManager is thread-safe. All operations use internal locking, so it is safe to use with concurrent message processing.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Definable AI","colors":{"primary":"#FA8112","light":"#FA8112","dark":"#FA8112"},"logo":{"light":"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/light.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=4b85977f6a03ffc7ceaa9b818e5d7990","dark":"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/dark.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=88f4a2faa73881a1af38ae9e48f83c11"},"favicon":"/favicon.svg","background":{"color":{"light":"#FAF3E1","dark":"#222222"}},"navbar":{"links":[{"href":"https://github.com/definable-ai/definable","label":"GitHub"}]},"footer":{"socials":{"github":"https://github.com/definable-ai"}},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/definable-ai/definable"},{"anchor":"PyPI","icon":"cube","href":"https://pypi.org/project/definable-ai/"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"definableaiprivatelimited","hasAudioNarration":false,"actualSubdomain":"definableaiprivatelimited","customDomains":["docs.definable.ai"],"gitSource":{"type":"github","owner":"definableai","repo":"definable.ai","deployBranch":"main","contentDirectory":"definable/docs","isPrivate":true,"mountPath":"","label":"","_id":"6b10d3309ffae5051c40c07e"},"entitlements":{},"buildId":"6ae94795d69537c8ab6fa802:success","clientVersion":"0.0.4453","searchFilterCounts":[{"language":"default","tag":"Documentation","count":127},{"language":"default","tag":"Basics","count":48},{"language":"default","tag":"Capabilities","count":41},{"language":"default","tag":"Examples","count":36},{"language":"default","tag":"Advanced","count":34},{"language":"default","tag":"Models","count":19},{"language":"default","tag":"Usage","count":17},{"language":"default","tag":"Interfaces","count":17},{"language":"default","tag":"Tools","count":15},{"language":"default","tag":"Agents","count":12}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"interfaces/sessions","slug":"/interfaces/sessions","pageMetadata":{"title":"Sessions","description":"Automatic per-user conversation management with history, state, and expiry.","icon":"clock-rotate-left","href":"/interfaces/sessions","hidden":false},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Automatic per-user conversation management with history, state, and expiry.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Mermaid,Note,Table}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Mermaid)_missingMdxReference(`Mermaid`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Every conversation between a user and your agent is tracked in a `,_jsx(_components.strong,{children:`session`}),`. Sessions store the message history, custom state, and metadata needed to maintain context across multiple interactions.`]}),`\n`,_jsx(Heading,{level:`2`,id:`how-sessions-work`,children:`How Sessions Work`}),`\n`,_jsx(_components.p,{children:`When a message arrives, the interface looks up (or creates) a session keyed by three values:`}),`\n`,_jsx(Mermaid,{chart:`flowchart LR\n Platform[\"platform\"] --> SessionKey[\"Session Key\"]\n UserID[\"user_id\"] --> SessionKey\n ChatID[\"chat_id\"] --> SessionKey\n SessionKey --> Session[\"InterfaceSession\"]`}),`\n`,_jsx(_components.p,{children:`This means:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Each user gets a separate session per chat`}),`\n`,_jsx(_components.li,{children:`Group chats have one session per user within the group`}),`\n`,_jsx(_components.li,{children:`Sessions persist across messages until they expire`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`interfacesession`,children:`InterfaceSession`}),`\n`,_jsx(_components.p,{children:`Each session contains:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Field`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`session_id`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`str`})}),_jsx(_components.td,{children:`Unique identifier (auto-generated UUID)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`platform`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`str`})}),_jsxs(_components.td,{children:[`Platform name (e.g., `,_jsx(_components.code,{children:`\"telegram\"`}),`)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`platform_user_id`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`str`})}),_jsx(_components.td,{children:`User’s ID on the platform`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`platform_chat_id`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`str`})}),_jsx(_components.td,{children:`Chat/conversation ID`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`messages`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`List[Message]`})}),_jsx(_components.td,{children:`Agent conversation history`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`session_state`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`dict`})}),_jsx(_components.td,{children:`Arbitrary key-value state (mutable)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`last_run_output`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`RunOutput`})}),_jsx(_components.td,{children:`Most recent agent output`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`created_at`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`float`})}),_jsx(_components.td,{children:`Creation timestamp`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`last_activity_at`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`float`})}),_jsx(_components.td,{children:`Last message timestamp`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`conversation-history`,children:`Conversation History`}),`\n`,_jsxs(_components.p,{children:[`The session’s `,_jsx(_components.code,{children:`messages`}),` list is passed to the agent on every call, giving it full context of the conversation:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`6`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`User: \"What is Python?\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Agent: \"Python is a programming language...\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`User: \"Who created it?\" ← agent sees both previous messages`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Agent: \"Python was created by Guido van Rossum...\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`History is automatically truncated to `,_jsx(_components.code,{children:`max_session_history`}),` (default: 50 messages) to stay within token limits. The most recent messages are always kept.`]}),`\n`,_jsx(Heading,{level:`2`,id:`session-state`,children:`Session State`}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`session_state`}),` to store custom per-user data that persists across messages:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.tool.decorator `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` tool`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@tool`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` set_language`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`language`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`_session_state`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"\"Set the user's preferred language.\"\"\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` _session_state[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"language\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` language`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Language set to `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`language`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`.\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@tool`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` get_preferences`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`_session_state`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"\"Get the user's preferences.\"\"\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` lang `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` _session_state.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"language\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"not set\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Language: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`lang`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`State set in one message is available in all subsequent messages within the same session.`}),`\n`,_jsx(Heading,{level:`2`,id:`sessionmanager`,children:`SessionManager`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`SessionManager`}),` handles creation, lookup, and expiry of sessions. A default instance is created automatically, or you can provide your own.`]}),`\n`,_jsx(Heading,{level:`3`,id:`automatic-behavior`,children:`Automatic Behavior`}),`\n`,_jsx(_components.p,{children:`By default, sessions are:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Created`}),` on the first message from a user/chat combination`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Reused`}),` on subsequent messages from the same user/chat`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Expired`}),` after `,_jsx(_components.code,{children:`session_ttl_seconds`}),` of inactivity (default: 1 hour)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Cleaned up`}),` automatically when expired sessions are encountered`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`custom-sessionmanager`,children:`Custom SessionManager`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.agent.interface `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SessionManager, TelegramInterface`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Sessions expire after 2 hours`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`session_manager `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SessionManager(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`session_ttl_seconds`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`7200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`interface `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` TelegramInterface(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` agent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` bot_token`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` session_manager`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`session_manager,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`sessionmanager-api`,children:`SessionManager API`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Method`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`get_or_create(platform, user_id, chat_id)`})}),_jsx(_components.td,{children:`Get existing session or create a new one`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`get(platform, user_id, chat_id)`})}),_jsxs(_components.td,{children:[`Get session or `,_jsx(_components.code,{children:`None`}),` if not found/expired`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`remove(platform, user_id, chat_id)`})}),_jsx(_components.td,{children:`Remove a session manually`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`cleanup_expired()`})}),_jsx(_components.td,{children:`Remove all expired sessions, returns count`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`active_session_count`})}),_jsx(_components.td,{children:`Number of active (non-expired) sessions`})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`manual-session-access`,children:`Manual Session Access`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`session_manager `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SessionManager(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`session_ttl_seconds`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3600`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Get or create`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`session `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` session_manager.get_or_create(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"telegram\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user-123\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chat-456\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Check state`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(session.session_state)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`len`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(session.messages))`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Cleanup`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`removed `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` session_manager.cleanup_expired()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Cleaned up `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`removed`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` expired sessions\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Active sessions: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`session_manager.active_session_count`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`session-ttl`,children:`Session TTL`}),`\n`,_jsxs(_components.p,{children:[`Sessions expire based on `,_jsx(_components.code,{children:`last_activity_at`}),`. Every incoming message updates this timestamp via `,_jsx(_components.code,{children:`session.touch()`}),`. Once the time since last activity exceeds `,_jsx(_components.code,{children:`session_ttl_seconds`}),`, the session is considered expired and will be removed on the next access or cleanup.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Short sessions for quick interactions`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`interface `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` TelegramInterface(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`agent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`bot_token`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`session_ttl_seconds`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`300`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# 5 minutes`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Long sessions for complex workflows`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`interface `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` TelegramInterface(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`agent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`bot_token`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`session_ttl_seconds`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`86400`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# 24 hours`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`When a session expires, the next message from that user starts a fresh conversation with no history.`}),`\n`,_jsx(Heading,{level:`2`,id:`history-truncation`,children:`History Truncation`}),`\n`,_jsx(_components.p,{children:`Long conversations are automatically truncated to prevent token limit issues:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`interface `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` TelegramInterface(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` agent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` bot_token`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` max_session_history`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`20`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Keep only the 20 most recent messages`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The session’s `,_jsx(_components.code,{children:`truncate_history(max_messages)`}),` method removes the oldest messages, always keeping the most recent ones.`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`SessionManager`}),` is thread-safe. All operations use internal locking, so it is safe to use with concurrent message processing.`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Sessions","description":"Automatic per-user conversation management with history, state, and expiry.","icon":"clock-rotate-left","href":"/interfaces/sessions","hidden":false}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"How Sessions Work","slug":"how-sessions-work","depth":2,"children":[]},{"title":"InterfaceSession","slug":"interfacesession","depth":2,"children":[]},{"title":"Conversation History","slug":"conversation-history","depth":2,"children":[]},{"title":"Session State","slug":"session-state","depth":2,"children":[]},{"title":"SessionManager","slug":"sessionmanager","depth":2,"children":[{"title":"Automatic Behavior","slug":"automatic-behavior","depth":3,"children":[]},{"title":"Custom SessionManager","slug":"custom-sessionmanager","depth":3,"children":[]},{"title":"SessionManager API","slug":"sessionmanager-api","depth":3,"children":[]},{"title":"Manual Session Access","slug":"manual-session-access","depth":3,"children":[]}]},{"title":"Session TTL","slug":"session-ttl","depth":2,"children":[]},{"title":"History Truncation","slug":"history-truncation","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"definableaiprivatelimited","siteName":"Definable AI","title":"Sessions - Definable AI","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-02-23T15:27:18.819Z","originalFileLocation":"interfaces/sessions.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Automatic per-user conversation management with history, state, and expiry.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Definable AI\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Sessions - Definable AI\">\u003cmeta data-mint-head property=\"og:description\" content=\"Automatic per-user conversation management with history, state, and expiry.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Definable AI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.definable.ai/interfaces/sessions\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://definableaiprivatelimited.mintlify.site/_mintlify/api/og/v2?division=Interfaces\u0026amp;title=Sessions\u0026amp;description=Automatic+per-user+conversation+management+with+history%2C+state%2C+and+expiry.\u0026amp;theme=292dbdbb8f2a2bd1ee1ab5df\u0026amp;signature=d141df75a73126fb9346ce86cdb7a40fb136ce5b63beb55e819173c09c4f908e\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Sessions - Definable AI\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Automatic per-user conversation management with history, state, and expiry.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://definableaiprivatelimited.mintlify.site/_mintlify/api/og/v2?division=Interfaces\u0026amp;title=Sessions\u0026amp;description=Automatic+per-user+conversation+management+with+history%2C+state%2C+and+expiry.\u0026amp;theme=292dbdbb8f2a2bd1ee1ab5df\u0026amp;signature=d141df75a73126fb9346ce86cdb7a40fb136ce5b63beb55e819173c09c4f908e\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Definable AI\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#FA8112\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.definable.ai/interfaces/sessions\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/interfaces/sessions.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.definable.ai/#organization\",\"name\":\"Definable AI\",\"url\":\"https://docs.definable.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/light.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=4b85977f6a03ffc7ceaa9b818e5d7990\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.definable.ai#website\",\"name\":\"Definable AI\",\"url\":\"https://docs.definable.ai\",\"publisher\":{\"@id\":\"https://docs.definable.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.definable.ai/interfaces/sessions#webpage\",\"url\":\"https://docs.definable.ai/interfaces/sessions\",\"name\":\"Sessions\",\"description\":\"Automatic per-user conversation management with history, state, and expiry.\",\"dateModified\":\"2026-02-23T15:27:18.819Z\",\"isPartOf\":{\"@id\":\"https://docs.definable.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.definable.ai/interfaces/sessions#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.definable.ai/interfaces/sessions#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Advanced\",\"item\":\"https://docs.definable.ai/interfaces/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Interfaces\",\"item\":\"https://docs.definable.ai/interfaces/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Sessions\",\"item\":\"https://docs.definable.ai/interfaces/sessions\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.definable.ai/interfaces/sessions#article\",\"headline\":\"Sessions\",\"name\":\"Sessions\",\"description\":\"Automatic per-user conversation management with history, state, and expiry.\",\"url\":\"https://docs.definable.ai/interfaces/sessions\",\"mainEntityOfPage\":{\"@id\":\"https://docs.definable.ai/interfaces/sessions#webpage\"},\"dateModified\":\"2026-02-23T15:27:18.819Z\",\"publisher\":{\"@id\":\"https://docs.definable.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.definable.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Definable AI\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Definable AI\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/interfaces/sessions.md","siteName":"Definable AI","nav":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/definable-ai/definable"},{"anchor":"PyPI","icon":"cube","href":"https://pypi.org/project/definable-ai/"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"Definable","sidebarTitle":"Introduction","mode":"wide","href":"/introduction","hidden":false},{"title":"Your First Agent","mode":"wide","href":"/first-agent","hidden":false},{"title":"Quickstart","icon":"bolt","href":"/quickstart","hidden":false},{"title":"Installation","href":"/installation","hidden":false}]},{"group":"Basics","pages":[{"group":"Agents","pages":[{"title":"What are Agents?","sidebarTitle":"Overview","mode":"wide","href":"/agents/overview","hidden":false},{"title":"Building Agents","sidebarTitle":"Building Agents","mode":"wide","href":"/agents/building-agents","hidden":false},{"title":"Running Agents","sidebarTitle":"Running Agents","icon":"play","href":"/agents/running-agents","hidden":false},{"title":"Agent Configuration","sidebarTitle":"Configuration","icon":"gear","href":"/agents/configuration","hidden":false},{"group":"Usage","pages":[{"title":"Agent with Tools","href":"/agents/usage/agent-with-tools","hidden":false},{"title":"Agent with Knowledge","href":"/agents/usage/agent-with-knowledge","hidden":false},{"title":"Agent with Memory","href":"/agents/usage/agent-with-memory","hidden":false},{"title":"Agent with Structured Output","href":"/agents/usage/agent-with-structured-output","hidden":false},{"title":"Agent with Streaming","href":"/agents/usage/agent-with-streaming","hidden":false}]}]},{"group":"Teams","pages":[{"title":"What are Teams?","sidebarTitle":"Overview","mode":"wide","href":"/teams/overview","hidden":false},{"title":"Building Teams","sidebarTitle":"Building Teams","mode":"wide","href":"/teams/building-teams","hidden":false},{"title":"Running Teams","sidebarTitle":"Running Teams","href":"/teams/running-teams","hidden":false},{"title":"Delegation","sidebarTitle":"Delegation","href":"/teams/delegation","hidden":false},{"group":"Usage","pages":[{"title":"Coordinate Team","href":"/teams/usage/coordinate-team","hidden":false},{"title":"Route Team","href":"/teams/usage/route-team","hidden":false},{"title":"Collaborate Team","href":"/teams/usage/collaborate-team","hidden":false},{"title":"Tasks Team","href":"/teams/usage/tasks-team","hidden":false}]}]},{"group":"Workflows","pages":[{"title":"What are Workflows?","sidebarTitle":"Overview","mode":"wide","href":"/workflows/overview","hidden":false},{"title":"Building Workflows","sidebarTitle":"Building Workflows","mode":"wide","href":"/workflows/building-workflows","hidden":false},{"title":"Running Workflows","sidebarTitle":"Running Workflows","href":"/workflows/running-workflows","hidden":false},{"group":"Patterns","pages":[{"title":"Sequential Workflow","sidebarTitle":"Sequential","href":"/workflows/patterns/sequential","hidden":false},{"title":"Parallel Workflow","sidebarTitle":"Parallel","href":"/workflows/patterns/parallel","hidden":false},{"title":"Conditional Workflow","sidebarTitle":"Conditional","href":"/workflows/patterns/conditional","hidden":false},{"title":"Loop Workflow","sidebarTitle":"Loop","href":"/workflows/patterns/loop","hidden":false},{"title":"Router Workflow","sidebarTitle":"Router","href":"/workflows/patterns/router","hidden":false}]},{"group":"Usage","pages":[{"title":"Basic Workflow","href":"/workflows/usage/basic-workflow","hidden":false},{"title":"Nested Workflows","href":"/workflows/usage/nested-workflows","hidden":false}]}]},{"group":"Input \u0026 Output","pages":[{"title":"Structured Output","sidebarTitle":"Structured Output","href":"/input-output/structured-output","hidden":false},{"title":"Streaming","sidebarTitle":"Streaming","href":"/input-output/streaming","hidden":false},{"title":"Multimodal Input","sidebarTitle":"Multimodal","href":"/input-output/multimodal","hidden":false}]},{"group":"Models","pages":[{"title":"What are Models?","sidebarTitle":"Overview","icon":"microchip","mode":"wide","href":"/models/overview","hidden":false},{"title":"Model as String","sidebarTitle":"String Shorthand","href":"/models/model-as-string","hidden":false},{"group":"Providers","pages":[{"title":"OpenAI","icon":"brain","href":"/models/openai","hidden":false},{"title":"Anthropic","href":"/models/anthropic","hidden":false},{"title":"Google Gemini","href":"/models/google","hidden":false},{"title":"DeepSeek","icon":"bolt","href":"/models/deepseek","hidden":false},{"title":"Mistral","href":"/models/mistral","hidden":false},{"title":"Moonshot","icon":"moon","href":"/models/moonshot","hidden":false},{"title":"xAI","icon":"magnifying-glass","href":"/models/xai","hidden":false},{"title":"Perplexity","href":"/models/perplexity","hidden":false},{"title":"Ollama","href":"/models/ollama","hidden":false},{"title":"OpenRouter","href":"/models/openrouter","hidden":false},{"title":"OpenAI-Like Providers","sidebarTitle":"OpenAI-Like","icon":"plug","href":"/models/openai-like","hidden":false}]},{"title":"Model Resilience","sidebarTitle":"Resilience","href":"/models/resilience","hidden":false},{"title":"Streaming","icon":"bars-staggered","href":"/models/streaming","hidden":false},{"title":"Structured Output","icon":"code","href":"/models/structured-output","hidden":false},{"title":"Vision \u0026 Audio","icon":"image","href":"/models/vision-and-audio","hidden":false},{"title":"Metrics \u0026 Pricing","icon":"chart-line","href":"/models/metrics-and-pricing","hidden":false}]}]},{"group":"Capabilities","pages":[{"group":"Tools","pages":[{"title":"What are Tools?","sidebarTitle":"Overview","mode":"wide","href":"/tools/overview","hidden":false},{"title":"Creating Tools","sidebarTitle":"Overview","href":"/tools/creating-tools/overview","hidden":false},{"title":"Tool Parameters","sidebarTitle":"Parameters","icon":"list","href":"/tools/creating-tools/parameters","hidden":false},{"title":"Tool Hooks","sidebarTitle":"Hooks","icon":"anchor","href":"/tools/creating-tools/hooks","hidden":false},{"title":"Tool Caching","sidebarTitle":"Caching","icon":"database","href":"/tools/creating-tools/caching","hidden":false},{"title":"Async Tools","sidebarTitle":"Async Tools","icon":"rotate","href":"/tools/creating-tools/async-tools","hidden":false},{"title":"Tool Dependencies","sidebarTitle":"Dependencies","icon":"puzzle-piece","href":"/tools/creating-tools/dependencies","hidden":false},{"group":"Toolkits","pages":[{"title":"Toolkits Overview","sidebarTitle":"Overview","icon":"toolbox","href":"/toolkits/overview","hidden":false},{"title":"KnowledgeToolkit","icon":"book","href":"/toolkits/knowledge-toolkit","hidden":false},{"title":"MCPToolkit","icon":"plug","href":"/toolkits/mcp-toolkit","hidden":false}]},{"group":"Built-in Skills","pages":[{"title":"Skills Overview","sidebarTitle":"Overview","icon":"puzzle-piece","href":"/skills/overview","hidden":false},{"title":"Built-in Skills","sidebarTitle":"Built-in Skills","icon":"toolbox","href":"/skills/built-in","hidden":false},{"title":"MacOS Skill","sidebarTitle":"MacOS","icon":"apple","href":"/skills/macos","hidden":false},{"title":"Skill Registry","sidebarTitle":"Skill Registry","icon":"book","href":"/skills/registry","hidden":false}]}]},{"group":"Knowledge \u0026 RAG","pages":[{"title":"Knowledge Overview","sidebarTitle":"Overview","icon":"book","href":"/knowledge/overview","hidden":false},{"title":"Documents","icon":"file-lines","href":"/knowledge/documents","hidden":false},{"title":"Agent Integration","sidebarTitle":"Agent Integration","icon":"robot","href":"/knowledge/agent-integration","hidden":false},{"title":"Hybrid Search \u0026 Scoring","sidebarTitle":"Hybrid Search","icon":"magnifying-glass-chart","href":"/knowledge/hybrid-search","hidden":false},{"group":"Pipeline","pages":[{"title":"Readers","icon":"file-import","href":"/knowledge/pipeline/readers","hidden":false},{"title":"Chunkers","icon":"scissors","href":"/knowledge/pipeline/chunkers","hidden":false},{"title":"Embedders","icon":"vector-square","href":"/knowledge/pipeline/embedders","hidden":false},{"title":"Rerankers","icon":"ranking-star","href":"/knowledge/pipeline/rerankers","hidden":false},{"title":"Vector Databases","sidebarTitle":"Vector Databases","icon":"database","href":"/knowledge/pipeline/vector-databases","hidden":false}]},{"group":"Usage","pages":[{"title":"Basic RAG","href":"/knowledge/usage/basic-rag","hidden":false},{"title":"Hybrid Search","href":"/knowledge/usage/hybrid-search-example","hidden":false}]}]},{"group":"Memory","pages":[{"title":"Memory Overview","sidebarTitle":"Overview","icon":"brain","href":"/memory/overview","hidden":false},{"title":"Memory Stores","sidebarTitle":"Stores","icon":"database","href":"/memory/stores","hidden":false},{"title":"Agent Integration","sidebarTitle":"Agent Integration","icon":"link","href":"/memory/agent-integration","hidden":false}]},{"group":"Reasoning","pages":[{"title":"Thinking","sidebarTitle":"Thinking","href":"/reasoning/thinking","hidden":false},{"title":"Deep Research","sidebarTitle":"Deep Research","href":"/reasoning/deep-research","hidden":false}]},{"group":"MCP","pages":[{"title":"MCP Overview","sidebarTitle":"Overview","icon":"plug","href":"/mcp/overview","hidden":false},{"title":"Getting Started with MCP","sidebarTitle":"Getting Started","icon":"rocket","href":"/mcp/getting-started","hidden":false},{"title":"MCP Configuration","sidebarTitle":"Configuration","icon":"gear","href":"/mcp/configuration","hidden":false},{"title":"MCP Resources","sidebarTitle":"Resources","icon":"folder-open","href":"/mcp/resources","hidden":false},{"title":"MCP Prompts","sidebarTitle":"Prompts","icon":"message","href":"/mcp/prompts","hidden":false},{"title":"MCP Error Handling","sidebarTitle":"Error Handling","icon":"triangle-exclamation","href":"/mcp/error-handling","hidden":false},{"title":"Mock MCP Servers","sidebarTitle":"Mock Servers","icon":"flask-vial","href":"/mcp/mock-servers","hidden":false}]},{"group":"Readers","pages":[{"title":"File Readers","sidebarTitle":"Overview","icon":"file-lines","href":"/readers/overview","hidden":false}]},{"group":"Browser","pages":[{"title":"Browser Toolkit","sidebarTitle":"Overview","icon":"globe","href":"/browser/overview","hidden":false}]},{"group":"Tracing","pages":[{"title":"Tracing","icon":"chart-gantt","href":"/agents/tracing","hidden":false}]},{"group":"Evaluation","pages":[{"title":"Evaluation","sidebarTitle":"Evaluation","icon":"chart-bar","href":"/agents/evaluation","hidden":false}]}]},{"group":"Advanced","pages":[{"group":"Interfaces","pages":[{"title":"Interfaces Overview","sidebarTitle":"Overview","icon":"message-bot","href":"/interfaces/overview","hidden":false},{"group":"Platforms","pages":[{"title":"Telegram","icon":"paper-plane","href":"/interfaces/telegram","hidden":false},{"title":"Discord","icon":"discord","href":"/interfaces/discord","hidden":false},{"title":"Slack","icon":"slack","href":"/interfaces/slack","hidden":false},{"title":"WebSocket","sidebarTitle":"WebSocket","href":"/interfaces/websocket","hidden":false},{"title":"WhatsApp","sidebarTitle":"WhatsApp","icon":"comment-dots","href":"/interfaces/whatsapp"},{"title":"Email","sidebarTitle":"Email","href":"/interfaces/email","hidden":false},{"title":"Call (Voice)","icon":"phone","href":"/interfaces/call","hidden":false},{"title":"Custom Interfaces","sidebarTitle":"Custom Interfaces","icon":"code","href":"/interfaces/custom-interfaces","hidden":false}]},{"group":"Usage","pages":[{"title":"Telegram Bot","href":"/interfaces/usage/telegram-bot","hidden":false},{"title":"Discord Bot","href":"/interfaces/usage/discord-bot","hidden":false},{"title":"Slack Bot","href":"/interfaces/usage/slack-bot","hidden":false},{"title":"Multi-Platform Agent","description":"Serve one agent across Telegram, Discord, and Slack simultaneously.","href":"/interfaces/usage/multi-platform","hidden":false}]},{"title":"Sessions","icon":"clock-rotate-left","href":"/interfaces/sessions","hidden":false},{"title":"Interface Hooks","sidebarTitle":"Hooks","description":"Intercept, filter, and modify messages and responses at every stage of the pipeline.","icon":"anchor","href":"/interfaces/hooks","hidden":false},{"title":"Identity Resolution","sidebarTitle":"Identity","icon":"fingerprint","href":"/interfaces/identity","hidden":false},{"title":"Multi-Interface Serving","sidebarTitle":"Multi-Interface","icon":"server","href":"/interfaces/multi-interface","hidden":false}]},{"group":"Security","pages":[{"title":"Security","sidebarTitle":"Security","icon":"shield-halved","href":"/agents/security","hidden":false}]},{"group":"Guardrails","pages":[{"title":"Guardrails Overview","sidebarTitle":"Overview","icon":"shield","href":"/guardrails/overview","hidden":false}]},{"group":"Plugins","pages":[{"title":"Plugins","sidebarTitle":"Plugins","href":"/agents/plugins","hidden":false}]},{"group":"Scheduling","pages":[{"title":"Scheduling","sidebarTitle":"Scheduling","href":"/agents/scheduling","hidden":false}]},{"title":"Middleware","icon":"layer-group","href":"/agents/middleware","hidden":false},{"title":"Multi-Turn Conversations","sidebarTitle":"Multi-Turn","icon":"comments","href":"/agents/multi-turn","hidden":false},{"title":"Agentic Loop","sidebarTitle":"Agentic Loop","icon":"rotate","href":"/agents/agentic-loop","hidden":false},{"title":"Testing","icon":"flask-vial","href":"/agents/testing","hidden":false},{"title":"Authentication","sidebarTitle":"Authentication","icon":"lock","href":"/agents/auth","hidden":false},{"title":"Agent Runtime","sidebarTitle":"Runtime","icon":"server","href":"/agents/runtime","hidden":false},{"title":"Error Handling","icon":"shield","href":"/advanced/error-handling","hidden":false},{"title":"Cost Tracking","icon":"dollar-sign","href":"/advanced/cost-tracking","hidden":false},{"title":"Run Output \u0026 Events","sidebarTitle":"Run Output","icon":"square-poll-vertical","href":"/advanced/run-output","hidden":false},{"title":"Media Types","icon":"photo-film","href":"/advanced/media-types","hidden":false},{"title":"Replay Overview","sidebarTitle":"Overview","icon":"rotate","href":"/replay/overview","hidden":false},{"title":"Observability Dashboard","sidebarTitle":"Overview","icon":"chart-line","href":"/observability/overview","hidden":false},{"title":"Claude Code Agent","href":"/claude-code/overview","hidden":false}]}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/examples/overview"}]},{"tab":"Reference","pages":[{"title":"Reference","href":"/reference/agents/agent"}]}]},"basePath":"","title":"Sessions - Definable AI","deploymentId":"dpl_BLZw3QngerHodH9E8mGgC4v752y3","buildId":"dpl_BLZw3QngerHodH9E8mGgC4v752y3","dynamics":[],"chunks":[]}