You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ownsCompaction tool-result context guard bypass still present in v2026.5.3 (Codex sessions have no mid-turn compaction protection) #77561
The ownsCompaction bypass is still present in v2026.5.3 (06d46f7). At selection-BgogoK8g.js:7163, the tool-result context guard is only installed when ownsCompaction !== true:
Since the Codex runtime sets ownsCompaction = true, Codex sessions get zero mid-turn compaction protection during tool loops. Additionally, shouldDisablePiAutoCompaction in pi-settings-Cj8yO4dX.js:95 disables Pi internal auto-compaction for these sessions.
Reproduction:
Run a heavy tool-loop (20+ sequential exec/API calls). Context overflows mid-loop. Compaction fires reactively but cannot keep up — tool results accumulate faster than compaction trims.
observedTokens=unknown — token estimation broken for Codex sessions
After 3 failed compaction attempts, session is restarted to a new file
Agent loses all active working context — returns with no memory of in-progress work
No graceful recovery; user has to re-explain what the agent was doing
Happened twice in 4 hours during normal heavy tool work
Expected behavior:
The tool-result context guard should be installed for ALL sessions regardless of ownsCompaction, or a forceCompactTranscriptBytes hard floor (as proposed in #71325) should fire when transcript size exceeds a threshold, bypassing the ownsCompaction flag.
Thanks for the context here. I did a careful shell check against current main, and this is already implemented.
Current main and shipped releases have the central guard-bypass fix: ownsCompaction engines now compose the context-engine loop hook with the generic tool-result context guard, and the preflight path uses LLM-boundary/unwindowed pressure so tool-heavy Codex sessions compact before provider overflow.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the shipped #85541 implementation for this specific guard bypass; broader context-budget and compaction-observability work can continue in their separate open issues.
Do we have a high-confidence way to reproduce the issue?
Yes for the historical bug: the report's old v2026.5.3 guard condition matches the predecessor discussion, and #85541 includes saved-session proof plus regression tests for the same tool-heavy/ownsCompaction pressure path. Current main no longer reproduces the bypass because the guard is installed in both ownsCompaction and non-ownsCompaction branches.
Is this the best way to solve the issue?
Yes. The current solution is the maintainable fix because it preserves context-engine compaction ownership while adding a host-side tool-result guard and provider-boundary pressure check before Codex submits oversized prompts.
Security review:
Security review: This is an issue cleanup review with no proposed patch to inspect for security or supply-chain risk.
AGENTS.md: found and applied where relevant.
What I checked:
Current source installs the guard for ownsCompaction engines: The current attempt wiring enters the ownsCompaction branch, installs the context-engine loop hook, then also installs installToolResultContextGuard before composing both removers; the non-ownsCompaction branch still installs the same guard. (src/agents/embedded-agent-runner/run/attempt.ts:2530, 6134c00657a2)
Current preflight uses provider-boundary pressure: shouldPreemptivelyCompactBeforePrompt accepts rendered LLM-boundary pressure, falls back to transcript estimates, and also considers an unwindowed transcript estimate when context-engine windowing hides larger history. (src/agents/embedded-agent-runner/run/preemptive-compaction.ts:263, 6134c00657a2)
Fix provenance from merged PR: Merged PR Fix context pressure preflight for tool-heavy sessions #85541 is titled 'Fix context pressure preflight for tool-heavy sessions' and its merge commit changed the preemptive compaction path, tool-result guard tests, Codex app-server run attempt, and SDK export surface. (c08400ea7d5d)
fuller-stack-dev: Authored the first commit in the merged fix PR that added tool-payload pressure estimation and ownsCompaction guard composition for this issue class. (role: fix author; confidence: high; commits: 2962db32fea7, c08400ea7d5d; files: src/agents/embedded-agent-runner/run/preemptive-compaction.ts, src/agents/embedded-agent-runner/run/attempt.ts, src/agents/embedded-agent-runner/tool-result-context-guard.test.ts)
joshavant: Added the provider-boundary Codex rendered preflight follow-up in the merged PR and supplied maintainer-facing proof tying the old path to live context_length_exceeded behavior. (role: follow-up fix author and area reviewer; confidence: high; commits: f1196461d388, c08400ea7d5d; files: extensions/codex/src/app-server/run-attempt.ts, src/agents/embedded-agent-runner/run/preemptive-compaction.ts, src/plugin-sdk/agent-harness-runtime.ts)
steipete: Authored the earlier safeguard repair commit for the linked predecessor issue and is therefore relevant for context-engine compaction routing history, though the later fix superseded that narrower repair. (role: prior compaction-safeguard contributor; confidence: medium; commits: 41f9768cd8de; files: src/agents/embedded-agent-runner/run/attempt.ts, src/agents/embedded-agent-runner/run/preemptive-compaction.ts)
Activity
clawsweeper commentedon May 4, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main and shipped releases have the central guard-bypass fix: ownsCompaction engines now compose the context-engine loop hook with the generic tool-result context guard, and the preflight path uses LLM-boundary/unwindowed pressure so tool-heavy Codex sessions compact before provider overflow.
I found the merged PR that appears to have closed this: #85541: Fix context pressure preflight for tool-heavy sessions.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the shipped #85541 implementation for this specific guard bypass; broader context-budget and compaction-observability work can continue in their separate open issues.
Do we have a high-confidence way to reproduce the issue?
Yes for the historical bug: the report's old v2026.5.3 guard condition matches the predecessor discussion, and #85541 includes saved-session proof plus regression tests for the same tool-heavy/ownsCompaction pressure path. Current main no longer reproduces the bypass because the guard is installed in both ownsCompaction and non-ownsCompaction branches.
Is this the best way to solve the issue?
Yes. The current solution is the maintainable fix because it preserves context-engine compaction ownership while adding a host-side tool-result guard and provider-boundary pressure check before Codex submits oversized prompts.
Security review:
Security review: This is an issue cleanup review with no proposed patch to inspect for security or supply-chain risk.
AGENTS.md: found and applied where relevant.
What I checked:
src/agents/embedded-agent-runner/run/attempt.ts:2530, 6134c00657a2)src/agents/embedded-agent-runner/tool-result-context-guard.ts:503, 6134c00657a2)src/agents/embedded-agent-runner/run/preemptive-compaction.ts:263, 6134c00657a2)src/agents/embedded-agent-runner/tool-result-context-guard.test.ts:594, 6134c00657a2)Likely related people:
src/agents/embedded-agent-runner/run/preemptive-compaction.ts,src/agents/embedded-agent-runner/run/attempt.ts,src/agents/embedded-agent-runner/tool-result-context-guard.test.ts)extensions/codex/src/app-server/run-attempt.ts,src/agents/embedded-agent-runner/run/preemptive-compaction.ts,src/plugin-sdk/agent-harness-runtime.ts)src/agents/embedded-agent-runner/run/attempt.ts,src/agents/embedded-agent-runner/run/preemptive-compaction.ts)Codex review notes: model internal, reasoning high; reviewed against 6134c00657a2; fix evidence: merged PR #85541, release v2026.5.22-beta.1, commit c08400ea7d5d.
openclaw-barnacle commentedon May 31, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.