-
-
Notifications
You must be signed in to change notification settings - Fork 52.9k
Description
Summary
When context overflow occurs and auto-compaction cannot recover (reason: "nothing to compact"), runEmbeddedPiAgent currently hard-fails even if fallback models are configured.
This prevents the fallback chain from doing its job in a common failure mode (request too large for current model).
Current behavior
- Model returns context/window overflow (e.g. 413 /
request_too_large) - Auto-compaction runs and fails to reduce enough context
- Runner throws a normal error path and exits
- No fallback model attempt is made
Expected behavior
If fallback models are configured, the runner should escalate this failure as a FailoverError so the outer loop can try the next fallback model/profile.
Why this matters
Fallback chains are specifically meant to recover from model-specific constraints (including context window limits). Hard-failing here defeats reliability for long-running sessions.
Proposed fix
In the overflow/compaction-failure branch in src/agents/pi-embedded-runner/run.ts:
- Build a user-facing overflow message
- If
fallbackConfigured, throwFailoverErrorwith:status: 413code: "context_overflow" | "compaction_failure"provider,model,profileId
- Keep existing non-fallback behavior unchanged
Also add coverage in src/agents/pi-embedded-runner/run.overflow-compaction.test.ts:
- Assert
FailoverErroris thrown when compaction fails and fallback is configured.
Version
Observed on OpenClaw v2026.2.15 with local reliability patches.