run-llama/LlamaIndexTS

Usage Visibility for Anthropic and OpenAI when using agent-workflow

オープン

#2,207 opened on 2025/09/18

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (524 件のフォーク)auto 404
buggood first issuehelp wanted

Repository metrics

Stars
 (3,078 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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


コントリビューターガイド