Description
Description:
I've been exploring how to track individual tool calls across their lifecycle using the OpenAI Agents JS SDK. I noticed that the agent_tool_start
and agent_tool_end
events don't seem to include a callId
or similar identifier, which makes it a bit tricky to correlate the beginning and end of a specific tool call—especially when a tool may be invoked multiple times concurrently.
Question / Suggestion
Is there a reason why callId
(which I believe is used internally to track tool invocations) isn't exposed in the tool lifecycle events?
If it's technically feasible, would it make sense to include it in the emitted events like so?
agent_tool_start: [
context: RunContext<TContext>,
agent: Agent<TContext, TOutput>,
tool: Tool,
callId: string // <- possible addition?
];
agent_tool_end: [
context: RunContext<TContext>,
agent: Agent<TContext, TOutput>,
tool: Tool,
result: string,
callId: string // <- possible addition?
];
Why This Might Help
Having access to something like callId
would be useful for:
- Linking
agent_tool_start
andagent_tool_end
for the same tool call - Measuring execution time for individual tool invocations
- Debugging and monitoring concurrent tool usage
- Correlating human approval workflows with specific tool executions
Current Workaround
At the moment, I'm considering workarounds like generating my own unique IDs per tool invocation, but that feels redundant if the SDK already generates and tracks a callId
internally.
Curious to Know
If there's already a way to do this or a better recommended approach, I’d love to hear about it!