agno
agno copied to clipboard
[Feature Request] RunContext does not have tool_call_id
Problem Description
When tools yield CustomEvent objects, there's currently no way to access the tool_call_id within the tool function to include it in the event. This makes it impossible to correlate CustomEvent with their corresponding ToolCallStart events, especially when the model calls multiple tools in parallel.
Proposed Solution
Add tool_call_id as a built-in parameter to RunContext, similar to existing parameters like session_state, dependencies, and metadata.
Suggested implementation:
from agno.run import RunContext
from agno.run.agent import CustomEvent
from agno.tools import tool
from dataclasses import dataclass
@dataclass
class MyCustomEvent(CustomEvent):
tool_call_id: str
progress: str
@tool
async def my_tool(run_context: RunContext):
# Access tool_call_id directly from run_context
tool_call_id = run_context.tool_call_id
yield MyCustomEvent(
tool_call_id=tool_call_id,
progress="Processing..."
)
### Alternatives Considered
_No response_
### Additional Context
_No response_
### Would you like to work on this?
- [x] Yes, I’d love to work on it!
- [ ] I’m open to collaborating but need guidance.
- [ ] No, I’m just sharing the idea.
RunContext should give more to functions, sometimes function need to read run_messages!