Runtime Context
Updated 6 hours ago • May 22, 2026
Runtime context is request metadata that server-side node code may need during one chat run.
Use it for values such as selected thread id, locale, UI mode, tenant hints, or server-approved auth context. Do not use it for the user's message. Do not use it as static node configuration.
The Three Inputs
Kortyx has three different data lanes:
Client to Node Flow
With @kortyx/react, pass request metadata through useChat({ context }).
The default route transport sends a body shaped like this:
In your route, parse the request and pass approved context into agent.streamChat(...).
Good to know: Client-sent context is request metadata, not trusted authorization state. Authenticate the route and derive sensitive values such as user id, roles, tenant permissions, and billing access on the server.
Read Context in a Node
Inside node execution, call useRuntimeContext(...).
useRuntimeContext(...) returns an object. If no context was passed for the request, it returns an empty object.
What Not to Put in Context
- Do not put provider credentials in context.
- Do not trust client-provided user ids, roles, permissions, or tenant access.
- Do not put large documents or full chat history in context; use messages, summaries, retrieval, or app services.
- Do not use context for static node settings; use node
params.
What to Read Next
- Nodes for
input,params, anddata - streamChat for request handling
- React Client for
useChat({ context }) - SSE for API Routes for authenticated streaming routes