run-llama/LlamaIndexTS

Usage Visibility for Anthropic and OpenAI when using agent-workflow

Aperta

#2207 aperta il 18 set 2025

 (2 commenti) (0 reazioni) (0 assegnatari)TypeScript (524 fork)auto 404
buggood first issuehelp wanted

Metriche repository

Star
 (3078 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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


Guida contributor