-
Notifications
You must be signed in to change notification settings - Fork 286
Labels
Description
Describe the bug
I need to collect usage information at the end of each of my agent runs. For non-streaming agents I can hook into the agent_end
event and fetch the usage information from the run context. However for steaming agents, my handler is never called.
Debug information
- Agents SDK version:
v0.0.17
- Runtime environment:
Node.js 20.19.3
Repro steps
const myAgent = new Agent({
name: 'My Agent',
instructions: 'Some instructions'
});
const runner = new Runner();
const streamResult = await runner.run(myAgent, [], {
context: {},
stream: true
});
myAgent.on('agent_tool_start', () => {
console.log('agent_tool_start called'); // This works!
);
myAgent.on('agent_tool_end', () => {
console.log('agent_tool_end called'); // This function is never hit
);
Expected behavior
I expect completed streaming agents to call the agent_tool_end
handlers.