ToolResultContext
Interface: ToolResultContext
Defined in: src/core/agent/middleware/types.ts:202
The finished call onToolResult is deciding about: everything onToolCall
saw, plus what came back.
args here are the args the tool ACTUALLY RAN WITH — every before-transform
applied — so a rule reading both fields is reading one coherent event rather
than the model's proposal beside somebody else's answer.
Extends
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.
Inherited from
error?
readonlyoptionalerror?:true
Defined in: src/core/agent/middleware/types.ts:214
Present and true when the tool THREW and result is the error's
message. The call still executed, which is why this moment happens at
all: a tool that failed halfway may have done half its work.
history
readonlyhistory: readonlyLLMMessage[]
Defined in: src/core/agent/middleware/types.ts:187
Conversation so far, including the assistant turn that made this call.
Inherited from
identity?
readonlyoptionalidentity?:MemoryIdentity
Defined in: src/core/agent/middleware/types.ts:189
Multi-tenant run identity, when the run carried one.
Inherited from
ToolMiddlewareContext.identity
iteration
readonlyiteration:number
Defined in: src/core/agent/middleware/types.ts:179
ReAct iteration this call belongs to.
Inherited from
ToolMiddlewareContext.iteration
result
readonlyresult:unknown
Defined in: src/core/agent/middleware/types.ts:208
What the tool returned. Whatever the tool's own return type is, un- stringified — the conversion to the text the model reads happens after this chain, so a rule can inspect the real object.
signal?
readonlyoptionalsignal?:AbortSignal
Defined in: src/core/agent/middleware/types.ts:191
Abort signal from run({ env: { signal } }).
Inherited from
toolCallId
readonlytoolCallId:string
Defined in: src/core/agent/middleware/types.ts:177
Matches stream.tool_start.toolCallId for this dispatch.
Inherited from
ToolMiddlewareContext.toolCallId
toolName
readonlytoolName:string
Defined in: src/core/agent/middleware/types.ts:163
Inherited from
ToolMiddlewareContext.toolName
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".
