Skip to content

Discord channel remains trapped in oversized session after /new; compaction fails provider_error_4xx and model drifts from codex/gpt-5.5 to gpt-5.4 #90496

Closed

Description

@nguyenjustin214-lab

Summary

A Discord channel can get trapped in an oversized session where every normal message returns:

Context is too large and auto-compaction could not recover this turn. Try again, use /compact, or use /new to start a fresh session.

This persists even after light follow-up messages and after attempting to recover with /new/manual compaction. The channel continues to bind to a very large session, compaction repeatedly fails with provider_error_4xx, and the active channel session can show gpt-5.4 even though global/default config is pinned to codex/gpt-5.5 with no fallbacks.

Environment

OpenClaw 2026.6.1 (2e08f0f)
macOS 26.3.1 arm64
Node 25.5.0
Gateway app 2026.6.1
Discord channel plugin enabled and Discord status OK

Config/model policy:

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "codex/gpt-5.5",
        "fallbacks": []
      }
    }
  }
}

Configured subagents were also set back to codex/gpt-5.5 with fallbacks: [] after the 2026.6.1 update migrated them to openai/gpt-5.5.

openclaw models list shows:

codex/gpt-5.5 default,configured auth yes
openai/gpt-5.5 configured auth no
openai/gpt-5.4 configured auth no

Expected behavior

One of these should happen when a Discord channel session gets too large:

  1. Auto-compaction succeeds and the logical channel session continues with a smaller context.
  2. /compact succeeds manually.
  3. /new creates a clean small session for the channel.
  4. If compaction cannot succeed, OpenClaw should preserve transcript/state and rotate safely, or at least stop rebinding the channel to the same unrecoverable oversized lane.

The channel should also respect the configured default route codex/gpt-5.5 and should not drift to gpt-5.4 when no fallback is configured.

Actual behavior

The Discord #main channel repeatedly returns the context-too-large error even for simple messages like a product question or “Hello”.

The session remains large/over budget and compaction fails repeatedly:

[compaction-diag] end runId=58d36597-52c3-476a-954d-e01561f23d58 sessionKey=agent:main:discord:channel:1488013357016420522 diagId=cmp-mq00oayd-3WEMIw trigger=budget provider=codex/gpt-5.5 attempt=1 maxAttempts=1 outcome=failed reason=provider_error_4xx durationMs=427
[compaction-diag] end runId=58d36597-52c3-476a-954d-e01561f23d58 sessionKey=agent:main:discord:channel:1488013357016420522 diagId=cmp-mq05by5r-Cc9sYA trigger=budget provider=codex/gpt-5.5 attempt=1 maxAttempts=1 outcome=failed reason=provider_error_4xx durationMs=337
[compaction-diag] end runId=58d36597-52c3-476a-954d-e01561f23d58 sessionKey=agent:main:discord:channel:1488013357016420522 diagId=cmp-mq07oeww-J67I_w trigger=budget provider=codex/gpt-5.5 attempt=1 maxAttempts=1 outcome=failed reason=provider_error_4xx durationMs=367

Live session inspection showed this channel bound to an oversized/near-overlimit session:

{
  "key": "agent:main:discord:channel:1488013357016420522",
  "sessionId": "58d36597-52c3-476a-954d-e01561f23d58",
  "modelProvider": "codex",
  "model": "gpt-5.4",
  "totalTokens": 231980,
  "contextTokens": 272000,
  "totalTokensFresh": true
}

After further attempted recovery, the channel showed a new session id but still gpt-5.4 and not a clean/small 5.5 lane:

{
  "key": "agent:main:discord:channel:1488013357016420522",
  "sessionId": "f79787f0-a5ba-4d64-9d34-f2a69e6d69c3",
  "modelProvider": "codex",
  "model": "gpt-5.4",
  "totalTokens": null,
  "contextTokens": 200000,
  "totalTokensFresh": false
}

