AgentOS not capturing metrics from workflow running inside a tool

Hello @agnoteam

Hi everyone,

I’m running into an issue where AgentOS is not capturing the token metrics from a workflow that runs inside a custom tool.

My Setup

I have a Team with a custom async tool that internally runs a Workflow:

@tool
async def process_documents(
    run_input: RunInput,
    run_context: RunContext,
) -> AsyncGenerator[Any, Any]:
    
    workflow = my_workflow()
    
    async for event in workflow.arun(
        input=run_input.input_content,
        session_state=run_context.session_state,
        session_id=run_context.session_id,
        stream=True,
        stream_events=True,
    ):
        yield event
my_team = Team(
    name="Document Processing Team",
    tools=[process_documents],
    # ... other config
)

The Problem

When I print the metrics from the workflow events, I see the actual token usage:

{'input_tokens': 4201, 'output_tokens': 2288, 'total_tokens': 6489}
{'input_tokens': 4034, 'output_tokens': 2137, 'total_tokens': 6171}
{'input_tokens': 3720, 'output_tokens': 1142, 'total_tokens': 4862}

But in AgentOS, I only see:

Input Tokens: 4,960
Output Tokens: 145
Total Tokens: 5,105

AgentOS is only tracking the outer Team’s metrics and completely missing the ~17,500 tokens consumed by the inner workflow agents.

Questions

  1. Is there a way to have nested workflow metrics automatically propagate to AgentOS?

  2. Would using WorkflowTools instead of a custom tool solve this?

  3. Is this a known limitation or am I missing something?

This is important for tracking actual token usage and costs. Any help appreciated!

Thanks!

Hi @raphael.rodrigues, thank you for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all queries one by one and will get back to you soon. If it’s urgent, please let us know. We appreciate your patience!