Skip to main content

Module errors

Module errors 

Source
Expand description

Classifying failed responses: context overflow, recoverable truncation, and transient errors worth retrying.

Port of packages/ai/src/utils/overflow.ts and retry.ts in pi v1.0.0.

Constants§

DEFAULT_MAX_AGENT_RETRY_DELAY_MS
Default cap on one agent-level retry delay.

Functions§

is_context_overflow
Whether a response failed or was cut short because the input exceeded the context window: an overflow error text, input above context_window on a completed response, or a length stop with no output and a full window. A context_window of 0 checks the error text only.
is_recoverable_length
Whether a length stop ended below the intended output limit, so one compact-and-retry attempt may recover it. desired_max_output is the limit before any clamping to the context.
is_retryable_assistant_error
Whether a failed response is transient and worth retrying.
retry_delay_ms
The backoff before retry attempt (1-based): base * 2^(attempt-1), capped.