Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.
Restate Virtual Objects give your agents persistent, isolated sessions. Each session is identified by a unique key (like a user ID or conversation ID), maintains its own state, and has built-in concurrency control, so concurrent requests to the same session are automatically queued.
How it works
A Virtual Object is a Restate service type where each instance is identified by a key. State stored in a Virtual Object:
Survives crashes and restarts: No external database needed
Is isolated per key: Each session has its own state
Has concurrency control: Only one write handler runs at a time per key, preventing race conditions
Example: a chat session
Vercel AI
OpenAI Agents
Google ADK
Pydantic AI
LangChain
Restate TS
Restate Py
To turn your agent into a stateful session, you need two changes compared to a regular durable agent:
Define a Virtual Object: use restate.object() instead of restate.service(). This gives each session key its own isolated state.
Manage conversation history using the object’s K/V store: use ctx.get() and ctx.set() to read and write the message history.
chat-agent.ts
const chatAgent = restate.object({ name: "Chat", handlers: { message: restate.createObjectHandler( { input: schema(ChatMessageSchema) }, async (ctx: restate.ObjectContext, { message }: { message: string }) => { const model = wrapLanguageModel({ model: openai("gpt-5.4"), middleware: durableCalls(ctx, { maxRetryAttempts: 3 }), }); // Retrieve the state const messages = (await ctx.get<ModelMessage[]>("messages", superJson)) ?? []; messages.push({ role: "user", content: message }); const res = await generateText({ model, system: "You are a helpful assistant.", messages, }); // Update the state ctx.set("messages", [...messages, ...res.response.messages], superJson); return { answer: res.text }; }, ), // Shared handler to retrieve the history getHistory: shared(async (ctx: restate.ObjectSharedContext) => ctx.get<ModelMessage[]>("messages", superJson), ), },});
Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for session123:
curl localhost:8080/restate/call/Chat/session123/message \--json '{"message": "make a poem about durable execution"}'
Continue the conversation with the same session ID. The agent remembers previous context:
curl localhost:8080/restate/call/Chat/session123/message \--json '{"message": "shorten it to 2 lines"}'
Send a message to a different session. It starts a completely separate conversation:
curl localhost:8080/restate/call/Chat/session456/message \--json '{"message": "what are the benefits of durable execution?"}'
To turn your agent into a stateful session, you need two changes compared to a regular durable agent:
Define a Virtual Object: use restate.VirtualObject() instead of restate.Service(). This gives each session key its own isolated state.
Enable use_restate_session on DurableRunner.run(): set use_restate_session=True so the conversation history is automatically persisted in Restate’s K/V store.
chat_agent.py
chat = VirtualObject("Chat")@chat.handler()async def message(_ctx: ObjectContext, req: ChatMessage) -> dict: # Set use_restate_session=True to store the session in Restate's key-value store # Make sure you use a VirtualObject to enable this feature result = await DurableRunner.run( Agent(name="Assistant", instructions="You are a helpful assistant."), req.message, use_restate_session=True, ) return result.final_output@chat.handler(kind="shared")async def get_history(ctx: restate.ObjectSharedContext): return await ctx.get("messages", type_hint=list[dict]) or []
Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for session123:
curl localhost:8080/restate/call/Chat/session123/message \--json '{"message": "Make a poem about durable execution."}'
Continue the conversation with the same session ID. The agent remembers previous context:
curl localhost:8080/restate/call/Chat/session123/message \--json '{"message": "Shorten it to 2 lines."}'
Go to the state tab of the UI to view the conversation history.Send a message to a different session. It starts a completely separate conversation:
curl localhost:8080/restate/call/Chat/session456/message \--json '{"message": "What are the benefits of durable execution?"}'
To turn your agent into a stateful session, you need two changes compared to a regular durable agent:
Define a Virtual Object: use restate.VirtualObject() instead of restate.Service(). This gives each session key its own isolated state.
Use RestateSessionService as the session service for the Runner: this stores the ADK session data (conversation history, agent state) in Restate’s K/V store. The object key (via ctx.key()) is used as the user identifier.
Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for session123:
curl localhost:8080/restate/call/Chat/user123/message \--json '{"message": "Make a poem about durable execution.", "session_id": "session-123"}'
Continue the conversation with the same user and session ID. The agent remembers previous context:
curl localhost:8080/restate/call/Chat/user123/message \--json '{"message": "Shorten it to 2 lines.", "session_id": "session-123"}'
Go to the state tab of the UI to view the conversation history.Send a message to a different user. It starts a completely separate conversation:
curl localhost:8080/restate/call/Chat/user456/message \--json '{"message": "What are the benefits of durable execution?", "session_id": "session-567"}'
To turn your agent into a stateful session, you need two changes compared to a regular durable agent:
Define a Virtual Object: use restate.VirtualObject() instead of restate.Service(). This gives each session key its own isolated state.
Manage conversation history using the object’s K/V store: use ctx.get() and ctx.set() to read and write the message history.
chat_agent.py
agent = Agent( "openai:gpt-5.4", system_prompt="You are a helpful assistant.",)restate_agent = RestateAgent(agent)chat = VirtualObject("Chat")@chat.handler()async def message(ctx: ObjectContext, req: ChatMessage) -> str: # Load message history from Restate's durable key-value store history = await ctx.get("messages", serde=MessageSerde()) result = await restate_agent.run(req.message, message_history=history) # Store updated history back in Restate state ctx.set("messages", result.all_messages(), serde=MessageSerde()) return result.output@chat.handler(kind="shared")async def get_history(ctx: restate.ObjectSharedContext) -> dict: return await ctx.get("messages", type_hint=dict) or {}
Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for session123:
curl localhost:8080/restate/call/Chat/session123/message \--json '{"message": "make a poem about durable execution"}'
Continue the conversation with the same session ID. The agent remembers previous context:
curl localhost:8080/restate/call/Chat/session123/message \--json '{"message": "shorten it to 2 lines"}'
Send a message to a different session. It starts a completely separate conversation:
curl localhost:8080/restate/call/Chat/session456/message \--json '{"message": "what are the benefits of durable execution?"}'
The state tab of the Restate UI lets you query the state of each session:
Vercel AI
OpenAI Agents
Google ADK
Pydantic AI
LangChain
Restate TS
Restate Py
This pattern is complementary to AI memory solutions like mem0 or graffiti. You can use Virtual Objects to enforce session concurrency and queueing while storing the agent’s memory in specialized memory systems.
This pattern is implementable with any of our SDKs and any AI SDK.
If you need help with a specific SDK, please reach out to us via Discord or Slack.
Built-in concurrency control
Restate queues concurrent requests to the same session key. They are processed sequentially, preventing race conditions on shared state. This works similar to a task queue per session, but without needing to set up any external queue infrastructure.Different session keys run in parallel with no interference.
Vercel AI
OpenAI Agents
Google ADK
Pydantic AI
LangChain
Restate TS
Restate Py
Try out queuing
Send several messages concurrently to different chat sessions:
curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "make a poem about durable execution"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what are the benefits of durable execution?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "how does workflow orchestration work?"}' &curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "can you make it rhyme better?"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what about fault tolerance in distributed systems?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "give me a practical example"}' &curl localhost:8080/restate/send/Chat/session101/message --json '{"message": "explain event sourcing in simple terms"}' &curl localhost:8080/restate/send/Chat/session202/message --json '{"message": "what is the difference between async and sync processing?"}'
The UI shows how Restate queues the requests per session to ensure consistency:
Try out queuing
Send several messages concurrently to different chat sessions:
curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "make a poem about durable execution"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what are the benefits of durable execution?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "how does workflow orchestration work?"}' &curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "can you make it rhyme better?"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what about fault tolerance in distributed systems?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "give me a practical example"}' &curl localhost:8080/restate/send/Chat/session101/message --json '{"message": "explain event sourcing in simple terms"}' &curl localhost:8080/restate/send/Chat/session202/message --json '{"message": "what is the difference between async and sync processing?"}'
The UI shows how Restate queues the requests per session to ensure consistency:
Try out queuing
Send several messages concurrently to different users:
curl localhost:8080/restate/send/Chat/user123/message --json '{"message": "make a poem about durable execution", "session_id": "session-123"}' &curl localhost:8080/restate/send/Chat/user456/message --json '{"message": "what are the benefits of durable execution?", "session_id": "session-567"}' &curl localhost:8080/restate/send/Chat/user789/message --json '{"message": "how does workflow orchestration work?", "session_id": "session-999"}' &curl localhost:8080/restate/send/Chat/user123/message --json '{"message": "can you make it rhyme better?", "session_id": "session-123"}' &curl localhost:8080/restate/send/Chat/user456/message --json '{"message": "what about fault tolerance in distributed systems?", "session_id": "session-567"}' &curl localhost:8080/restate/send/Chat/user789/message --json '{"message": "give me a practical example", "session_id": "session-999"}' &curl localhost:8080/restate/send/Chat/user101/message --json '{"message": "explain event sourcing in simple terms", "session_id": "session-123"}' &curl localhost:8080/restate/send/Chat/user202/message --json '{"message": "what is the difference between async and sync processing?", "session_id": "session-123"}'
The UI shows how Restate queues the requests per session to ensure consistency:
Try out queuing
Send several messages concurrently to different chat sessions:
curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "make a poem about durable execution"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what are the benefits of durable execution?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "how does workflow orchestration work?"}' &curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "can you make it rhyme better?"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what about fault tolerance in distributed systems?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "give me a practical example"}' &curl localhost:8080/restate/send/Chat/session101/message --json '{"message": "explain event sourcing in simple terms"}' &curl localhost:8080/restate/send/Chat/session202/message --json '{"message": "what is the difference between async and sync processing?"}'
The UI shows how Restate queues the requests per session to ensure consistency:
Try out queuing
Send several messages concurrently to different chat sessions:
curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "make a poem about durable execution"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what are the benefits of durable execution?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "how does workflow orchestration work?"}' &curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "can you make it rhyme better?"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what about fault tolerance in distributed systems?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "give me a practical example"}' &curl localhost:8080/restate/send/Chat/session101/message --json '{"message": "explain event sourcing in simple terms"}' &curl localhost:8080/restate/send/Chat/session202/message --json '{"message": "what is the difference between async and sync processing?"}'
The UI shows how Restate queues the requests per session to ensure consistency:
Try out queuing
Send several messages concurrently to different chat sessions:
curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "make a poem about durable execution"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what are the benefits of durable execution?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "how does workflow orchestration work?"}' &curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "can you make it rhyme better?"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what about fault tolerance in distributed systems?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "give me a practical example"}' &curl localhost:8080/restate/send/Chat/session101/message --json '{"message": "explain event sourcing in simple terms"}' &curl localhost:8080/restate/send/Chat/session202/message --json '{"message": "what is the difference between async and sync processing?"}'
The UI shows how Restate queues the requests per session to ensure consistency:
Try out queuing
Send several messages concurrently to different chat sessions:
curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "make a poem about durable execution"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what are the benefits of durable execution?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "how does workflow orchestration work?"}' &curl localhost:8080/restate/send/Chat/session123/message --json '{"message": "can you make it rhyme better?"}' &curl localhost:8080/restate/send/Chat/session456/message --json '{"message": "what about fault tolerance in distributed systems?"}' &curl localhost:8080/restate/send/Chat/session789/message --json '{"message": "give me a practical example"}' &curl localhost:8080/restate/send/Chat/session101/message --json '{"message": "explain event sourcing in simple terms"}' &curl localhost:8080/restate/send/Chat/session202/message --json '{"message": "what is the difference between async and sync processing?"}'
The UI shows how Restate queues the requests per session to ensure consistency:
Concurrently retrieving state
The state you store in Virtual Objects lives forever. To resume a session, simply send a new message to the same Virtual Object key.
Vercel AI
OpenAI Agents
Google ADK
Pydantic AI
LangChain
Restate TS
Restate Py
To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the getHistory handler in the example above.Call the handler to get the conversation history:
To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the get_history handler in the example above.Call the handler to get the conversation history:
To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the get_history handler in the example above.Call the handler to get the conversation history:
To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the get_history handler in the example above.Call the handler to get the conversation history:
To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the get_history handler in the example above.Call the handler to get the conversation history:
To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the getHistory handler in the example above.Call the handler to get the conversation history:
To retrieve state, view the UI’s state tab or add as handler that reads it. Have a look at the get_history handler in the example above.Call the handler to get the conversation history:
This is a shared handler, meaning it can only read state (not write). This allows it to run concurrently with the message handler.
Steerable, stateful agents
For a complete TypeScript application, see the Agent Reference Architecture. It separates the agent controller and turn execution into two Virtual Objects, so you can steer a running turn or respond to approvals while it works.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Restate","description":"Restate is the simplest way to build resilient applications.","colors":{"primary":"#4752c4","light":"#7a87e1","dark":"#4752c4"},"logo":{"light":"https://mintcdn.com/restate-6d46e1dc/0MkLgffDAGHkNDIZ/logo/light.svg?fit=max\u0026auto=format\u0026n=0MkLgffDAGHkNDIZ\u0026q=85\u0026s=70e648c2608af2d2c33dc26b3bce13d3","dark":"https://mintcdn.com/restate-6d46e1dc/0MkLgffDAGHkNDIZ/logo/dark.svg?fit=max\u0026auto=format\u0026n=0MkLgffDAGHkNDIZ\u0026q=85\u0026s=5be48044922541993e0e472f203bca46","href":"https://restate.dev"},"favicon":"https://mintcdn.com/restate-6d46e1dc/en_t8BH_S2cXTlbv/favicon.svg?fit=max\u0026auto=format\u0026n=en_t8BH_S2cXTlbv\u0026q=85\u0026s=d282cb3c3124106eca71fa9e9121043f","api":{"playground":{"display":"simple"}},"appearance":{"default":"light","strict":true},"background":{"decoration":"gradient"},"navbar":{"links":[{"icon":"discord","href":"https://discord.restate.dev","label":""},{"icon":"slack","href":"https://slack.restate.dev","label":""},{"icon":"github","href":"https://github.com/restatedev/restate","label":""}]},"footer":{"socials":{"website":"https://restate.dev","github":"https://github.com/restatedev/restate","discord":"https://discord.restate.dev","slack":"https://slack.restate.dev","youtube":"https://www.youtube.com/@restatedev","linkedin":"https://linkedin.com/company/restatedev","x":"https://x.com/restatedev","bluesky":"https://bsky.app/profile/restate.dev"}},"fonts":{"heading":{"family":"Rubik"},"body":{"family":"Manrope"}},"integrations":{"gtm":{"tagId":"GTM-TKTFM2CK"},"cookies":{"key":"restate_cookie_consent","value":"granted"}},"contextual":{"options":["chatgpt","claude","copy"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"restate-6d46e1dc","hasAudioNarration":false,"actualSubdomain":"restate-6d46e1dc","customDomains":["docs.restate.dev"],"gitSource":{"type":"github","owner":"restatedev","repo":"docs-restate","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af5a69c319ac6c743b602db","clientVersion":"0.0.4128","searchFilterCounts":[{"language":"default","tag":"Docs","count":151},{"language":"default","tag":"SDKs","count":55},{"language":"default","tag":"References","count":50},{"language":"default","tag":"APIs","count":39},{"language":"default","tag":"AI / Agents","count":34},{"language":"default","tag":"Admin API","count":34},{"language":"default","tag":"Restate Cloud / BYOC / OSS","count":22},{"language":"default","tag":"Services","count":22},{"language":"default","tag":"Self-hosted Restate","count":17},{"language":"default","tag":"Learn","count":16}]},"assistantConfig":{"enableAskAiButton":true,"enableAskAiSearchBar":false,"deflection":{"enabled":false,"email":"[email protected]"}},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","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":"workos-onboarding","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":"assistant-v5","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":"workos-sso-scim","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":"workos-signup","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":"workos-enabled","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":"sso-setup-deadline-banner","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":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"privacy":{"consentBanner":{"enabled":false}},"googleFontsInlined":true},"customCss":[{"filePath":"styles.css","content":"@font-face{font-family:'Rubik';src:url('https://fonts.gstatic.com/s/rubik/v28/iJWKBXyIfDnIV7nBrXw.woff2');font-weight:normal;font-style:normal;font-display:swap}h1,h2,h3{font-family:'Rubik';letter-spacing:normal!important}.hidden-tabs [data-component-part=\"tabs-list\"]{display:none!important}.hidden-tabs .tabs-list{display:none!important}[data-component-part=\"tabs-list\"]{flex-wrap:wrap!important;row-gap:0.25rem}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/cloud-providers/aws-lambda.svg\"]{content:url(\"/img/cloud-providers/aws-lambda-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/cloud-providers/cloudflare-workers.svg\"]{content:url(\"/img/cloud-providers/cloudflare-workers-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/cloud-providers/docker.svg\"]{content:url(\"/img/cloud-providers/docker-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/cloud-providers/google-cloud-run.svg\"]{content:url(\"/img/cloud-providers/google-cloud-run-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/cloud-providers/kubernetes.svg\"]{content:url(\"/img/cloud-providers/kubernetes-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/cloud-providers/other-serverless.svg\"]{content:url(\"/img/cloud-providers/other-serverless-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/cloud-providers/vercel.svg\"]{content:url(\"/img/cloud-providers/vercel-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/languages/go.svg\"]{content:url(\"/img/languages/go-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/languages/java.svg\"]{content:url(\"/img/languages/java-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/languages/kotlin.svg\"]{content:url(\"/img/languages/kotlin-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/languages/python.svg\"]{content:url(\"/img/languages/python-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/languages/ruby.svg\"]{content:url(\"/img/languages/ruby-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/languages/rust.svg\"]{content:url(\"/img/languages/rust-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/img/languages/typescript.svg\"]{content:url(\"/img/languages/typescript-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/logo/restate-cloud-mini.svg\"]{content:url(\"/logo/restate-cloud-mini-primary.svg\")}[data-component-part=\"tab-button\"][data-active=\"true\"] .tab-icon[src=\"/logo/restate-mini.svg\"]{content:url(\"/logo/restate-mini-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/cloud-providers/aws-lambda.svg\"]{content:url(\"/img/cloud-providers/aws-lambda-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/cloud-providers/cloudflare-workers.svg\"]{content:url(\"/img/cloud-providers/cloudflare-workers-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/cloud-providers/docker.svg\"]{content:url(\"/img/cloud-providers/docker-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/cloud-providers/google-cloud-run.svg\"]{content:url(\"/img/cloud-providers/google-cloud-run-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/cloud-providers/kubernetes.svg\"]{content:url(\"/img/cloud-providers/kubernetes-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/cloud-providers/other-serverless.svg\"]{content:url(\"/img/cloud-providers/other-serverless-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/cloud-providers/vercel.svg\"]{content:url(\"/img/cloud-providers/vercel-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/languages/go.svg\"]{content:url(\"/img/languages/go-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/languages/java.svg\"]{content:url(\"/img/languages/java-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/languages/kotlin.svg\"]{content:url(\"/img/languages/kotlin-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/languages/python.svg\"]{content:url(\"/img/languages/python-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/languages/ruby.svg\"]{content:url(\"/img/languages/ruby-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/languages/rust.svg\"]{content:url(\"/img/languages/rust-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/img/languages/typescript.svg\"]{content:url(\"/img/languages/typescript-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/logo/restate-cloud-mini.svg\"]{content:url(\"/logo/restate-cloud-mini-primary.svg\")}li[data-active-nav-item=\"true\"] img[src=\"/logo/restate-mini.svg\"]{content:url(\"/logo/restate-mini-primary.svg\")}#cc-main{--cc-btn-border-radius: 0.75rem;--cc-btn-primary-bg: #2563eb;--cc-btn-primary-color: #fff;--cc-btn-primary-border-color: transparent;--cc-btn-primary-hover-bg: #1d4ed8;--cc-btn-secondary-bg: #fff;--cc-btn-secondary-color: #14151a;--cc-btn-secondary-border-color: #dee0e3;--cc-btn-secondary-hover-bg: #f3f4f6}"}],"page":{"pagePath":"ai/patterns/sessions","slug":"/ai/patterns/sessions","pageMetadata":{"title":"Durable Sessions","sidebarTitle":"Durable Sessions","icon":"comments","description":"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.","href":"/ai/patterns/sessions"},"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: \"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.\"\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];const GitHubLink=({url})=>{const _components={a:`a`,..._provideComponents()};return _jsx(`div`,{style:{marginTop:`-8px`,marginBottom:`8px`,textAlign:`right`},children:_jsxs(_components.a,{href:url,target:`_blank`,rel:`noopener noreferrer`,style:{fontSize:`0.75rem`,color:`#6B7280`,textDecoration:`none`,display:`inline-flex`,alignItems:`center`,gap:`3px`,padding:`2px 6px`,borderRadius:`3px`,border:`1px solid #E5E7EB`,backgroundColor:`transparent`,transition:`all 0.2s ease`},onMouseOver:e=>{e.target.style.color=`#6B7280`;e.target.style.backgroundColor=`#F9FAFB`},onMouseOut:e=>{e.target.style.color=`#6B7280`;e.target.style.backgroundColor=`transparent`},children:[_jsx(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`currentColor`,children:_jsx(`path`,{d:`M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.230 3.297-1.230.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z`})}),`View on GitHub`]})})};function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Accordion,CodeBlock,Frame,Heading,OptimizedImage,Tab,Tabs,Tip,_MdxComponentBoundary}=_components;if(!Accordion)_missingMdxReference(`Accordion`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Tab)_missingMdxReference(`Tab`,true);if(!Tabs)_missingMdxReference(`Tabs`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!_MdxComponentBoundary)_missingMdxReference(`_MdxComponentBoundary`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Restate `,_jsx(_components.strong,{children:`Virtual Objects`}),` give your agents persistent, isolated sessions. Each session is identified by a unique key (like a user ID or conversation ID), maintains its own state, and has built-in concurrency control, so concurrent requests to the same session are automatically queued.`]}),`\n`,_jsx(Heading,{level:`2`,id:`how-it-works`,children:`How it works`}),`\n`,_jsx(_components.p,{children:`A Virtual Object is a Restate service type where each instance is identified by a key. State stored in a Virtual Object:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Survives crashes and restarts`}),`: No external database needed`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Is isolated per key`}),`: Each session has its own state`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Has concurrency control`}),`: Only one write handler runs at a time per key, preventing race conditions`]}),`\n`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_objects.png?fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=47543277d79b6ede64b32c21fef97a39`,alt:`Virtual Objects as sessions`,\"data-og-width\":`2242`,width:`2242`,\"data-og-height\":`731`,height:`731`,\"data-path\":`img/tour/agents/chat_objects.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_objects.png?w=280\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=b79470ba9c05a08afaea4461e9e95436 280w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_objects.png?w=560\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=bcd99eda91702fd3efbd13bbd6324973 560w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_objects.png?w=840\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=3d95f1082dae6788a083096471e339f7 840w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_objects.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=7015a6285ab5d77e5e194e169ca61a3b 1100w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_objects.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=65948203ed77ddb64617b7271266eb3f 1650w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_objects.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=d0dd87a50f4285cf8eecb9c6b7b34cdd 2500w`}),`\n`,_jsx(Heading,{level:`2`,id:`example-a-chat-session`,children:`Example: a chat session`}),`\n`,_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Vercel AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`vercel-ai`,children:[_jsxs(_components.p,{children:[`To turn your agent into a stateful session, you need two changes compared to a regular `,_jsx(_components.a,{href:`/ai/patterns/durable-agents`,children:`durable agent`}),`:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Define a Virtual Object`}),`: use `,_jsx(_components.code,{children:`restate.object()`}),` instead of `,_jsx(_components.code,{children:`restate.service()`}),`. This gives each session key its own isolated state.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Manage conversation history`}),` using the object’s K/V store: use `,_jsx(_components.code,{children:`ctx.get()`}),` and `,_jsx(_components.code,{children:`ctx.set()`}),` to read and write the message history.`]}),`\n`]}),_jsx(CodeBlock,{filename:`chat-agent.ts`,numberOfLines:`33`,language:`typescript`,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:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`33`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` chatAgent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`object`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` name:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` handlers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` message:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`createObjectHandler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`input:`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` schema`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ChatMessageSchema`}),_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\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`ObjectContext`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_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:` { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_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\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` wrapLanguageModel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` openai`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-5.4\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` middleware:`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` durableCalls`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxRetryAttempts:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_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:` // Retrieve the state`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`ModelMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[]>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`superJson`}),_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:` [];`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`push`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` message`}),_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:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` res`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` generateText`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` system:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"You are a helpful assistant.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_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:` // Update the state`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`set`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_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\":`#9CDCFE`},children:`messages`}),_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\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`], `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`superJson`}),_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:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`answer:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` };`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Shared handler to retrieve the history`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` getHistory:`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` shared`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`ObjectSharedContext`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`ModelMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[]>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`superJson`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),_jsx(_MdxComponentBoundary,{name:`GitHubLink`,children:_jsx(GitHubLink,{url:`https://github.com/restatedev/ai-examples/tree/main/vercel-ai/tour-of-agents/src/chat-agent.ts`})}),_jsxs(Accordion,{title:`Try out Virtual Objects`,icon:`laptop`,id:`try-out-virtual-objects`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/installation`,children:`Install Restate`}),` and launch it:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --global`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @restatedev/restate-server@latest`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @restatedev/restate@latest`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate-server`})}),`\n`]})})}),_jsx(_components.p,{children:`Get the example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` typescript-vercel-ai-tour-of-agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` typescript-vercel-ai-tour-of-agents`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Export your `,_jsx(_components.a,{href:`https://platform.openai.com/api-keys`,children:`OpenAI API key`}),` and run the agent:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sk-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`...`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npx`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` tsx`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ./src/chat-agent.ts`})]}),`\n`]})})}),_jsx(_components.p,{children:`Register the agents with Restate:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deployments`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` register`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:9080`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --force`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --yes`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # dev only: overrides previous registrations`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for `,_jsx(_components.code,{children:`session123`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"make a poem about durable execution\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Continue the conversation with the same session ID. The agent remembers previous context:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"shorten it to 2 lines\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Send a message to a different session. It starts a completely separate conversation:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"what are the benefits of durable execution?\"}'`})]}),`\n`]})})})]})]}),_jsxs(Tab,{title:`OpenAI Agents`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`openai-agents`,children:[_jsxs(_components.p,{children:[`To turn your agent into a stateful session, you need two changes compared to a regular `,_jsx(_components.a,{href:`/ai/patterns/durable-agents`,children:`durable agent`}),`:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Define a Virtual Object`}),`: use `,_jsx(_components.code,{children:`restate.VirtualObject()`}),` instead of `,_jsx(_components.code,{children:`restate.Service()`}),`. This gives each session key its own isolated state.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[`Enable `,_jsx(_components.code,{children:`use_restate_session`})]}),` on `,_jsx(_components.code,{children:`DurableRunner.run()`}),`: set `,_jsx(_components.code,{children:`use_restate_session=True`}),` so the conversation history is automatically persisted in Restate’s K/V store.`]}),`\n`]}),_jsx(CodeBlock,{filename:`chat_agent.py`,numberOfLines:`18`,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:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` VirtualObject(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`_ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ObjectContext, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ChatMessage) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Set use_restate_session=True to store the session in Restate's key-value store`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Make sure you use a VirtualObject to enable this feature`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` DurableRunner.run(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`instructions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a helpful assistant.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` req.message,`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` use_restate_session`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_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:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result.final_output`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`kind`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"shared\"`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` get_history`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectSharedContext):`})]}),`\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\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`type_hint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`list[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` []`})]}),`\n`]})})}),_jsx(_MdxComponentBoundary,{name:`GitHubLink`,children:_jsx(GitHubLink,{url:`https://github.com/restatedev/ai-examples/blob/main/openai-agents/tour-of-agents/app/chat_agent.py`})}),_jsxs(Accordion,{title:`Try out Virtual Objects`,icon:`laptop`,id:`try-out-virtual-objects-1`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/installation`,children:`Install Restate`}),` and launch it:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate-server`})}),`\n`]})})}),_jsx(_components.p,{children:`Get the example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-openai-agents-tour-of-agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-openai-agents-tour-of-agents`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Export your `,_jsx(_components.a,{href:`https://platform.openai.com/api-keys`,children:`OpenAI API key`}),` and run the agent:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sk-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`...`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` app/chat_agent.py`})]}),`\n`]})})}),_jsx(_components.p,{children:`Register the agents with Restate:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deployments`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` register`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:9080`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --force`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --yes`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # dev only: overrides previous registrations`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for `,_jsx(_components.code,{children:`session123`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Make a poem about durable execution.\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Continue the conversation with the same session ID. The agent remembers previous context:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Shorten it to 2 lines.\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Go to the state tab of the UI to view the conversation history.`}),_jsx(_components.p,{children:`Send a message to a different session. It starts a completely separate conversation:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"What are the benefits of durable execution?\"}'`})]}),`\n`]})})})]})]}),_jsxs(Tab,{title:`Google ADK`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`google-adk`,children:[_jsxs(_components.p,{children:[`To turn your agent into a stateful session, you need two changes compared to a regular `,_jsx(_components.a,{href:`/ai/patterns/durable-agents`,children:`durable agent`}),`:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Define a Virtual Object`}),`: use `,_jsx(_components.code,{children:`restate.VirtualObject()`}),` instead of `,_jsx(_components.code,{children:`restate.Service()`}),`. This gives each session key its own isolated state.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[`Use `,_jsx(_components.code,{children:`RestateSessionService`})]}),` as the session service for the Runner: this stores the ADK session data (conversation history, agent state) in Restate’s K/V store. The object key (via `,_jsx(_components.code,{children:`ctx.key()`}),`) is used as the user identifier.`]}),`\n`]}),_jsx(CodeBlock,{filename:`chat_agent.py`,numberOfLines:`24`,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:`24`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},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:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gemini-2.5-flash\"`}),_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:` name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_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:` instruction`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a helpful assistant. Be concise and helpful.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`app `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` App(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`APP_NAME`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`root_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:`plugins`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[RestatePlugin()])`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`runner `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Runner(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`app`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`app, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`session_service`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`RestateSessionService())`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` restate.VirtualObject(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectContext, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ChatMessage) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_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:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` events `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` runner.run_async(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` user_id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`ctx.key(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` session_id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`req.session_id,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` new_message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Content(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`role`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`parts`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[Part.from_text(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`req.message)]),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_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\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` parse_agent_response(events)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`kind`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"shared\"`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` get_history`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectSharedContext, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`session_id`}),_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`,_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\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"session_store::`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`session_id`}),_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:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`type_hint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`list[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` []`})]}),`\n`]})})}),_jsx(_MdxComponentBoundary,{name:`GitHubLink`,children:_jsx(GitHubLink,{url:`https://github.com/restatedev/ai-examples/blob/main/google-adk/tour-of-agents/app/chat_agent.py`})}),_jsxs(Accordion,{title:`Try out Virtual Objects`,icon:`laptop`,id:`try-out-virtual-objects-2`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/installation`,children:`Install Restate`}),` and launch it:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate-server`})}),`\n`]})})}),_jsx(_components.p,{children:`Get the example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-google-adk-tour-of-agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-google-adk-tour-of-agents`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Export your `,_jsx(_components.a,{href:`https://aistudio.google.com/app/apikey`,children:`Google API key`}),` and run the agent:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` GOOGLE_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`your-api-key`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` app/chat_agent.py`})]}),`\n`]})})}),_jsx(_components.p,{children:`Register the agents with Restate:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deployments`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` register`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:9080`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --force`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --yes`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # dev only: overrides previous registrations`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for `,_jsx(_components.code,{children:`session123`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/user123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Make a poem about durable execution.\", \"session_id\": \"session-123\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Continue the conversation with the same user and session ID. The agent remembers previous context:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/user123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Shorten it to 2 lines.\", \"session_id\": \"session-123\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Go to the state tab of the UI to view the conversation history.`}),_jsx(_components.p,{children:`Send a message to a different user. It starts a completely separate conversation:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/user456/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"What are the benefits of durable execution?\", \"session_id\": \"session-567\"}'`})]}),`\n`]})})})]})]}),_jsxs(Tab,{title:`Pydantic AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`pydantic-ai`,children:[_jsxs(_components.p,{children:[`To turn your agent into a stateful session, you need two changes compared to a regular `,_jsx(_components.a,{href:`/ai/patterns/durable-agents`,children:`durable agent`}),`:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Define a Virtual Object`}),`: use `,_jsx(_components.code,{children:`restate.VirtualObject()`}),` instead of `,_jsx(_components.code,{children:`restate.Service()`}),`. This gives each session key its own isolated state.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Manage conversation history`}),` using the object’s K/V store: use `,_jsx(_components.code,{children:`ctx.get()`}),` and `,_jsx(_components.code,{children:`ctx.set()`}),` to read and write the message history.`]}),`\n`]}),_jsx(CodeBlock,{filename:`chat_agent.py`,numberOfLines:`24`,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:`24`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},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:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"openai:gpt-5.4\"`}),_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:` system_prompt`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a helpful assistant.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`restate_agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` RestateAgent(agent)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` VirtualObject(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ObjectContext, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ChatMessage) -> `}),_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:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Load message history from Restate's durable key-value store`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` history `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`serde`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`MessageSerde())`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` restate_agent.run(req.message, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`message_history`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`history)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Store updated history back in Restate state`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.set(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, result.all_messages(), `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`serde`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`MessageSerde())`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result.output`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`kind`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"shared\"`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` get_history`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectSharedContext) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_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\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`type_hint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {}`})]}),`\n`]})})}),_jsx(_MdxComponentBoundary,{name:`GitHubLink`,children:_jsx(GitHubLink,{url:`https://github.com/restatedev/ai-examples/blob/main/pydantic-ai/tour-of-agents/app/chat_agent.py`})}),_jsxs(Accordion,{title:`Try out Virtual Objects`,icon:`laptop`,id:`try-out-virtual-objects-3`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/installation`,children:`Install Restate`}),` and launch it:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate-server`})}),`\n`]})})}),_jsx(_components.p,{children:`Get the example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-pydantic-ai-tour-of-agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-pydantic-ai-tour-of-agents`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Export your `,_jsx(_components.a,{href:`https://platform.openai.com/api-keys`,children:`OpenAI API key`}),` and run the agent:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sk-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`...`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` app/chat_agent.py`})]}),`\n`]})})}),_jsx(_components.p,{children:`Register the agents with Restate:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deployments`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` register`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:9080`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --force`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --yes`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # dev only: overrides previous registrations`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for `,_jsx(_components.code,{children:`session123`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Make a poem about durable execution.\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Continue the conversation with the same session ID. The agent remembers previous context:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Shorten it to 2 lines.\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Go to the state tab of the UI to view the conversation history.`}),_jsx(_components.p,{children:`Send a message to a different session. It starts a completely separate conversation:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"What are the benefits of durable execution?\"}'`})]}),`\n`]})})})]})]}),_jsxs(Tab,{title:`LangChain`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`langchain`,children:[_jsxs(_components.p,{children:[`To turn your agent into a stateful session, you need two changes compared to a regular `,_jsx(_components.a,{href:`/ai/patterns/durable-agents`,children:`durable agent`}),`:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Define a Virtual Object`}),`: use `,_jsx(_components.code,{children:`restate.VirtualObject()`}),` instead of `,_jsx(_components.code,{children:`restate.Service()`}),`. This gives each session key its own isolated state.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Manage conversation history`}),` using the object’s K/V store: use `,_jsx(_components.code,{children:`ctx.get()`}),` and `,_jsx(_components.code,{children:`ctx.set()`}),` to read and write the message history.`]}),`\n`]}),_jsx(CodeBlock,{filename:`chat_agent.py`,numberOfLines:`23`,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:`23`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` restate.VirtualObject(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Chat\"`}),_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:`agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` create_agent(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`init_chat_model(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"openai:gpt-5.4\"`}),_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:` system_prompt`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a helpful assistant.\"`}),_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:` middleware`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[RestateMiddleware()],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectContext, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ChatMessage) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` history `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`type_hint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`ChatHistory) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ChatHistory()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` history.messages.append(HumanMessage(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`req.message))`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agent.ainvoke({`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: history.messages})`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.set(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, ChatHistory(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_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:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_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:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].content`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`kind`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"shared\"`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` get_history`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectSharedContext) -> ChatHistory:`})]}),`\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\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`type_hint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`ChatHistory) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ChatHistory()`})]}),`\n`]})})}),_jsx(_MdxComponentBoundary,{name:`GitHubLink`,children:_jsx(GitHubLink,{url:`https://github.com/restatedev/ai-examples/blob/main/langchain-python/tour-of-agents/app/chat_agent.py`})}),_jsxs(Accordion,{title:`Try out Virtual Objects`,icon:`laptop`,id:`try-out-virtual-objects-4`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/installation`,children:`Install Restate`}),` and launch it:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate-server`})}),`\n`]})})}),_jsx(_components.p,{children:`Get the example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-langchain-tour-of-agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-langchain-tour-of-agents`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Export your `,_jsx(_components.a,{href:`https://platform.openai.com/api-keys`,children:`OpenAI API key`}),` and run the agent:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sk-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`...`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` app/chat_agent.py`})]}),`\n`]})})}),_jsx(_components.p,{children:`Register the agents with Restate:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deployments`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` register`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:9080`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --force`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --yes`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # dev only: overrides previous registrations`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for `,_jsx(_components.code,{children:`session123`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Make a poem about durable execution.\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Continue the conversation with the same session ID. The agent remembers previous context:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"Shorten it to 2 lines.\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Go to the state tab of the UI to view the conversation history.`}),_jsx(_components.p,{children:`Send a message to a different session. It starts a completely separate conversation:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"What are the benefits of durable execution?\"}'`})]}),`\n`]})})})]})]}),_jsxs(Tab,{title:`Restate TS`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`restate-ts`,children:[_jsxs(_components.p,{children:[`To turn your agent into a stateful session, you need two changes compared to a regular `,_jsx(_components.a,{href:`/ai/patterns/durable-agents`,children:`durable agent`}),`:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Define a Virtual Object`}),`: use `,_jsx(_components.code,{children:`restate.object()`}),` instead of `,_jsx(_components.code,{children:`restate.service()`}),`. This gives each session key its own isolated state.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Manage conversation history`}),` using the object’s K/V store: use `,_jsx(_components.code,{children:`ctx.get()`}),` and `,_jsx(_components.code,{children:`ctx.set()`}),` to read and write the message history.`]}),`\n`]}),_jsx(CodeBlock,{filename:`chat-agent.ts`,numberOfLines:`38`,language:`typescript`,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:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`38`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`/**`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` * Long-lived, Stateful Chat Sessions`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` *`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` * Maintains conversation state across multiple requests using Restate's persistent memory.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` * Sessions survive failures and can be resumed at any time.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` */`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` restate`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@restatedev/restate-sdk\"`}),_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:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ObjectContext`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@restatedev/restate-sdk\"`}),_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:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` llmCall`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"./utils/llm\"`}),_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:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`zodPrompt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"./utils/utils\"`}),_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:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ModelMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@ai-sdk/provider-utils\"`}),_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:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` chatAgent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`object`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` name:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` handlers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` message:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`createObjectHandler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`input:`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` zodPrompt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Write a poem about Durable Execution\"`}),_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\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` ObjectContext`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_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:` { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_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\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Array`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`ModelMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"memory\"`}),_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:` [];`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`push`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` message`}),_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:` // Use your preferred LLM SDK here`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"LLM call\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` llmCall`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_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\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`push`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`set`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"memory\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_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:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ),`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` getHistory:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`createObjectSharedHandler`}),_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\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`ObjectSharedContext`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Array`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`ModelMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"memory\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_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\":`#9CDCFE`},children:`restate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`serve`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`services:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chatAgent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`], `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`port:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 9080`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`]})})}),_jsx(_MdxComponentBoundary,{name:`GitHubLink`,children:_jsx(GitHubLink,{url:`https://github.com/restatedev/ai-examples/blob/main/typescript-restate-only/tour-of-agents/src/chat-agent.ts`})}),_jsxs(Accordion,{title:`Try out Virtual Objects`,icon:`laptop`,id:`try-out-virtual-objects-5`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/installation`,children:`Install Restate`}),` and launch it:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate-server`})}),`\n`]})})}),_jsx(_components.p,{children:`Get the example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` typescript-restate-tour-of-agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` typescript-restate-tour-of-agents`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`})]}),`\n`]})})}),_jsx(_components.p,{children:`Export your API key:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sk-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`...`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npx`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` tsx`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ./src/chat-agent.ts`})]}),`\n`]})})}),_jsx(_components.p,{children:`Register the services with Restate:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deployments`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` register`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:9080`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --force`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --yes`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # dev only: overrides previous registrations`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for `,_jsx(_components.code,{children:`session123`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"make a poem about durable execution\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Continue the conversation with the same session ID. The agent remembers previous context:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"shorten it to 2 lines\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Send a message to a different session. It starts a completely separate conversation:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"what are the benefits of durable execution?\"}'`})]}),`\n`]})})})]})]}),_jsxs(Tab,{title:`Restate Py`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`restate-py`,children:[_jsxs(_components.p,{children:[`To turn your agent into a stateful session, you need two changes compared to a regular `,_jsx(_components.a,{href:`/ai/patterns/durable-agents`,children:`durable agent`}),`:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Define a Virtual Object`}),`: use `,_jsx(_components.code,{children:`restate.VirtualObject()`}),` instead of `,_jsx(_components.code,{children:`restate.Service()`}),`. This gives each session key its own isolated state.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Manage conversation history`}),` using the object’s K/V store: use `,_jsx(_components.code,{children:`ctx.get()`}),` and `,_jsx(_components.code,{children:`ctx.set()`}),` to read and write the message history.`]}),`\n`]}),_jsx(CodeBlock,{filename:`chat_agent.py`,numberOfLines:`28`,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:`28`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` restate.VirtualObject(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectContext, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`msg`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ChatMessage) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_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:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"\"A long-lived stateful chat session that allows for ongoing conversation.\"\"\"`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Retrieve conversation memory from Restate`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"memory\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`type_hint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`list[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` []`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages.append({`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: msg.message})`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.run_typed(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"LLM call\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` llm_call, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Use your preferred LLM SDK here`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` RunOptions(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`max_attempts`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3`}),_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:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_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:` # Update conversation memory in Restate`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages.append({`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: result.content})`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.set(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"memory\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, messages)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result.content`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@chat.handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`kind`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"shared\"`}),_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\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` get_history`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: restate.ObjectSharedContext):`})]}),`\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\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ctx.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"memory\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`type_hint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`list[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`dict`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` []`})]}),`\n`]})})}),_jsx(_MdxComponentBoundary,{name:`GitHubLink`,children:_jsx(GitHubLink,{url:`https://github.com/restatedev/ai-examples/blob/main/python-restate-only/tour-of-agents/app/chat_agent.py`})}),_jsxs(Accordion,{title:`Try out Virtual Objects`,icon:`laptop`,id:`try-out-virtual-objects-6`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/installation`,children:`Install Restate`}),` and launch it:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate-server`})}),`\n`]})})}),_jsx(_components.p,{children:`Get the example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-restate-tour-of-agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python-restate-tour-of-agents`})]}),`\n`]})})}),_jsx(_components.p,{children:`Export your API key:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sk-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`...`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` app/chat_agent.py`})]}),`\n`]})})}),_jsx(_components.p,{children:`Register the services with Restate:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`restate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deployments`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` register`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:9080`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --force`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --yes`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # dev only: overrides previous registrations`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Ask the agent to do some task. Specify the Virtual Object ID in the URL, for example for `,_jsx(_components.code,{children:`session123`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"make a poem about durable execution\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Continue the conversation with the same session ID. The agent remembers previous context:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"shorten it to 2 lines\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Send a message to a different session. It starts a completely separate conversation:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`--json `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{\"message\": \"what are the benefits of durable execution?\"}'`})]}),`\n`]})})})]})]})]}),`\n`,_jsx(_components.p,{children:`The state tab of the Restate UI lets you query the state of each session:`}),`\n`,_jsx(`div`,{className:`hidden-tabs`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`Vercel AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`vercel-ai-2`,children:_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=ae1bfcd8d881f1c7bb5e8439cfb3067e`,alt:`Conversation State Management`,\"data-og-width\":`1632`,width:`1632`,\"data-og-height\":`1030`,height:`1030`,\"data-path\":`img/tour/agents/conversations.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=e589932039c3c214fcf2f6e45f2c3412 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=2dba1bea46d882498f1a72464987ac2b 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=3b3999de5d159b46bb02668699f023bd 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=c036dcfc8e067b4dd68ecf7cfcfeda8a 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=504270380bd396b4e70f70bc9856d2c3 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=0c0028e7b421398ea60428344d63909b 2500w`})})}),_jsx(Tab,{title:`OpenAI Agents`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`openai-agents-2`,children:_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=ae1bfcd8d881f1c7bb5e8439cfb3067e`,alt:`Conversation State Management`,\"data-og-width\":`1632`,width:`1632`,\"data-og-height\":`1030`,height:`1030`,\"data-path\":`img/tour/agents/conversations.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=e589932039c3c214fcf2f6e45f2c3412 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=2dba1bea46d882498f1a72464987ac2b 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=3b3999de5d159b46bb02668699f023bd 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=c036dcfc8e067b4dd68ecf7cfcfeda8a 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=504270380bd396b4e70f70bc9856d2c3 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=0c0028e7b421398ea60428344d63909b 2500w`})})}),_jsx(Tab,{title:`Google ADK`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`google-adk-2`,children:_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/conversations.png?fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=b6bfb622cb52151bee7d776f386e9511`,alt:`Conversation State Management`,\"data-og-width\":`1219`,width:`1219`,\"data-og-height\":`849`,height:`849`,\"data-path\":`img/tour/agents/adk/conversations.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/conversations.png?w=280\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=1ec58b3462a2c51b2ae9ec527b0e7b38 280w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/conversations.png?w=560\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=2647c4ece43c41484fe6b4c5bb021e2e 560w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/conversations.png?w=840\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=5cf3c83c2616cbdf7e2fba960f804db3 840w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/conversations.png?w=1100\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=224bce54e55a5ec7cb0402302c3fe791 1100w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/conversations.png?w=1650\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=13eb0dbfce8bd82be4a56d12735edad9 1650w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/conversations.png?w=2500\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=c7e16176f6c3285bdd03dd570d9901d2 2500w`})})}),_jsx(Tab,{title:`Pydantic AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`pydantic-ai-2`,children:_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=ae1bfcd8d881f1c7bb5e8439cfb3067e`,alt:`Conversation State Management`,\"data-og-width\":`1632`,width:`1632`,\"data-og-height\":`1030`,height:`1030`,\"data-path\":`img/tour/agents/conversations.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=e589932039c3c214fcf2f6e45f2c3412 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=2dba1bea46d882498f1a72464987ac2b 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=3b3999de5d159b46bb02668699f023bd 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=c036dcfc8e067b4dd68ecf7cfcfeda8a 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=504270380bd396b4e70f70bc9856d2c3 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=0c0028e7b421398ea60428344d63909b 2500w`})})}),_jsx(Tab,{title:`LangChain`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`langchain-2`,children:_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=ae1bfcd8d881f1c7bb5e8439cfb3067e`,alt:`Conversation State Management`,\"data-og-width\":`1632`,width:`1632`,\"data-og-height\":`1030`,height:`1030`,\"data-path\":`img/tour/agents/conversations.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=e589932039c3c214fcf2f6e45f2c3412 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=2dba1bea46d882498f1a72464987ac2b 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=3b3999de5d159b46bb02668699f023bd 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=c036dcfc8e067b4dd68ecf7cfcfeda8a 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=504270380bd396b4e70f70bc9856d2c3 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=0c0028e7b421398ea60428344d63909b 2500w`})})}),_jsx(Tab,{title:`Restate TS`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`restate-ts-2`,children:_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=ae1bfcd8d881f1c7bb5e8439cfb3067e`,alt:`Conversation State Management`,\"data-og-width\":`1632`,width:`1632`,\"data-og-height\":`1030`,height:`1030`,\"data-path\":`img/tour/agents/conversations.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=e589932039c3c214fcf2f6e45f2c3412 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=2dba1bea46d882498f1a72464987ac2b 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=3b3999de5d159b46bb02668699f023bd 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=c036dcfc8e067b4dd68ecf7cfcfeda8a 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=504270380bd396b4e70f70bc9856d2c3 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=0c0028e7b421398ea60428344d63909b 2500w`})})}),_jsx(Tab,{title:`Restate Py`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`restate-py-2`,children:_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=ae1bfcd8d881f1c7bb5e8439cfb3067e`,alt:`Conversation State Management`,\"data-og-width\":`1632`,width:`1632`,\"data-og-height\":`1030`,height:`1030`,\"data-path\":`img/tour/agents/conversations.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=e589932039c3c214fcf2f6e45f2c3412 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=2dba1bea46d882498f1a72464987ac2b 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=3b3999de5d159b46bb02668699f023bd 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=c036dcfc8e067b4dd68ecf7cfcfeda8a 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=504270380bd396b4e70f70bc9856d2c3 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/conversations.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=0c0028e7b421398ea60428344d63909b 2500w`})})})]})}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`This pattern is complementary to AI memory solutions like mem0 or graffiti. You can use Virtual Objects to enforce session concurrency and queueing while storing the agent’s memory in specialized memory systems.`})}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`This pattern is implementable with any of our SDKs and any AI SDK.\nIf you need help with a specific SDK, please reach out to us via `,_jsx(_components.a,{href:`https://discord.restate.dev`,children:`Discord`}),` or `,_jsx(_components.a,{href:`https://slack.restate.dev`,children:`Slack`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`built-in-concurrency-control`,children:`Built-in concurrency control`}),`\n`,_jsx(_components.p,{children:`Restate queues concurrent requests to the same session key. They are processed sequentially, preventing race conditions on shared state. This works similar to a task queue per session, but without needing to set up any external queue infrastructure.`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_queue.png?fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=8deb701300c65e5a87e20c6b95dbb4f9`,alt:`Concurrency control`,\"data-og-width\":`1944`,width:`1944`,\"data-og-height\":`916`,height:`916`,\"data-path\":`img/tour/agents/chat_queue.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_queue.png?w=280\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=ee1e4f1a4d2604790ad4086ccacbdc84 280w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_queue.png?w=560\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=41ba0558bf8ed9ac0f0f7f3cf07b8cb7 560w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_queue.png?w=840\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=a77080f933f576bc44ad95916e332027 840w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_queue.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=b3957b468c5745b3b22e0ebaec43244d 1100w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_queue.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=b2a2ece331569b96825d9b757f5d2cc3 1650w, https://mintcdn.com/restate-6d46e1dc/ljjz_dSeR6PsMalr/img/tour/agents/chat_queue.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ljjz_dSeR6PsMalr\u0026q=85\u0026s=59cc2dd8a0211c0cc447157aecae37eb 2500w`}),`\n`,_jsx(_components.p,{children:`Different session keys run in parallel with no interference.`}),`\n`,_jsx(`div`,{className:`hidden-tabs`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`Vercel AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`vercel-ai-3`,children:_jsxs(Accordion,{title:`Try out queuing`,icon:`laptop`,id:`try-out-queuing`,children:[_jsx(_components.p,{children:`Send several messages concurrently to different chat sessions:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"make a poem about durable execution\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what are the benefits of durable execution?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"how does workflow orchestration work?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"can you make it rhyme better?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what about fault tolerance in distributed systems?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"give me a practical example\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session101/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"explain event sourcing in simple terms\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session202/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what is the difference between async and sync processing?\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`The UI shows how Restate queues the requests per session to ensure consistency:`}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=1fc75fe514a8e419bdd4a093093be02b`,alt:`Concurrency control in action`,\"data-og-width\":`1885`,width:`1885`,\"data-og-height\":`1060`,height:`1060`,\"data-path\":`img/tour/agents/exclusive-handlers.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=a9565671cd68ab27aa722bf2459ebc48 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=66e41997afa71d29583432a85861a3f4 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=8c06a138e6c2b7a619084eac7bc8d9fa 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=527b66e11c8a956ae974b3f349544b02 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=43901bdc1a45921d57f08fb7df7e0b72 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=7f261e0430234fba38a65c098399dd7a 2500w`})})]})}),_jsx(Tab,{title:`OpenAI Agents`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`openai-agents-3`,children:_jsxs(Accordion,{title:`Try out queuing`,icon:`laptop`,id:`try-out-queuing-1`,children:[_jsx(_components.p,{children:`Send several messages concurrently to different chat sessions:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"make a poem about durable execution\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what are the benefits of durable execution?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"how does workflow orchestration work?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"can you make it rhyme better?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what about fault tolerance in distributed systems?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"give me a practical example\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session101/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"explain event sourcing in simple terms\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session202/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what is the difference between async and sync processing?\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`The UI shows how Restate queues the requests per session to ensure consistency:`}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=fab7091323e26c47f8b6344e5f3e4650`,alt:`Concurrency control in action`,\"data-og-width\":`1871`,width:`1871`,\"data-og-height\":`687`,height:`687`,\"data-path\":`img/tour/agents/openai/exclusive-handlers.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=280\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=b57b17d1c2febf2abe21f3acadf1a574 280w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=560\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=d3f880d07a7b3301b0982f33f0a19cee 560w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=840\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=0047dfbdb911b6e5ba32a7d29b964f56 840w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=1100\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=8d1b1c2868da87ac954a96b35fa4afb8 1100w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=1650\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=394e10f272e7b6d00371567f40728c47 1650w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=2500\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=9a4f5b322f5049b3525ce6dc9c5b10b6 2500w`})})]})}),_jsx(Tab,{title:`Google ADK`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`google-adk-3`,children:_jsxs(Accordion,{title:`Try out queuing`,icon:`laptop`,id:`try-out-queuing-2`,children:[_jsx(_components.p,{children:`Send several messages concurrently to different users:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"make a poem about durable execution\", \"session_id\": \"session-123\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what are the benefits of durable execution?\", \"session_id\": \"session-567\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"how does workflow orchestration work?\", \"session_id\": \"session-999\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"can you make it rhyme better?\", \"session_id\": \"session-123\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what about fault tolerance in distributed systems?\", \"session_id\": \"session-567\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"give me a practical example\", \"session_id\": \"session-999\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user101/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"explain event sourcing in simple terms\", \"session_id\": \"session-123\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/user202/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what is the difference between async and sync processing?\", \"session_id\": \"session-123\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`The UI shows how Restate queues the requests per session to ensure consistency:`}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/exclusive-handlers.png?fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=71fc02bed87dd297dfcb87b5f36c1383`,alt:`Concurrency control in action`,\"data-og-width\":`1517`,width:`1517`,\"data-og-height\":`610`,height:`610`,\"data-path\":`img/tour/agents/adk/exclusive-handlers.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/exclusive-handlers.png?w=280\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=4c2b9d87907e1a689b612989abf19284 280w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/exclusive-handlers.png?w=560\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=18aa0bf25d841e3d6d29e84558ef4435 560w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/exclusive-handlers.png?w=840\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=672c75e3a93a02334726aee53eb1d3b9 840w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/exclusive-handlers.png?w=1100\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=70184cb705769375d929db103348aae7 1100w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/exclusive-handlers.png?w=1650\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=d8e2eea41fcc7002b383a1d63fe209b9 1650w, https://mintcdn.com/restate-6d46e1dc/Nqw04BBNfCiHrELc/img/tour/agents/adk/exclusive-handlers.png?w=2500\u0026fit=max\u0026auto=format\u0026n=Nqw04BBNfCiHrELc\u0026q=85\u0026s=c3f588ce74644b43aec6d2d70fbddf04 2500w`})})]})}),_jsx(Tab,{title:`Pydantic AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`pydantic-ai-3`,children:_jsxs(Accordion,{title:`Try out queuing`,icon:`laptop`,id:`try-out-queuing-3`,children:[_jsx(_components.p,{children:`Send several messages concurrently to different chat sessions:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"make a poem about durable execution\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what are the benefits of durable execution?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"how does workflow orchestration work?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"can you make it rhyme better?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what about fault tolerance in distributed systems?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"give me a practical example\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session101/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"explain event sourcing in simple terms\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session202/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what is the difference between async and sync processing?\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`The UI shows how Restate queues the requests per session to ensure consistency:`}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=fab7091323e26c47f8b6344e5f3e4650`,alt:`Concurrency control in action`,\"data-og-width\":`1871`,width:`1871`,\"data-og-height\":`687`,height:`687`,\"data-path\":`img/tour/agents/openai/exclusive-handlers.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=280\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=b57b17d1c2febf2abe21f3acadf1a574 280w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=560\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=d3f880d07a7b3301b0982f33f0a19cee 560w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=840\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=0047dfbdb911b6e5ba32a7d29b964f56 840w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=1100\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=8d1b1c2868da87ac954a96b35fa4afb8 1100w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=1650\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=394e10f272e7b6d00371567f40728c47 1650w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=2500\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=9a4f5b322f5049b3525ce6dc9c5b10b6 2500w`})})]})}),_jsx(Tab,{title:`LangChain`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`langchain-3`,children:_jsxs(Accordion,{title:`Try out queuing`,icon:`laptop`,id:`try-out-queuing-4`,children:[_jsx(_components.p,{children:`Send several messages concurrently to different chat sessions:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"make a poem about durable execution\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what are the benefits of durable execution?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"how does workflow orchestration work?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"can you make it rhyme better?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what about fault tolerance in distributed systems?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"give me a practical example\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session101/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"explain event sourcing in simple terms\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session202/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what is the difference between async and sync processing?\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`The UI shows how Restate queues the requests per session to ensure consistency:`}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=fab7091323e26c47f8b6344e5f3e4650`,alt:`Concurrency control in action`,\"data-og-width\":`1871`,width:`1871`,\"data-og-height\":`687`,height:`687`,\"data-path\":`img/tour/agents/openai/exclusive-handlers.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=280\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=b57b17d1c2febf2abe21f3acadf1a574 280w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=560\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=d3f880d07a7b3301b0982f33f0a19cee 560w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=840\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=0047dfbdb911b6e5ba32a7d29b964f56 840w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=1100\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=8d1b1c2868da87ac954a96b35fa4afb8 1100w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=1650\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=394e10f272e7b6d00371567f40728c47 1650w, https://mintcdn.com/restate-6d46e1dc/AlmW9-xJqv-0ObCA/img/tour/agents/openai/exclusive-handlers.png?w=2500\u0026fit=max\u0026auto=format\u0026n=AlmW9-xJqv-0ObCA\u0026q=85\u0026s=9a4f5b322f5049b3525ce6dc9c5b10b6 2500w`})})]})}),_jsx(Tab,{title:`Restate TS`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`restate-ts-3`,children:_jsxs(Accordion,{title:`Try out queuing`,icon:`laptop`,id:`try-out-queuing-5`,children:[_jsx(_components.p,{children:`Send several messages concurrently to different chat sessions:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"make a poem about durable execution\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what are the benefits of durable execution?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"how does workflow orchestration work?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"can you make it rhyme better?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what about fault tolerance in distributed systems?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"give me a practical example\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session101/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"explain event sourcing in simple terms\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session202/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what is the difference between async and sync processing?\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`The UI shows how Restate queues the requests per session to ensure consistency:`}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=1fc75fe514a8e419bdd4a093093be02b`,alt:`Concurrency control in action`,\"data-og-width\":`1885`,width:`1885`,\"data-og-height\":`1060`,height:`1060`,\"data-path\":`img/tour/agents/exclusive-handlers.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=a9565671cd68ab27aa722bf2459ebc48 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=66e41997afa71d29583432a85861a3f4 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=8c06a138e6c2b7a619084eac7bc8d9fa 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=527b66e11c8a956ae974b3f349544b02 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=43901bdc1a45921d57f08fb7df7e0b72 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=7f261e0430234fba38a65c098399dd7a 2500w`})})]})}),_jsx(Tab,{title:`Restate Py`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`restate-py-3`,children:_jsxs(Accordion,{title:`Try out queuing`,icon:`laptop`,id:`try-out-queuing-6`,children:[_jsx(_components.p,{children:`Send several messages concurrently to different chat sessions:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"make a poem about durable execution\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what are the benefits of durable execution?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"how does workflow orchestration work?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session123/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"can you make it rhyme better?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session456/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what about fault tolerance in distributed systems?\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session789/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"give me a practical example\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session101/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"explain event sourcing in simple terms\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/send/Chat/session202/message`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"message\": \"what is the difference between async and sync processing?\"}'`})]}),`\n`]})})}),_jsx(_components.p,{children:`The UI shows how Restate queues the requests per session to ensure consistency:`}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=1fc75fe514a8e419bdd4a093093be02b`,alt:`Concurrency control in action`,\"data-og-width\":`1885`,width:`1885`,\"data-og-height\":`1060`,height:`1060`,\"data-path\":`img/tour/agents/exclusive-handlers.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=280\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=a9565671cd68ab27aa722bf2459ebc48 280w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=560\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=66e41997afa71d29583432a85861a3f4 560w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=840\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=8c06a138e6c2b7a619084eac7bc8d9fa 840w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=1100\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=527b66e11c8a956ae974b3f349544b02 1100w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=1650\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=43901bdc1a45921d57f08fb7df7e0b72 1650w, https://mintcdn.com/restate-6d46e1dc/q2BK2cDd-GaqCp75/img/tour/agents/exclusive-handlers.png?w=2500\u0026fit=max\u0026auto=format\u0026n=q2BK2cDd-GaqCp75\u0026q=85\u0026s=7f261e0430234fba38a65c098399dd7a 2500w`})})]})})]})}),`\n`,_jsx(Heading,{level:`2`,id:`concurrently-retrieving-state`,children:`Concurrently retrieving state`}),`\n`,_jsx(_components.p,{children:`The state you store in Virtual Objects lives forever. To resume a session, simply send a new message to the same Virtual Object key.`}),`\n`,_jsx(`div`,{className:`hidden-tabs`,children:_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Vercel AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`vercel-ai-4`,children:[_jsxs(_components.p,{children:[`To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the `,_jsx(_components.code,{children:`getHistory`}),` handler in the example above.`]}),_jsx(_components.p,{children:`Call the handler to get the conversation history:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/getHistory`})]}),`\n`]})})})]}),_jsxs(Tab,{title:`OpenAI Agents`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`openai-agents-4`,children:[_jsxs(_components.p,{children:[`To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the `,_jsx(_components.code,{children:`get_history`}),` handler in the example above.`]}),_jsx(_components.p,{children:`Call the handler to get the conversation history:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/get_history`})]}),`\n`]})})})]}),_jsxs(Tab,{title:`Google ADK`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`google-adk-4`,children:[_jsxs(_components.p,{children:[`To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the `,_jsx(_components.code,{children:`get_history`}),` handler in the example above.`]}),_jsx(_components.p,{children:`Call the handler to get the conversation history:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/user123/get_history`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --json`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '\"session-123\"'`})]}),`\n`]})})})]}),_jsxs(Tab,{title:`Pydantic AI`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`pydantic-ai-4`,children:[_jsxs(_components.p,{children:[`To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the `,_jsx(_components.code,{children:`get_history`}),` handler in the example above.`]}),_jsx(_components.p,{children:`Call the handler to get the conversation history:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/get_history`})]}),`\n`]})})})]}),_jsxs(Tab,{title:`LangChain`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`langchain-4`,children:[_jsxs(_components.p,{children:[`To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the `,_jsx(_components.code,{children:`get_history`}),` handler in the example above.`]}),_jsx(_components.p,{children:`Call the handler to get the conversation history:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/get_history`})]}),`\n`]})})})]}),_jsxs(Tab,{title:`Restate TS`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=62b813088c931e033d6f0c262315f8e8`,\"data-og-width\":`800`,width:`800`,\"data-og-height\":`800`,height:`800`,\"data-path\":`img/languages/typescript.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=a94ebcba0be9e8a375e014a8f91b2773 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=ae82094b89f8df5162aa118dc4801175 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=18216e7589767120ad351236076bfac4 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=6bea830ed3b5f9c3c9d21765e5528ac3 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=7bb1ff6de20afda71f4c6ba5c3044f0f 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/typescript.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=5184b995e0a584ede38ec26a85a50745 2500w`,id:`restate-ts-4`,children:[_jsxs(_components.p,{children:[`To retrieve state, view the UI’s state tab or add a handler that reads it. Have a look at the `,_jsx(_components.code,{children:`getHistory`}),` handler in the example above.`]}),_jsx(_components.p,{children:`Call the handler to get the conversation history:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/getHistory`})]}),`\n`]})})})]}),_jsxs(Tab,{title:`Restate Py`,icon:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=67a6dbe92867a1d945bbe5940057662e`,\"data-og-width\":`404`,width:`404`,\"data-og-height\":`399`,height:`399`,\"data-path\":`img/languages/python.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=280\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=0d6d9866c291b2e305815d01fda6fcc5 280w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=560\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=e410eca2859fae6f102a8131bb51459c 560w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=840\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c284eff6d62df0171d9d6e54927b65eb 840w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=c736db39a089dc3418323c9ecc984bb7 1100w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=97c98159b96d5a4e0b53654433a187be 1650w, https://mintcdn.com/restate-6d46e1dc/MqWeXC2P3O-4Bva4/img/languages/python.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=MqWeXC2P3O-4Bva4\u0026q=85\u0026s=721d0aaf5a97ff4ead85c67876349bca 2500w`,id:`restate-py-4`,children:[_jsxs(_components.p,{children:[`To retrieve state, view the UI’s state tab or add as handler that reads it. Have a look at the `,_jsx(_components.code,{children:`get_history`}),` handler in the example above.`]}),_jsx(_components.p,{children:`Call the handler to get the conversation history:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:8080/restate/call/Chat/session123/get_history`})]}),`\n`]})})})]})]})}),`\n`,_jsxs(_components.p,{children:[`This is a `,_jsx(_components.a,{href:`/foundations/handlers#handler-behavior`,children:`shared handler`}),`, meaning it can only read state (not write). This allows it to run concurrently with the `,_jsx(_components.code,{children:`message`}),` handler.`]}),`\n`,_jsx(Heading,{level:`2`,id:`steerable-stateful-agents`,children:`Steerable, stateful agents`}),`\n`,_jsxs(_components.p,{children:[`For a complete TypeScript application, see the `,_jsx(_components.a,{href:`https://github.com/restatedev/agent`,children:`Agent Reference Architecture`}),`. It separates the agent controller and turn execution into two Virtual Objects, so you can steer a running turn or respond to approvals while it works.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{GitHubLink,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":"Durable Sessions","sidebarTitle":"Durable Sessions","icon":"comments","description":"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.","href":"/ai/patterns/sessions"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[146,1652,")=>null;function _cr"]]},"mdxExtracts":{"tableOfContents":[{"title":"How it works","slug":"how-it-works","depth":2,"children":[]},{"title":"Example: a chat session","slug":"example-a-chat-session","depth":2,"children":[]},{"title":"Built-in concurrency control","slug":"built-in-concurrency-control","depth":2,"children":[]},{"title":"Concurrently retrieving state","slug":"concurrently-retrieving-state","depth":2,"children":[]},{"title":"Steerable, stateful agents","slug":"steerable-stateful-agents","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/restate-6d46e1dc/fe33ed8c8f6baacd/matomo.js","/_mintlify/custom/restate-6d46e1dc/4d0b5d686abf67ad/scarf.js","/_mintlify/custom/restate-6d46e1dc/28474ce7323ba556/cookie-consent.js"],"subdomain":"restate-6d46e1dc","siteName":"Restate","title":"Durable Sessions - Restate","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-30T11:51:08.442Z","originalFileLocation":"ai/patterns/sessions.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=\"light\";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=\"light\"}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=\"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Restate\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/restate-6d46e1dc/aPguAmH_f4I6oEvV/_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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/restate-6d46e1dc/aPguAmH_f4I6oEvV/_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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Durable Sessions - Restate\">\u003cmeta data-mint-head property=\"og:description\" content=\"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Restate\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.restate.dev/ai/patterns/sessions\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://restate-6d46e1dc.mintlify.site/_mintlify/api/og/v2?division=Getting+Started\u0026amp;title=Durable+Sessions\u0026amp;description=Persistent%2C+isolated+agent+sessions+keyed+by+ID.+Conversation+state+survives+crashes+and+restarts+with+built-in+concurrency+control.\u0026amp;theme=30a1876c039d9e9b0beaa49c\u0026amp;signature=57c2990b03bbdda697168fa3a9dee7f0742a7f60a8226838badc64ba199bd42b\">\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=\"Durable Sessions - Restate\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://restate-6d46e1dc.mintlify.site/_mintlify/api/og/v2?division=Getting+Started\u0026amp;title=Durable+Sessions\u0026amp;description=Persistent%2C+isolated+agent+sessions+keyed+by+ID.+Conversation+state+survives+crashes+and+restarts+with+built-in+concurrency+control.\u0026amp;theme=30a1876c039d9e9b0beaa49c\u0026amp;signature=57c2990b03bbdda697168fa3a9dee7f0742a7f60a8226838badc64ba199bd42b\">\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/restate-6d46e1dc/aPguAmH_f4I6oEvV/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Restate\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#4752c4\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.restate.dev/ai/patterns/sessions\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/ai/patterns/sessions.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.restate.dev/#organization\",\"name\":\"Restate\",\"url\":\"https://docs.restate.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/restate-6d46e1dc/0MkLgffDAGHkNDIZ/logo/light.svg?fit=max\u0026auto=format\u0026n=0MkLgffDAGHkNDIZ\u0026q=85\u0026s=70e648c2608af2d2c33dc26b3bce13d3\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.restate.dev#website\",\"name\":\"Restate\",\"url\":\"https://docs.restate.dev\",\"publisher\":{\"@id\":\"https://docs.restate.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.restate.dev/ai/patterns/sessions#webpage\",\"url\":\"https://docs.restate.dev/ai/patterns/sessions\",\"name\":\"Durable Sessions\",\"description\":\"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.\",\"dateModified\":\"2026-09-30T11:51:08.442Z\",\"isPartOf\":{\"@id\":\"https://docs.restate.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.restate.dev/ai/patterns/sessions#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.restate.dev/ai/patterns/sessions#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Getting Started\",\"item\":\"https://docs.restate.dev/ai/patterns/durable-agents\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Durable Sessions\",\"item\":\"https://docs.restate.dev/ai/patterns/sessions\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.restate.dev/ai/patterns/sessions#article\",\"headline\":\"Durable Sessions\",\"name\":\"Durable Sessions\",\"description\":\"Persistent, isolated agent sessions keyed by ID. Conversation state survives crashes and restarts with built-in concurrency control.\",\"url\":\"https://docs.restate.dev/ai/patterns/sessions\",\"mainEntityOfPage\":{\"@id\":\"https://docs.restate.dev/ai/patterns/sessions#webpage\"},\"dateModified\":\"2026-09-30T11:51:08.442Z\",\"publisher\":{\"@id\":\"https://docs.restate.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.restate.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Restate\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Restate\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/ai/patterns/sessions.md","siteName":"Restate","nav":{"global":null,"tabs":[{"tab":"Learn","icon":"graduation-cap","pages":[{"title":"Learn","href":""}]},{"tab":"Docs","icon":"hammer","pages":[{"title":"Docs","href":"/docs"}]},{"tab":"Guides","icon":"book","pages":[{"title":"Guides","href":"/guides"}]},{"tab":"Roadmap","icon":"map","pages":[{"title":"Roadmap","href":"/roadmap/oss"}]},{"tab":"AI / Agents","icon":"robot","pages":[{"title":"AI / Agents with Restate","sidebarTitle":"Overview","icon":"book-open","href":"/ai"},{"title":"Agent Quickstart","icon":"robot","href":"/ai-quickstart"},{"title":"AI Examples","url":"https://github.com/restatedev/ai-examples","icon":"github","href":"/ai/ai-examples"},{"title":"Agent Reference Architecture","url":"https://github.com/restatedev/agent","icon":"github","href":"/ai/reference-architecture"},{"group":"Getting Started","pages":[{"title":"Durable Agents","sidebarTitle":"Durable Agents","icon":"shield-halved","description":"Build AI agents that survive crashes and recover automatically. Every LLM call, tool execution, and routing decision is durably persisted.","href":"/ai/patterns/durable-agents"},{"title":"Durable Sessions","sidebarTitle":"Durable Sessions","icon":"comments","href":"/ai/patterns/sessions"},{"title":"Approvals with Pause \u0026 Resume","sidebarTitle":"Approvals with Pause \u0026 Resume","icon":"user-check","description":"Agents that pause for human approval and resume when it arrives, even across restarts and infrastructure changes.","href":"/ai/patterns/human-in-the-loop"},{"title":"Multi-Agent Orchestration","sidebarTitle":"Multi-Agent Orchestration","icon":"users","href":"/ai/patterns/multi-agent"},{"title":"Observability \u0026 Control","sidebarTitle":"Observability \u0026 Control","icon":"eye","href":"/ai/patterns/observability-control"}]},{"group":"Orchestration Guides","pages":[{"title":"Parallel Tool Calls","sidebarTitle":"Parallel Tool Calls","icon":"bolt","href":"/ai/patterns/parallelization"},{"group":"Workflows","icon":"diagram-project","pages":[{"title":"Sequential Pipeline","sidebarTitle":"Sequential Pipeline","icon":"arrow-right","href":"/ai/patterns/workflow-sequential"},{"title":"Parallel Agents","sidebarTitle":"Parallel Agents","icon":"arrows-split-up-and-left","href":"/ai/patterns/workflow-parallel"},{"title":"Evaluation Feedback Loop","sidebarTitle":"Evaluation Loop","icon":"rotate","href":"/ai/patterns/workflow-evaluator"},{"title":"Orchestrator-Worker","sidebarTitle":"Orchestrator-Worker","icon":"sitemap","href":"/ai/patterns/workflow-orchestrator"}]},{"title":"Workflows as Tools","sidebarTitle":"Workflows as Tools","icon":"wrench","href":"/ai/patterns/tools"},{"title":"Remote Agents","icon":"network-wired","href":"/ai/patterns/remote-agents"},{"title":"Racing agents","icon":"flag-checkered","href":"/ai/patterns/competitive-racing"},{"title":"Interrupt \u0026 Regenerate","sidebarTitle":"Interrupt \u0026 Regenerate","icon":"rotate","href":"/ai/patterns/interrupt-regenerate"}]},{"group":"Reliability Guides","pages":[{"title":"Retries \u0026 Error Handling","sidebarTitle":"Retries \u0026 Error Handling","icon":"triangle-exclamation","href":"/ai/patterns/error-handling"},{"title":"Rollback on Failures","icon":"arrow-rotate-left","href":"/ai/patterns/rollback"}]},{"group":"Frontend Integration","pages":[{"title":"Chat UI Integration","sidebarTitle":"Chat UI Integration","icon":"browser","href":"/ai/patterns/chat-ui-integration"},{"title":"Streaming Responses","icon":"signal-stream","href":"/ai/patterns/streaming-responses"},{"title":"Notify when ready","icon":"bell","href":"/ai/patterns/notify-when-ready"}]},{"group":"SDK Integrations","pages":[{"title":"Restate \u0026 Vercel AI SDK","sidebarTitle":"Vercel AI SDK","icon":"https://mintlify.s3.us-west-1.amazonaws.com/restate-6d46e1dc/img/languages/typescript.svg","href":"/ai/sdk-integrations/vercel-ai-sdk"},{"title":"Restate \u0026 OpenAI Agents SDK","sidebarTitle":"OpenAI Agents SDK","icon":"https://mintlify.s3.us-west-1.amazonaws.com/restate-6d46e1dc/img/languages/python.svg","href":"/ai/sdk-integrations/openai-agents-sdk"},{"title":"Restate \u0026 Google ADK","sidebarTitle":"Google ADK","icon":"https://mintlify.s3.us-west-1.amazonaws.com/restate-6d46e1dc/img/languages/python.svg","href":"/ai/sdk-integrations/google-adk"},{"title":"Restate \u0026 Pydantic AI","sidebarTitle":"Pydantic AI","icon":"https://mintlify.s3.us-west-1.amazonaws.com/restate-6d46e1dc/img/languages/python.svg","href":"/ai/sdk-integrations/pydantic-ai"},{"title":"Restate \u0026 LangChain","sidebarTitle":"LangChain","icon":"https://mintlify.s3.us-west-1.amazonaws.com/restate-6d46e1dc/img/languages/python.svg","href":"/ai/sdk-integrations/langchain"},{"title":"Restate \u0026 LiteLLM","sidebarTitle":"LiteLLM","icon":"https://mintlify.s3.us-west-1.amazonaws.com/restate-6d46e1dc/img/languages/python.svg","href":"/ai/sdk-integrations/litellm"},{"title":"Integrating Restate with LLM / Agent SDKs","sidebarTitle":"Integrating with other SDKs","icon":"puzzle-piece","href":"/ai/sdk-integrations/integration-guide"}]},{"group":"AI Observability Integrations","pages":[{"title":"Langfuse","sidebarTitle":"Langfuse","icon":"magnifying-glass","href":"/ai/ecosystem-integrations/langfuse"},{"title":"Pydantic Logfire","sidebarTitle":"Pydantic Logfire","icon":"magnifying-glass","href":"/ai/ecosystem-integrations/logfire"},{"title":"Arize Phoenix","sidebarTitle":"Arize Phoenix","icon":"magnifying-glass","href":"/ai/ecosystem-integrations/arize-phoenix"},{"title":"Parseable","sidebarTitle":"Parseable","icon":"magnifying-glass","href":"/ai/ecosystem-integrations/parseable"}]}]}]},"basePath":"","title":"Durable Sessions - Restate","buildId":"dpl_5tKr6cUUeuVJdEZ9JAEY3h4soMJ8","deploymentId":"dpl_5tKr6cUUeuVJdEZ9JAEY3h4soMJ8","dynamics":["a74be98ba7","07c022d89b"],"chunks":["zoom-image-lightbox-9bQKnClW.js","lightbox-handle-r17bVUz3.js","Frame-B90Qhg8r.js","DynamicMarkdown-DpAS3GCb.js"]}