ToolMiddlewareContext
Interface: ToolMiddlewareContext
Defined in: src/core/agent/middleware/types.ts:162
The call a tool middleware is deciding about.
Extended by
Properties
args
readonlyargs:Readonly<Record<string,unknown>>
Defined in: src/core/agent/middleware/types.ts:185
The args as THIS middleware sees them — every earlier transform in the chain already applied. The first middleware sees what the model asked for; the last sees what the tool is about to receive.
history
readonlyhistory: readonlyLLMMessage[]
Defined in: src/core/agent/middleware/types.ts:187
Conversation so far, including the assistant turn that made this call.
identity?
readonlyoptionalidentity?:MemoryIdentity
Defined in: src/core/agent/middleware/types.ts:189
Multi-tenant run identity, when the run carried one.
iteration
readonlyiteration:number
Defined in: src/core/agent/middleware/types.ts:179
ReAct iteration this call belongs to.
signal?
readonlyoptionalsignal?:AbortSignal
Defined in: src/core/agent/middleware/types.ts:191
Abort signal from run({ env: { signal } }).
toolCallId
readonlytoolCallId:string
Defined in: src/core/agent/middleware/types.ts:177
Matches stream.tool_start.toolCallId for this dispatch.
toolName
readonlytoolName:string
Defined in: src/core/agent/middleware/types.ts:163
toolSource?
readonlyoptionaltoolSource?:string
Defined in: src/core/agent/middleware/types.ts:175
Where the tool being called came from — Tool.source, which mcpClient
fills with the server's name.
Absent means the agent's own tool. A name alone is not an identity: two
MCP servers may both serve a call_aws, and a policy matching the bare
name governs whichever one answers — including the one it was never written
about. With this, call.toolSource === 'aws-prod' is a rule that means what
it says, and call.toolSource === undefined is the honest way to spell
"something we wrote ourselves".
