Skip to content

fix(codex): keep task lists active across compaction - #123921

Merged
fuller-stack-dev merged 4 commits into
mainfrom
fix/codex-plan-state-after-compaction
Aug 15, 2026
Merged

fuller-stack-dev merged 4 commits into
mainfrom
fix/codex-plan-state-after-compaction

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

What Problem This Solves

Codex-backed turns could leave the WebChat task list stuck at its initial state after automatic context compaction. OpenClaw retained the visible snapshot, but the continuing model turn no longer had the active structured plan, so it stopped emitting later progress snapshots.

Why This Change Was Made

The Codex app-server boundary now retains the latest valid plan event and restores that exact snapshot into the active thread through the official history-only thread/inject_items API after completed compaction.

The restoration:

  • covers native plans, direct OpenClaw update_plan calls, and nested code-mode tool calls;
  • preserves the exact statuses instead of inferring or synthesizing completion;
  • does nothing when no current plan exists; and
  • is best-effort, so an injection failure cannot break the active turn.

User Impact

Long-running Codex-backed sessions keep their active task list available to the model across compaction, allowing subsequent update_plan calls to keep the WebChat list current instead of leaving it at 0/N.

Evidence

  • Canonical-base regression: failed as expected because completed compaction emitted no thread/inject_items restoration request.
  • Exact-head focused regression and controls: 3/3 passed (restore latest plan, no-plan negative control, restoration-failure resilience).
  • Adjacent event-projector tests: 5/5 passed.
  • pnpm tsgo:prod, changed-file oxlint, formatting, and local autoreview passed; autoreview reported no findings.
  • The same red/green scenario passed on an isolated Linux Crabbox target with raw video evidence retained privately.
  • The broad Codex extension lane was attempted but its Vitest worker exited unexpectedly after about 16 minutes. Before exiting, it reported only two unrelated app-inventory/cache failures that also reproduce on the unmodified base; the affected tests pass independently.

An exact live WebChat green replay is not claimed: provider-triggered compaction inside an authenticated live turn is nondeterministic. The original real-session rollout remains the user-surface red occurrence; the deterministic owner-boundary test is the green regression proof.

AI-assisted: yes. The implementation, tests, source audit, and proof were reviewed by the author.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review August 15, 2026 01:49
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 14, 2026, 10:34 PM ET / August 15, 2026, 02:34 UTC.

ClawSweeper review

What this changes

The PR retains the latest Codex task plan and reinjects it after context compaction so later progress updates can keep the WebChat task list current.

Merge readiness

⛔ Blocked by patch quality or review findings - 7 items remain

Keep open: the updated payload cap still permits roughly 7K tokens of new model-visible text immediately after compaction, creating the context-pressure failure the fix is meant to avoid.

Priority: P2
Reviewed head: 8ebf199841cd1c8705149b0d35ea74147ed2cf9d

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The new context cap remains unsafe for an already-compacted model turn.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; a redacted real app-server protocol trace would still reduce merge risk.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; a redacted real app-server protocol trace would still reduce merge risk.
Evidence reviewed 6 items Oversized model-context envelope: The new limits allow 50 steps of 512 bytes plus a 2 KiB explanation, then serialize that plan into a new user message after compaction; this is far beyond the repository’s ~1K-token review threshold.
Context-budget policy: Repository policy requires a hard cap for injected model context and treats new text above about 1K tokens as a P0 review concern unless explicitly justified.
Unbounded source input: The update_plan schema has a minimum item count but no maximum item count or string length, so the restoration bounds—not the tool schema—are the sole protection against a large injected message.
Findings 1 actionable finding [P0] Keep the restored plan within the model-context budget
Security None None.

How this fits together

The Codex plugin projects app-server plan events into OpenClaw’s agent and WebChat progress streams. After Codex compacts a thread, this change sends the retained plan back through the app-server client before the model continues.

flowchart LR
A[Codex plan update] --> B[Plan event projection]
B --> C[Retained plan]
D[Context compaction completes] --> E[Restore plan]
C --> E
E --> F[Codex thread history]
F --> G[Continuing model turn]
G --> H[WebChat task progress]
Loading

