Skip to content

runcontext has no token count in history processor #2989

@jcaplan

Description

@jcaplan

Initial Checks

Description

trying to generate a summary based on token count instead of number of messages. I can see the token count for each message but the ctx.usage.total_tokens is always 0.

> history.py(57)summary_processor()
(Pdb) p ctx.usage.total_tokens
0
(Pdb) p messages[1].usage
RequestUsage(input_tokens=24, output_tokens=11, details={'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0})

Example Code

Python, Pydantic AI & LLM client version

pydantic-ai==1.0.10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions