Skip to content

OpenRouter/Poolside "exceeds the maximum allowed input length" error not detected as context overflow #4943

@elecnix

Description

@elecnix

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

  1. Use poolside/laguna-m.1:free via OpenRouter
  2. Accumulate context until it exceeds 131,072 tokens
  3. 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

Metadata

Metadata

Assignees

Labels

inprogressIssue is being worked on

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions