Skip to content

models_usage shows prompt_tokens and completion_tokens as 0 #6548

Description

@quantexperts

What happened?

Describe the bug
I was previously using v0.5.1 and sometime over the last few weeks, I had upgraded to v0.5.6. I was checking the history data and noticed that the prompt_tokens and completion_tokens under models_usage are coming as 0.
I remember they used to report token count but I can only see zero.

To Reproduce

response = await agent.on_messages(
	messages=[request], 
	cancellation_token=CancellationToken()
)
print('>>>>', response.chat_message.json())

Expected behavior
Expecting token usage counts

Screenshots
I see output like: {"source":"assistant","models_usage":{"prompt_tokens":0,"completion_tokens":0},"metadata":{},"content":"Hello! How can I assist you today?","type":"TextMessage"}

Which packages was the bug in?

Python Core (autogen-core)

AutoGen library version.

Python 0.5.6

Other library version.

No response

Model used

gpt-4o-mini, gemini-2.0-flash

Model provider

OpenAI

Other model provider

Gemini

Python version

3.12

.NET version

None

Operating system

None

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions