MaxTokens
A dataclass to be used on spawning an agent or decorating an agentic function to control the maximum number of output tokens generated by the underlying model.
The maximum number of output tokens generated over all rounds of inference in a single invocation.Defaults to
None meaning unlimited.The maximum number of output tokens generated in a single round of inference in a single invocation.Defaults to
None meaning unlimited.The maximum number of rounds of inference in a single invocation.Defaults to
None meaning unlimited.Usage
A dataclass outlining the token usage of the underlying model of an agent or agentic function.
The number of input tokens consumed by the model.
The number of output tokens consequently generated by the model.
The total number of tokens processed, not double-counting generated then re-consumed tokens.
total_usage
A function to obtain the total token usage of an agent or agentic function accross all invocations.
The number of input tokens consumed by the model.
The token usage accross all invocations of the agent or agentic function.
last_usage
A function to obtain the token usage of an agent or agentic function for the last invocation.
The number of input tokens consumed by the model.
The token usage of the last invocation of the agent or agentic function.