session_context — but it is the most important call in the entire workflow. It opens a traced research run, attaches the user’s question, and scopes every subsequent tool call the agent makes.
session_context
Open a traced research run and attach the user’s question. Every tool call after this one is recorded against the session and streamed live to the web UI via SSE.
Arguments
What it does
- Creates a new session row (or resumes an existing one) scoped to the caller’s
tenant_id. - Stores the
promptverbatim — this is the canonical record of what the human asked. - Returns a
session_idthat the agent includes in every subsequent tool call (either explicitly or implicitly via the MCP session context). - Begins streaming trace events to the web UI via SSE so the human can watch the research unfold live.
Why it’s always called first
No other tool can be called before
session_context. The MCP server rejects calls that arrive without an active session — there is no unscoped execution path. This is enforced at the server, not just by the agent’s instructions.session_context, there is no session, and the server returns an error:
Return value
session_context returns a session descriptor:
Example call
Example response
Resuming a session
Passsession_id to resume an existing session instead of creating a new one. This is useful when an agent is re-invoked to continue research from a previous turn:
prompt is appended to the session’s prompt history. The session’s status remains open and the trace stream continues from where it left off.
Session lifecycle
Session lifecycle
open— the session is active and accepting tool calls.closed— the agent calledsession_close(or the session timed out). No further tool calls are accepted. The trace is still readable and replayable from the web UI.archived— the session has been moved to cold storage after the retention window. Metadata is still queryable; raw trace events may take longer to load.
Related
- Data tools — what to call after the session is open
- Trace observability — how the web UI consumes the trace stream
- SSE streaming — the transport behind the live trace