There was also an idle scheduled/reminder-style item targeting the same channel session with codex/gpt-5.4 while the rest of GPT cron routes were codex/gpt-5.5:

acba74a9-f602-4e93-b350-b740dcea0106 Pick up animal poop ... idle session:agent:main:discord:channel:1488013357016420522 ... main codex/gpt-5.4

User-visible impact

The Discord channel becomes effectively unusable. Every normal message returns the same context-too-large warning. Manual /compact produces no usable recovery. /new/recovery behavior does not reliably create a clean, small, configured-model continuation.

Notes

  • Gateway and Discord health were otherwise OK.
  • Config validation passed.
  • Global default route was codex/gpt-5.5 with no fallbacks.
  • The system intentionally avoids direct OpenAI API routing; openai/gpt-* entries are configured compatibility entries but auth is not available and should not be active defaults.
  • This bug report omits private Discord content and tokens.

Ask

Please investigate:

  1. Why compaction returns provider_error_4xx without a recoverable fallback path.
  2. Why /new or channel recovery can leave the channel bound to a huge/failed lane.
  3. Why a Discord channel session can show gpt-5.4 despite config default codex/gpt-5.5 and fallbacks: [].
  4. Whether scheduled/reminder/session-targeted items can pin or recreate a channel session using stale model/runtime metadata.
  5. Whether OpenClaw should automatically preserve transcript + rotate the channel when compaction is unrecoverable, instead of repeatedly returning the same error.

