Defined in: types.ts:351
Context passed to tool execute functions, providing capabilities like emitting custom events during execution.
emitCustomEvent: (eventName, value) => void;
emitCustomEvent: (eventName, value) => void;
Defined in: types.ts:372
Emit a custom event during tool execution. Events are streamed to the client in real-time as AG-UI CUSTOM events.
string
Name of the custom event
Record<string, any>
Event payload value
void
const tool = toolDefinition({ ... }).server(async (args, context) => {
context?.emitCustomEvent('progress', { step: 1, total: 3 })
// ... do work ...
context?.emitCustomEvent('progress', { step: 2, total: 3 })
// ... do more work ...
return result
})
const tool = toolDefinition({ ... }).server(async (args, context) => {
context?.emitCustomEvent('progress', { step: 1, total: 3 })
// ... do work ...
context?.emitCustomEvent('progress', { step: 2, total: 3 })
// ... do more work ...
return result
})
optional toolCallId: string;
optional toolCallId: string;
Defined in: types.ts:353
The ID of the tool call being executed
