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
| Argument | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The user’s natural-language question or research goal. Stored verbatim and displayed in the web UI. |
title | string | No | A short human-readable title for the session. If omitted, one is derived from the first line of prompt. |
session_id | string | No | An existing session ID to resume. If omitted, a new session is created. |
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:
| Field | Type | Description |
|---|---|---|
session_id | string (UUID) | The session identifier. Include this in subsequent calls. |
tenant_id | string (UUID) | The tenant the session belongs to. Echoed for transparency. |
title | string | The resolved session title. |
created_at | string (ISO 8601) | When the session was opened. |
status | string | open — the session is active and accepting tool calls. |
trace_stream | string (URL) | The SSE endpoint the web UI subscribes to. |
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