Skip to content

Overflow classifier: non-overflow guard patterns + behavioral detectors #414

Description

@justrach

From the prime-agent analysis (their overflow.ts: 20 provider regexes, a NON_OVERFLOW guard list, and two behavioral detectors).

Proposal for graff's context-overflow classification (#193 arc, recoverContextOverflow):

  1. Non-overflow guards checked first: e.g. Bedrock's ThrottlingException: Too many tokens is rate limiting, not context overflow — naive keyword matching misclassifies it and triggers a pointless compaction instead of a retry wait.
  2. Behavioral detectors:
    • silent overflow: HTTP 200 with an empty/failed completion whose usage shows input at/over the context window (seen on z.ai);
    • upstream truncation: finish_reason: length with truncated output when input is near the window (seen on MiMo).

Notes: guards keep the retry/Retry-After path (where graff is already strong) from being shadowed by overflow recovery.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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