Skip to main content

MaxTokens

A class 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.
export class MaxTokens {
    constructor(
        public perInvocation: number | null = null,
        public perRound: number | null = null,
        public rounds: number | null = null
    ) {}
}
Parameters
per_invocation
int | null
The maximum number of output tokens generated over all rounds of inference in a single invocation.Defaults to null meaning unlimited.
per_round
int | null
The maximum number of output tokens generated in a single round of inference in a single invocation.Defaults to null meaning unlimited.
rounds
int | null
The maximum number of rounds of inference in a single invocation.Defaults to null meaning unlimited.

Usage

A class outlining the token usage of the underlying model of an agent or agentic function.
export class Usage {
    /**
     * NOTE: `totalTokens` = `inputTokens` + `outputTokens`
     */
    constructor(
        public readonly inputTokens: number,
        public readonly outputTokens: number,
        public readonly totalTokens: number
    ) {}
}
Parameters
inputTokens
number
The number of input tokens consumed by the model.
outputTokens
number
The number of output tokens consequently generated by the model.
totalTokens
number
The total number of tokens processed, not double-counting generated then re-consumed tokens.