Skip to main content

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.

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

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​

PythonTypeScriptMeaning
responseresponseThe reply text.
session_idsessionIdThe current session.
retrieved_contextsretrievedContextsFile passages used, if any.
structured_outputrawPayload.structured_outputParsed JSON when the agent has a response_schema.
research_sourcesrawPayload.research_sourcesPages found by web tools.
selected_agent, handoff_path, contributing_agentsselectedAgent, handoffPath, contributingAgentsWhich squad agents answered.
raw_payloadrawPayloadThe unmodified API response.