Before merge

  • Keep the restored plan within the model-context budget (P0) - This permits up to 50 512-byte steps plus a 2 KiB explanation, then injects that text into an already-compacted turn. That can consume roughly 7K tokens and trigger renewed context pressure; cap the complete injected message (including its preamble) to a compact envelope and assert that full bound.
  • Resolve merge risk (P1) - Merging can reinject a multi-thousand-token message into an already-compacted turn, causing immediate renewed context pressure or preventing useful continuation.
  • Resolve merge risk (P1) - The active-turn thread/inject_items contract remains unverified because the authoritative Codex source was unavailable.
  • Complete next step (P2) - The P0 context bound needs correction, and the protocol-dependent merge gate requires direct Codex contract verification.
  • Improve patch quality - Cap and test the complete restored message at a compact model-context budget.
  • Improve patch quality - Verify the pinned Codex app-server accepts this request during the active compaction lifecycle.
  • Improve patch quality - Refresh exact-head CI after the P0 repair.

Findings

  • [P0] Keep the restored plan within the model-context budget — extensions/codex/src/app-server/plan-compaction-state.ts:13-16
Agent review details

Security

None.

PR surface

Source +144, Tests +119. Total +263 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 5 158 14 +144
Tests 1 119 0 +119
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 277 14 +263

Review metrics

Metric Value Why it matters
Production vs test LOC production +158/-14 (net +144); tests +119/-0 This bug fix materially grows the production runtime; the remaining growth must be justified by a compact, owner-bound plan-restoration path.

Merge-risk options

Maintainer options:

  1. Reduce the restored context (recommended)
    Cap the complete injected message to a compact task-list budget and add a regression assertion over the full message, including the preamble.
  2. Pause until protocol proof exists
    Hold this PR if the pinned Codex app-server cannot be inspected or traced accepting active-turn post-compaction injection.

Technical review

Best possible solution:

Retain only a compact plan envelope within the model-context budget, measure the complete injected message including its preamble, and verify the exact pinned Codex protocol lifecycle before merge.

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

Yes, from source: update_plan accepts arbitrarily large strings and lists, while this branch serializes up to its new high cap into the next model context after compaction.

Is this the best way to solve the issue?

No: preserving plan state is appropriate, but the restoration must be a small bounded context item rather than a potentially multi-thousand-token replay.

Full review comments:

  • [P0] Keep the restored plan within the model-context budget — extensions/codex/src/app-server/plan-compaction-state.ts:13-16
    This permits up to 50 512-byte steps plus a 2 KiB explanation, then injects that text into an already-compacted turn. That can consume roughly 7K tokens and trigger renewed context pressure; cap the complete injected message (including its preamble) to a compact envelope and assert that full bound.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6abfedcca5d4.

Labels

Label justifications:

  • P2: This targets Codex task-progress continuity in long-running sessions but is not a confirmed broad runtime outage.
  • merge-risk: 🚨 availability: The injected message can consume substantial context immediately after compaction and disrupt the continuing turn.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; a redacted real app-server protocol trace would still reduce merge risk.

Evidence

What I checked:

Likely related people:

  • steipete: Introduced the current Codex event projector and reasoning projection that normalize native and OpenClaw plan updates. (role: current plan-projection owner; confidence: high; commits: 4fadf4674012; files: extensions/codex/src/app-server/event-projector.ts, extensions/codex/src/app-server/event-projector-reasoning.ts, extensions/codex/src/app-server/run-attempt-active-turn.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-15T01:56:00.592Z sha 80284b4 :: found issues before merge. :: [P0] Bound the restored plan payload

@fuller-stack-dev fuller-stack-dev self-assigned this Aug 15, 2026
@fuller-stack-dev
fuller-stack-dev merged commit e382fa7 into main Aug 15, 2026
99 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/codex-plan-state-after-compaction branch August 15, 2026 03:27
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
* fix(codex): restore plan state after compaction

* fix(codex): bound restored plan context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant