Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Usage Visibility for Anthropic and OpenAI when using agent-workflow #2207

Description

@bipulsimkhada-cr

1. Anthropic (Streaming)

When using agent-workflow with Anthropic and stream = true, the usage info is filtered out from the chunk.
The usage info is of type "message-delta", and the chunk is not yielded in the code below:

🔗 LlamaIndexTS Anthropic LLM Code

Example payload:

{
  "type": "message_delta",
  "delta": {
    "stop_reason": "end_turn",
    "stop_sequence": null
  },
  "usage": {
    "input_tokens": 8,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 12
  }
}

2. Anthropic and OpenAI (Non-Streaming)

When running with agent.run, it is returning the finalEvent.
However, the finalEvent does not have usage info applicable.
https://github.com/run-llama/LlamaIndexTS/blob/main/packages/workflow/src/agent/agent-workflow.ts#L470-L476


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions