Skip to content

InvokeModelContext

Defined in: src/middleware/stages.ts:74

Context passed to model-stage middleware. All inputs to the model call are explicit — middleware can inspect and transform any of them by passing a modified context to next().

readonly agent: LocalAgent;

Defined in: src/middleware/stages.ts:76

The agent instance (escape hatch for advanced use cases).


readonly messages: readonly Message[];

Defined in: src/middleware/stages.ts:78

The messages to send to the model.


readonly optional systemPrompt?: SystemPrompt;

Defined in: src/middleware/stages.ts:80

System prompt to guide the model’s behavior.


readonly toolSpecs: readonly ToolSpec[];

Defined in: src/middleware/stages.ts:82

Tool specifications available to the model.


readonly optional toolChoice?: ToolChoice;

Defined in: src/middleware/stages.ts:84

Controls how the model selects tools.


readonly invocationState: InvocationState;

Defined in: src/middleware/stages.ts:86

Per-invocation state. Shared by reference — mutations are visible to hooks, tools, and AgentResult.