Skip to content

Fix token calculation metadata in CoT agent strategy #1564

@laipz8200

Description

@laipz8200

Self Checks

✅ This is only for bug report
✅ I have searched for existing issues
✅ I confirm that I am using English to submit this report
✅ Please do not modify this template

Dify version

Latest

Plugin version

0.0.23

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

When using the CoT (Chain of Thought) agent strategy with function calling, the execution metadata returned to the client incorrectly formats token usage information. The current implementation only includes partial metadata fields, missing important token calculation details that are needed for proper usage tracking and billing.

✔️ Error log

No explicit error occurs, but the execution metadata lacks complete token usage information including:

  • prompt_tokens
  • prompt_unit_price
  • prompt_price_unit
  • prompt_price
  • completion_tokens
  • completion_unit_price
  • completion_price_unit
  • completion_price
  • latency

This results in incomplete token usage tracking for agents using the function calling strategy.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions