Summary
When using Poolside models via OpenRouter (e.g., poolside/laguna-m.1:free), context overflow errors with the format:
"Input length 131393 exceeds the maximum allowed input length of 131040 tokens."
are not recognized, causing infinite retry loops instead of triggering auto-compaction.
Expected Behavior
Error should be recognized as context overflow and trigger compaction.
Actual Behavior
isContextOverflow() returns false (no matching pattern in OVERFLOW_PATTERNS)
- Error falls through to
_isRetryableError() which matches provider.?returned.?error
- 100 auto-retries occur without compaction
Root Cause
OVERFLOW_PATTERNS in packages/ai/src/utils/overflow.ts does not include a pattern for this Poolside-specific error format.
Existing patterns (none match):
/exceeds the context window/i — needs "context window" text
/maximum context length is \d+ tokens/i — expects "is X tokens" format
/exceeds (?:the )?(?:model\'?s )?maximum context length of [\d,]+ tokens?/i — expects "maximum context length of"
Proposed fix: Add to OVERFLOW_PATTERNS:
/exceeds the maximum allowed input length of \d+ tokens/i, // OpenRouter/Poolside variants
Reproduction
- Use
poolside/laguna-m.1:free via OpenRouter
- Accumulate context until it exceeds 131,072 tokens
- Send a prompt — observe retry loop instead of compaction
Provider Context
- Model:
poolside/laguna-m.1:free (131,072 token context window)
- Provider: OpenRouter (Poolside is a provider on OpenRouter)
- API: OpenAI-compatible completions
Summary
When using Poolside models via OpenRouter (e.g.,
poolside/laguna-m.1:free), context overflow errors with the format:are not recognized, causing infinite retry loops instead of triggering auto-compaction.
Expected Behavior
Error should be recognized as context overflow and trigger compaction.
Actual Behavior
isContextOverflow()returnsfalse(no matching pattern inOVERFLOW_PATTERNS)_isRetryableError()which matchesprovider.?returned.?errorRoot Cause
OVERFLOW_PATTERNSinpackages/ai/src/utils/overflow.tsdoes not include a pattern for this Poolside-specific error format.Existing patterns (none match):
/exceeds the context window/i— needs "context window" text/maximum context length is \d+ tokens/i— expects "is X tokens" format/exceeds (?:the )?(?:model\'?s )?maximum context length of [\d,]+ tokens?/i— expects "maximum context length of"Proposed fix: Add to
OVERFLOW_PATTERNS:Reproduction
poolside/laguna-m.1:freevia OpenRouterProvider Context
poolside/laguna-m.1:free(131,072 token context window)