Chat sessions
Models have no memory. Each request starts from a blank slate. To hold a conversation, the earlier messages have to be sent along each time. A session does this for you.
How it works
The first message starts a session, and the reply carries a session_id. Send that ID
with the next message, and Custodian includes the earlier conversation, so the agent
remembers it.
You: "My name is Alex." → new session: session_ab12
Agent: "Nice to meet you, Alex."
You: "What's my name?" + session_ab12
Agent: "Your name is Alex."
Without the session ID, the second question would start a new conversation and the agent wouldn't know.
The SDKs handle it for you
app.chat() stores the session ID and resends it automatically. Multi-turn
conversations just work.
- Python
- TypeScript
app.chat("My name is Alex.")
print(app.chat("What is my name?").response) # knows it's Alex
app.reset_session() # next message starts a fresh conversation
app.session().ask("Summarize the handbook.") # helper that always returns a ChatResponse
app.chat() # interactive terminal chat; "exit" to quit
await app.chat("My name is Alex.");
console.log((await app.chat("What is my name?"))?.response); // knows it's Alex
console.log(app.sessionId); // null before the first message
app.resetSession(); // next message starts a fresh conversation
await app.session().ask("Summarize the handbook."); // never returns null
await app.chat(); // interactive terminal chat (Node TTY); "exit" to quit
The session lives on the deployed app handle in your code — Python: DeployedApp
(aliases App / CustodianSquadApp), TypeScript: App. A new handle starts with no
session. Re-attach to an existing deployment by ID
(Python) and the next chat() continues the
previous server conversation.
Many users at once
One App object holds one conversation. If your backend serves many users, store each
user's session_id and send it with their messages over the
Platform API. That keeps every user's conversation separate.
Squads
A squad shares one session across all its agents, so follow-ups keep their context even if a different agent answers.
The chat response
| Python | TypeScript | Meaning |
|---|---|---|
response | response | The reply text. |
session_id | sessionId | The current session. |
retrieved_contexts | retrievedContexts | File passages used, if any. |
structured_output | rawPayload.structured_output | Parsed JSON when the agent has a response_schema. |
research_sources | rawPayload.research_sources | Pages found by web tools. |
selected_agent, handoff_path, contributing_agents | selectedAgent, handoffPath, contributingAgents | Which squad agents answered. |
raw_payload | rawPayload | The unmodified API response. |