Skip to content

Function: createRequestContext()

createRequestContext(options?): Promise<RequestContext<unknown>>

Build the RequestContext a NON-HTTP agent turn needs.

Everything Mastra’s tools read off the context is stamped the same way the request middleware stamps it - the AppKit user (so ask_genie and the model resolver can mint user-scoped tokens), the memory thread / resource pair, and a request id so the turn’s spans join up in traces. The result is passed as requestContext to agent.generate / agent.stream.

This is what makes a card turn answer with the SAME data a chat turn does: the difference between the two endpoints is presentation, not capability.

string

string

string

Promise<RequestContext<unknown>>