Skip to content

Title: OOC detection misclassifies provider rate-limit ("too many tokens ... Please wait a moment before retrying") as context overflow → recovery permanently halted #46

Open

Description

@szwedoman

Plugin version: opencode-auto-resume 1.1.20
opencode version: 1.19.0
Provider: Codix (openai-compatible endpoint)

Summary

When the provider returns a rate-limit / throttling error whose message contains
"too many tokens", the plugin treats it as an out-of-context (OOC) error,
latches oocLocked=true and halts all recovery, leaving the session frozen
forever (continue prompts are refused) until the user sends a new message.

Triggering error (from logs)

AI_APICallError: You have sent too many tokens to CodiX in a short period.
Please wait a moment before retrying.

Observed behaviour (log excerpt, session ...i6ouNvBl)

... - stream error ... error.error="AI_APICallError: You have sent too many tokens to CodiX in a short period. Please wait a moment before retrying."
... - Streaming failure detected on ...i6ouNvBl: errorName=ContextOverflowError, ...
... - OOC error latched, halting recovery (reason: You have sent too many tokens to CodiX in a short period. Please wait a moment before retrying.)
... - Pending recovery triggered on ...i6ouNvBl: reason=ContextOverflowError, attempt=1, maxRetries=3
After this the session only logs user recently active, skipping periodic open-todos nudge
forever — sendContinuePrompt() refuses because of oocLocked.

Root cause

OOC_ERROR_RE in dist/index.js includes the bare pattern too many tokens:

var OOC_ERROR_RE = /exceeds the available context size|context size \(\d+\)|too large to compact|too many tokens|prompt is too long/i;

This matches the rate-limit message "You have sent too many tokens ..." and
the OOC latch (if (!w.oocLocked && OOC_ERROR_RE.test(...))) then blocks
sendContinuePrompt() (oocLocked latched, refusing further continue prompts).
Note: the same message also triggers isStreamingFailure via the broad
"too many tokens" pattern, but the OOC latch is independent of that check
and cannot be disabled by any config option (the regex is a hardcoded constant).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions