diff --git a/examples/basic/lifecycle-example.ts b/examples/basic/lifecycle-example.ts index f7f9d76c..8ed864f3 100644 --- a/examples/basic/lifecycle-example.ts +++ b/examples/basic/lifecycle-example.ts @@ -59,16 +59,18 @@ function attachHooks(agent: Agent) { `### ${eventCounter}: ${agent.name} ended with output ${JSON.stringify(output)}. Usage: ${toPrintableUsage(ctx?.usage)}`, ); }); - agent.on('agent_tool_start', (ctx, tool) => { + agent.on('agent_tool_start', (ctx, tool, { toolCall }) => { eventCounter++; + const args = toolCall.type === 'function_call' ? toolCall.arguments : ''; console.log( - `### ${eventCounter}: Tool ${tool.name} started. Usage: ${toPrintableUsage(ctx?.usage)}`, + `### ${eventCounter}: Tool ${tool.name} (args: ${args}) started. Usage: ${toPrintableUsage(ctx?.usage)}`, ); }); - agent.on('agent_tool_end', (ctx, tool, result) => { + agent.on('agent_tool_end', (ctx, tool, result, { toolCall }) => { eventCounter++; + const args = toolCall.type === 'function_call' ? toolCall.arguments : ''; console.log( - `### ${eventCounter}: Tool ${tool.name} ended with result ${JSON.stringify(result)}. Usage: ${toPrintableUsage(ctx?.usage)}`, + `### ${eventCounter}: Tool ${tool.name} (args: ${args}) ended with result ${JSON.stringify(result)}. Usage: ${toPrintableUsage(ctx?.usage)}`, ); }); agent.on('agent_handoff', (ctx, nextAgent) => {