[FEATURE] Expose the native tool call id on tool usage events
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 58.8k
- Forks
- 8.5k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 109
Description
Feature Area
Core functionality
Is your feature request related to a an existing bug? Please link it here.
N/A
Describe the solution you'd like
Add an optional call_id: str | None = None field to ToolUsageEvent (crewai/events/types/tool_usage_events.py), populated at the emit sites in _execute_single_native_tool_call.
CrewAI already has the value. _parse_native_tool_call sets call_id = getattr(tool_call, "id", f"call_{id(tool_call)}") (agents/crew_agent_executor.py:835), and it's threaded through _execute_single_native_tool_call(call_id=...) into the assistant/tool messages, so message history pairs correctly. It's a parameter of the very function that emits ToolUsageStartedEvent / ToolUsageFinishedEvent — already in scope, no plumbing needed.
Today those events carry tool_name, tool_args, agent and task ids, but no call id, so no observability consumer can attribute a tool execution to the model request that asked for it.
Describe alternatives you've considered
- Wrapping BaseTool.run (what OpenLIT and Arize OpenInference do): the id isn't in scope there, so it can't be recovered.
- Reconstructing from message history: the tool_call_id does survive into messages, but only post-hoc — an instrumentor needs it at span creation, not after the run.
- Pairing by ordering: ambiguous under max_usage_count retries and the parallel batch path in
_handle_native_tool_calls.
Adding the field is the smallest change that makes any of this work.
Additional context
Observability. The OTel GenAI semantic conventions list gen_ai.tool.call.id on the execute_tool span as Recommended "If available", described as "The tool call identifier." Because CrewAI doesn't surface it, no CrewAI instrumentor can populate it, and teams doing trace-based auditing lose the ability to attribute a tool execution to the specific model request that asked for it.
Verified against crewai 1.15.18.
Willingness to Contribute
Yes, I'd be happy to submit a pull request
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crewai/events/types/tool_usage_events.py to inspect ToolUsageEvent, then trace the emit sites in _execute_single_native_tool_call in agents/crew_agent_executor.py. Add the optional call_id field and ensure the existing native tool call id reaches both started and finished events; done means observability consumers can identify the originating model tool call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend-api-design
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100