Activity

  1. clawsweeper commented on Jun 5, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 4, 2026, 9:07 PM ET / 01:07 UTC.

    Summary
    Keep open: the report is recent, concrete, and current main only covers parts of the reset/model cleanup path; it does not prove recovery from unrecoverable Codex compaction, stale scheduled-session binding, or Discord channel model drift back to the configured default.

    Reproducibility: no. high-confidence live reproduction was established in this read-only pass. The issue provides concrete diagnostics and current source has matching compaction-failure, reset, and persistent session-target paths that make the report source-reproducible enough to keep open.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    The report is actionable but spans Discord channel recovery, Codex compaction, session reset semantics, scheduled jobs, and model routing, with a product decision around automatic rotation.

    Review details

    Best possible solution:

    Investigate the session-state invariant across Discord reset, Codex compaction failure, and scheduled turns so /new creates a clean configured-model continuation while any automatic rotate/preserve behavior remains an explicit product choice.

    Do we have a high-confidence way to reproduce the issue?

    No high-confidence live reproduction was established in this read-only pass. The issue provides concrete diagnostics and current source has matching compaction-failure, reset, and persistent session-target paths that make the report source-reproducible enough to keep open.

    Is this the best way to solve the issue?

    No, current main is not a complete solution: it clears some auto-sourced reset overrides, but it does not prove clean recovery from failed Codex compaction or stale scheduled/session model metadata. The best fix should first isolate the stale binding path before adding automatic rotation policy.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No live Discord/Codex reproduction was run in this read-only review, so the exact root cause could be split across compaction, reset state, and scheduled-session binding.
    • Automatically preserving transcript and rotating away from an unrecoverable compaction lane is a user-visible policy change and should be decided explicitly before implementation.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 5cf63f295b90.

    Label changes

    Label changes:

    • add P1: The reported Discord channel becomes unusable for normal messages after an oversized-session failure, affecting a real channel workflow now.
    • add impact:message-loss: Normal Discord messages receive only the context-too-large warning instead of agent answers while the channel remains trapped.
    • add impact:session-state: The core symptom is stale or oversized session binding after compaction and /new recovery attempts.
    • add impact:auth-provider: The report includes model/provider routing drift from configured codex/gpt-5.5 to codex/gpt-5.4 despite empty fallbacks.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.
    • add clawsweeper:needs-product-decision: Current issue advisory state selects this label.

    Label justifications:

    • P1: The reported Discord channel becomes unusable for normal messages after an oversized-session failure, affecting a real channel workflow now.
    • impact:message-loss: Normal Discord messages receive only the context-too-large warning instead of agent answers while the channel remains trapped.
    • impact:session-state: The core symptom is stale or oversized session binding after compaction and /new recovery attempts.
    • impact:auth-provider: The report includes model/provider routing drift from configured codex/gpt-5.5 to codex/gpt-5.4 despite empty fallbacks.
    Evidence reviewed

    Acceptance criteria:

    • Reproduce with a Discord channel bound to an oversized Codex app-server session where preflight compaction returns a provider 4xx, then verify /compact, /new, and a follow-up message use the configured codex/gpt-5.5 route.
    • Add or update focused tests around initSessionState, compaction failure recovery text/state, and cron session:<key> model metadata so stale runtime model fields cannot pin a reset channel.
    • Use Codex app-server behavior from the sibling ../codex source as the dependency contract for manual compaction and remote compaction failure handling.

    What I checked:

    • Issue evidence: The issue body includes concrete OpenClaw 2026.6.1 environment data, compaction diagnostics with provider_error_4xx, session JSON showing totalTokens near the reported context window, and model drift from configured codex/gpt-5.5 to codex/gpt-5.4.
    • Current failure copy preserves mapping: Current main still tells users that failed auto-compaction kept the conversation mapped to the current session and recommends retrying, /compact, or /new; that is not proof that the unrecoverable lane is automatically rotated. (src/auto-reply/reply/agent-runner-execution.ts:1221, 5cf63f295b90)
    • Preflight compaction failure remains user-visible: The preflight compaction failure path formats the exact context-too-large recovery text reported by the issue rather than rotating or repairing the session itself. (src/auto-reply/reply/agent-runner-execution.ts:702, 5cf63f295b90)
    • /new has partial reset protection: /new and /reset now create a new session id and clear auto-sourced model/auth overrides, but the issue also reports stale runtime model fields and scheduler/session-target behavior that this path alone does not close out. (src/auto-reply/reply/session.ts:514, 5cf63f295b90)
    • Reset selection helper is partial: The reset helper preserves user overrides and clears auto fallback provenance, but legacy entries without provenance may still be treated as user-driven selections. (src/config/sessions/reset-preserved-selection.ts:15, 5cf63f295b90)
    • Existing tests cover only the partial reset case: Focused tests assert auto-sourced overrides are cleared on /new and /reset; they do not cover the reported Discord oversized-session plus scheduled-turn model-pinning scenario. (src/auto-reply/reply/session.test.ts:2482, 5cf63f295b90)

    Likely related people:

    • Peter Steinberger: git blame and git log tie the central compaction, session reset, scheduler, cron, and reset-preservation code currently in main to the same recent commit; history is grafted/squashed, so this is a routing signal rather than blame. (role: recent area contributor; confidence: medium; commits: a628a66e4d1e; files: src/auto-reply/reply/agent-runner-execution.ts, src/auto-reply/reply/session.ts, src/config/sessions/reset-preserved-selection.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jun 5, 2026
  3. Morphious12345 commented on Jun 7, 2026

    @Morphious12345

    I am having same exact issue in WebUI chat, even after /compact or /new I get "⚠️ Context is too large and auto-compaction could not recover this turn. Try again, use /compact, or use /new to start a fresh session"

    This is a new issue since v2026.6.1. Have restarted gateway, cleared out Bloated Trajectory Files, restarted again,

    Still same issue, and it happens even in a new session after ~90K tokens in a 262K context window.

    Image

    SOLUTION, By removing Non Default Database from the contextEngine slot, OpenClaw's native built-in compaction will handle it properly instead of bouncing between "DB refuses" and "runtime fails."

  4. self-assigned this
    on Jun 9, 2026
  5. locked as resolved and limited conversation to collaborators on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions