Repository navigation
Description
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:
- Auto-compaction succeeds and the logical channel session continues with a smaller context.
/compactsucceeds manually./newcreates a clean small session for the channel.- 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.5with 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:
- Why compaction returns
provider_error_4xxwithout a recoverable fallback path. - Why
/newor channel recovery can leave the channel bound to a huge/failed lane. - Why a Discord channel session can show
gpt-5.4despite config defaultcodex/gpt-5.5andfallbacks: []. - Whether scheduled/reminder/session-targeted items can pin or recreate a channel session using stale model/runtime metadata.
- Whether OpenClaw should automatically preserve transcript + rotate the channel when compaction is unrecoverable, instead of repeatedly returning the same error.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 5, 2026
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
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
/newcreates 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:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 5cf63f295b90.
Label changes
Label changes:
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/newrecovery attempts.impact:auth-provider: The report includes model/provider routing drift from configuredcodex/gpt-5.5tocodex/gpt-5.4despite empty fallbacks.issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.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/newrecovery attempts.impact:auth-provider: The report includes model/provider routing drift from configuredcodex/gpt-5.5tocodex/gpt-5.4despite empty fallbacks.Evidence reviewed
Acceptance criteria:
/compact,/new, and a follow-up message use the configuredcodex/gpt-5.5route.initSessionState, compaction failure recovery text/state, and cronsession:<key>model metadata so stale runtime model fields cannot pin a reset channel.../codexsource as the dependency contract for manual compaction and remote compaction failure handling.What I checked:
provider_error_4xx, session JSON showingtotalTokensnear the reported context window, and model drift from configuredcodex/gpt-5.5tocodex/gpt-5.4./compact, or/new; that is not proof that the unrecoverable lane is automatically rotated. (src/auto-reply/reply/agent-runner-execution.ts:1221, 5cf63f295b90)src/auto-reply/reply/agent-runner-execution.ts:702, 5cf63f295b90)/newand/resetnow 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)src/config/sessions/reset-preserved-selection.ts:15, 5cf63f295b90)/newand/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:
git blameandgit logtie 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 re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Morphious12345 commentedon Jun 7, 2026
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.
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."