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_windowon a completed response, or a length stop with no output and a full window. Acontext_windowof 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_outputis 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.