pi-mono/packages
robopipi[bot] d3398f826a
fix(ai): detect LiteLLM ContextWindowExceededError as context overflow (#11494)
LiteLLM's pre-call context check rejects requests that are too large
with HTTP 400 and a message like:

```
litellm.ContextWindowExceededError: litellm.BadRequestError: litellm._pre_call_checks: Context Window exceeded for given call. ... Max Input Tokens=262144, Got=265262 ...
```

None of the `OVERFLOW_PATTERNS` matched this wording, so
`isContextOverflow()` returned false. As a result, the agent session
never ran overflow compaction and retry, and the turn failed with the
400 error.

This change adds `/context window exceeded/i` to `OVERFLOW_PATTERNS` and
documents the error in the doc comment that lists providers.

Testing:
- Added a regression test in `packages/ai/test/overflow.test.ts` with
the exact error message from the issue. It fails without the pattern and
passes with it.
- `node ../../node_modules/vitest/dist/cli.js --run
test/overflow.test.ts` in `packages/ai`: 32 passed.
- `npm run check` passes.
- Running `isContextOverflow()` directly on the reported message
returned `false` before this change and returns `true` after it.

Fixes #11492

Requested by @rwachtler

Co-authored-by: triagent <triagent@localhost>
2026-10-27 20:27:30 +01:00
..
agent fix(ai,chord,durable,coding-agent): parse streamed tool-call arguments incrementally (fixes #9265) 2026-10-24 08:00:07 +00:00
ai fix(ai): detect LiteLLM ContextWindowExceededError as context overflow (#11494) 2026-10-27 20:27:30 +01:00
chord fix(chord): bound the Node SQLite driver's prepared-statement cache 2026-10-27 11:28:28 +00:00
codemode fix: update deps for security advisories 2026-10-22 11:24:50 +02:00
coding-agent docs(coding-agent): update llama.cpp setup for llama.app (#10179) 2026-10-27 16:21:37 +01:00
durable fix(durable): end restart loops visibly; a host death charges a generation's attempt 2026-10-27 16:57:59 +00:00
env fix(env): include stderr in pi-env startup errors (#10716) 2026-10-27 16:16:49 +01:00
evals fix(evals): drop autoevals dependency 2026-10-22 23:32:38 +02:00
mcp fix(ai,chord,durable,coding-agent): parse streamed tool-call arguments incrementally (fixes #9265) 2026-10-24 08:00:07 +00:00
telemetry fix(ai): resolve pi-telemetry from source in workspace tests 2026-10-26 21:05:54 +00:00
tui fix(tui): fall back to raw LaTeX when display math is wider than the content width (#11487) 2026-10-27 16:09:08 +01:00