Skip to content

Context overflow from opencode-go is misclassified, bypassing automatic compaction #4253

Closed

Description

@DoodleBears

Problem

A long-running Bot using DSH 0.2.2-rc.1 and the pi-ai opencode-go route stopped after repeated INVALID_REQUEST failures. The provider returned:

Input too long: model limit 1048576 tokens, requested 1123530 tokens

DSH's installed isContextWindowExceededError() returns false for this wording. The pi-ai adapter consequently reports INVALID_REQUEST; native compaction-basic only performs forced overflow recovery for CONTEXT_WINDOW_EXCEEDED. Repeating the request cannot shrink the history, so the Bot's consecutive-failure guard eventually holds it. Manual native compaction succeeded and the same Bot resumed responding.

Reproduction and expected result

Call isContextWindowExceededError() with the text above, including an OpenAI-compatible 400 invalid_request_error wrapper: expected true; observed false. Replay that response through the pi-ai HTTP adapter and a real Agent/compaction composition: expect a bounded compaction and successful retry, rather than repeated terminal INVALID_REQUEST failures.

Negative controls must preserve ordinary validation failures such as oversized non-token input and invalid parameter values.

Scope

Implement a Tobs-owned agent/request-error listener for this precise missed token-limit wording. Limit recovery to Tobs-owned Sessions, call the unmodified native compaction service, retry only after durable context progress, and bound the attempts. Do not modify DSH source, dependency bytes, classifier functions or native recovery methods. The earlier upstream fork PR is closed at the Human's instruction.

Automatic compaction was enabled and had succeeded previously. Idle compaction is an optimization requiring eligible idle time, not an unconditional overflow guard. The exact historical outbound payload was not captured; requested must not be described as prompt-only tokens.

The initial investigation also observed omitted catalog output caps in resolved model metadata. Current DSH tests explicitly distinguish catalog capabilities from configured request defaults. This PR must not change that contract without independent evidence and design review.

Activity

  1. DoodleBears commented on Nov 15, 2026

    @DoodleBears
    ContributorAuthor

    Agent work claim

    • Agent: Codex
    • Task: codex/local/01a1df5e-8b2e-7813-8ac8-7ad9abf7061b (not a DSH Session)
    • Issue scope: reproduce token-limit wording through the pi-ai adapter and native compaction; fix upstream classification without changing catalog output-cap semantics.
    • Branch: fix/4253-context-overflow-recovery (DSH upstream fork)
    • Started: 2026-11-16 UTC
    • State: active
  2. added
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Nov 15, 2026
  3. DoodleBears commented on Nov 15, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome

    • Task: codex/local/01a1df5e-8b2e-7813-8ac8-7ad9abf7061b
    • State: handed-off
    • Review PR: fix(llm): recover token-counted gateway context overflows DoodleBears/deepseek-harness#2
    • Head: c96eb3be18d5f1f3b78c425f473a4787784f9de5
    • Reproduced the original token-limit wording at the classifier, HTTP adapter and Loader-mounted Agent composition. Before the fix, the adapter returned INVALID_REQUEST and the Agent produced no compaction summary. After the fix, native compaction completes and the retry succeeds, without changing catalog output-cap semantics or recovery policy.
    • Checks: 179 focused tests; 100% classifier statement/branch/function/line coverage; full build 10/10; doc-sync 43/43; pre-push typecheck 5/5; focused lint and built classifier smoke passed. Two pre-existing Loader tests timed out during parallel build/doc work; the full Loader file passed afterward with unchanged timeouts.
    • Remaining: direct upstream PR creation was rejected by GitHub: DoodleBears does not have the correct permissions to execute CreatePullRequest. The fork PR uses a dedicated base ref pinned to upstream 39163dd30f703a79079e2d2446545cff3c453738, so reviewers see only this fix. An account allowed to submit upstream must complete that submission; upstream acceptance/release and VPS deployment remain outstanding. No production Host was changed.
  4. removed
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Nov 15, 2026
  5. DoodleBears commented on Nov 15, 2026

    @DoodleBears
    ContributorAuthor

    Agent work claim (Tobs-only scope)

    • Agent: Codex
    • Task: codex/local/01a1df5e-8b2e-7813-8ac8-7ad9abf7061b
    • Branch: codex/4253-tobs-context-recovery
    • State: active
    • Supersedes this task's upstream handoff: the Human requires Tobs-only changes. The DSH fork PR is closed. Implement bounded recovery through supported DSH events and compaction service calls, with unmodified DSH dependencies and before/after Host tests.
  6. added
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Nov 15, 2026
  7. DoodleBears commented on Nov 15, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome (Tobs-only)

    • Task: codex/local/01a1df5e-8b2e-7813-8ac8-7ad9abf7061b
    • State: handed-off
    • PR: fix(core): recover gateway context overflow on the Tobs side #4257
    • Head: 8f5791196634334778ef4551a1c19ca7ccb24794
    • The DSH fork PR remains closed. This implementation changes only Tobs and its verification tooling, using the public native isolated Preset compaction service.
    • Real isolated Host replay on DSH 0.2.2-rc.1: base 7e0ca0012 yielded one token-limit rejection, zero summary requests, no reply and INVALID_REQUEST. Fixed Tobs yielded one rejection, one summary and committed OVERFLOW_RECOVERED in the same Session. The HTTP model endpoint is a local fixture; DSH implementations are unmodified.
    • Validation: 89 related tests, build, TypeScript, lint, formatting, feature-map and bilingual changelog checks passed. Initial Windows lifecycle failures were rechecked successfully with sufficient process-cleanup time; full related rerun passed. The same-Session proof uses the public context query and canonical Channel message read.
    • Both verification Hosts exited, their ports were released and private evidence was retained. Production provider, QQ, visual/Human QA and VPS deployment remain untested by this replay. CI is running; no merge or deployment performed.
    • An exact-head Chinese HTML explainer was generated locally. It is not published or reviewer-accessible, and was not visually checked in a browser.
  8. removed
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Nov 15, 2026
  9. DoodleBears commented on Nov 15, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome

    • Task: codex/local/01a1df5e-8b2e-7813-8ac8-7ad9abf7061b
    • State: completed
    • PR: fix(core): recover gateway context overflow on the Tobs side #4257
    • Merged commit: 52c5544d08ea61bd99a1d5c89c701a83b4edd946
    • Latest head 0990d33 passed all applicable CI checks; all three review threads were resolved before squash merge.
    • Tobs-side recovery, native persistence checkpoint and exact Session replacement readback are merged. DSH implementations remain unchanged. Sanitized real Host replay evidence is retained in the PR discussion.
    • Task verification Hosts were stopped and their listeners released. VPS deployment, production-provider and QQ verification were not performed as part of this merge.
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions