Skip to content

fix: keep Codex goals advancing across turns and restarts - #177351

Closed
Baumus wants to merge 2 commits into
openclaw:mainfrom
Baumus:fix/codex-goal-continuation
Closed

Baumus wants to merge 2 commits into
openclaw:mainfrom
Baumus:fix/codex-goal-continuation

Conversation

@Baumus

@Baumus Baumus commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Related: #102260, #167897, #175918.

Problem and behavior

Local Codex sessions can finish a reply while their OpenClaw Goal remains active, requiring repeated /goal resume. This PR extends the existing Goal continuation queue to local Codex and restores durably accepted Goal continuations after Gateway restart.

The same queue, admission, accounting, operator-authority, and reply-delivery owners remain responsible. Pause, Stop, completion, session/Goal replacement, current permissions, and budgets remain authoritative. Codex's native autonomous Goal engine stays disabled.

Maintainer decision requested: approve local Codex automatic pursuit and recovery of accepted Goal inputs as one capability. Earlier implementations deliberately supported narrower placement/lifecycle boundaries; this expansion needs owner agreement.

Evidence and remaining gates

Evidence below applies to head 4ba6e39ad497. Latest inspection: October 19, 2026.

Claim Evidence Status
Source restrictions survive recovery Original failure reproduced; real SQLite replay, production operator restoration, host-bound file effects, policy narrowing, and revocation checks Passed
Recovered replies reach authorized WebChat clients Original missing-final-event failure reproduced; authenticated subscribed WebSocket receives the repaired final reply Passed with simulated model
Shipped-release data remains usable Packaged 2026.10.5 → candidate drill preserves settings, complete existing Goal, and original transcript data; candidate edits and completes that same Goal Passed
Candidate runs on existing operator state Verified backup, real Doctor migrations, authenticated RPC build identity, readiness, valid config, loaded Codex plugin, and fresh error-level Doctor lint Passed
Consecutive local Codex Goal pursuit with a real model Current production activity is not sufficient proof; see observation below Open
Accepted Goal continuation survives an actual runtime restart Integration coverage exists; a real-model runtime demonstration remains needed Open
Integration with current main GitHub reports conflicts; three text conflicts confirmed against f455495cd8819 Open
Maintainer approval and required CI Owner decision outstanding; openclaw/ci-gate pending at inspection Open

Production observation: do not count ordinary activity as Goal proof

The installed candidate is executing real local Codex work. However, the inspected session's Goal was paused, with continuationTurns: 0, after a thread-ownership rejection: Codex thread <redacted> is claimed by active work; stop it first. Later work was attributed to a native child-result continuation. That activity does not demonstrate successful Goal-led continuation.

The persisted lifecycle owner pauses an active Goal after a terminal failed run. The Codex adapter rejects releasing a thread still claimed or protected by active work. Whether this observed rejection is an existing ownership problem, an interaction with this change, or an expected overlapping request still requires a focused reproduction. Do not bypass the ownership guard or infer a successful Goal run from tool activity alone. Private session identifiers, transcript contents, and model/account details are omitted.

Packaged upgrade proof

The published 2026.10.5 runtime (1b58cb9a1b4f) created the setting, admitted and paused a Goal through its public API, and wrote three transcript messages. After clean shutdown, the candidate ran Doctor and config validation on the same synthetic state. The setting and complete Goal—including ID, counters, timestamps, and status—were preserved, as were original message IDs, content, and usage. Editing and completing the existing Goal also passed.

The sole response difference was an additive assistant.usage.contextUsage: { state: "unavailable" } projection, verified against both packaged serializers. This covers the exercised data path, not every possible plugin database.

Artifact SHA-256: 73ad91edee7838a73c2efc5001c179bac9f42bf6af467456fa3aacd81b95662d.

The operator deployment used the documented external-terminal package-manager/Doctor workflow after the old updater refused its native handoff check before activation. Doctor completed; the same Gateway process became ready after its initial 90-second readiness budget expired. Independent error-level lint returned ok: true with no findings. These are deployment observations, not a Goal benchmark.

Implementation and regression coverage

The three earlier ClawSweeper findings are addressed:

  • Persist source execution restrictions before acceptance, including explicit empty caps, independent glob intersections, disabled tools, restart-safe tools, and code-mode restrictions. Recovery combines them with current policy and revalidates authority before effects.
  • Reconstruct internal/WebChat delivery through existing late-reply finalization and session-writer authority.
  • Keep Goal identity/policy types independent of session types, removing the import cycle.

Original restriction-loss and WebChat delivery failures were reproduced before repair. Coverage includes four real SQLite/operator/file-effect/revocation cases, all four command-settlement modes (including the real disabled-tool command-attempt path), 63 Goal queue tests, 15 recovery tests, 7 policy tests, and 5 prompt/tool-prefix tests. Core plus four affected type graphs, runtime/type import-cycle guards, mock-export ratchet, changed-file lint/format, and independent repair review passed. Full repository CI and real-model Goal/restart proof are not claimed.

Integration work and limits

Conflicts against f455495cd8819 are in docs/gateway/restart-recovery.md, src/config/sessions/session-entry-list.worker.ts, and src/config/sessions/session-pending-input-history.kernel.ts. Preserve upstream chat/steering/deferred recovery while retaining Goal-specific selection, source policy, and delivery. In particular, upstream's expanded queued-input selection must not allow ordinary chat recovery and Goal recovery to consume the same private Goal input.

No new database schema, configuration option, or parallel scheduler is introduced. Older private PR records without source-policy information stop visibly instead of resuming with broader permissions. Startup restores accepted inputs; an active Goal row alone does not authorize new work. A hard crash before durable acceptance can still require /goal resume. Exhausted retries and genuinely blocked work do not become unlimited retries.

After resolving integration and real-runtime proof, update this evidence and request one fresh ClawSweeper review.

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations agents Agent runtime and tooling extensions: codex size: XL labels Oct 19, 2026
@Baumus
Baumus marked this pull request as ready for review October 19, 2026 13:44
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR enables automatic local Codex Goal continuation and restores durably accepted continuation inputs after Gateway restarts.

Example: A local Codex session finishes the first step of a three-step checklist while its Goal remains active.

  • Before: Pursuit stops until the operator uses /goal resume.
  • After: The shared queue submits another turn and can recover an accepted continuation after restart.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The earlier code defects are repaired and authority coverage is stronger, but required runtime and upgrade evidence remains incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Local Codex Goals require repeated manual resumption, and accepted continuation work can be stranded by a Gateway restart.
Reason: The capability has clear value, but local autonomy and durable startup replay expand deliberately scoped existing behavior without recorded owner direction.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR adds a distinct capability missing from current main, and the three earlier code findings are addressed; the expanded autonomy still needs owner direction.

Priority: P2
Reviewed head: 4ba6e39ad497b1f2b838f084996fc886862ddf3d
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this PR enable local Codex automatic pursuit and restart replay of accepted Goal continuations?
  • Recommendation: Approve the complete continuation path: Keep local continuation and accepted-input recovery together, subject to the separate validation gates.
  • Why: The prior implementations explicitly scoped support to cloud workers and same-process returns, and no owner approval of this expansion appears in the discussion.

Before merge

  • Add real behavior proof - The supplied tests cover SQLite replay, production operator restoration, file effects and revocation, and authenticated WebSocket delivery, but local Codex execution is simulated; provide redacted terminal output, logs, or a recording demonstrating consecutive pursuit and recovery through the shipped runtime, excluding credentials, IPs, and private endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Complete next step - Resolve the merge conflict GitHub reports for this head while preserving current session-controller and recovery contracts.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Low-value test src/gateway/goal-continuation-recovery.test.ts: The standalone skipped-before-adoption settlement case duplicates the non-restart lifecycle case and never establishes the consumed-source condition in its title; remove or consolidate it.
  • Missing end-to-end proof: Show consecutive local Codex pursuit, actual Gateway restart recovery, and visible replies through the shipped runtime, plus a latest-stable upgrade preserving settings, Goals, restrictions, and transcript data.
Agent review details

How this fits together

Goal continuation consumes completed-turn outcomes, Goal state, source restrictions, operator authority, and delivery coordinates, then submits follow-up turns through existing session admission and reply owners.

flowchart LR
  A[Completed agent turn] --> B[Goal continuation]
  B --> C[Pending input storage]
  C --> D[Startup recovery]
  D --> E[Current operator authority]
  E --> F[Session follow-up queue]
  B --> F
  F --> G[Agent execution]
  G --> H[Authorized reply delivery]
Loading

Technical review

Best possible solution:

Extend the existing Goal queue and recovery owners with approved autonomy semantics and verified runtime and upgrade behavior.

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

Current-main source explicitly excludes local Codex continuation; the supplied integration tests exercise the proposed behavior with simulated execution, and no target code was run during this review.

Is this the best way to solve the issue?

The queue, pending-input store, operator restoration, and reply finalizer are appropriate existing owners; a local-only first stage remains viable if restart autonomy is deferred.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 954a610f5d0f.

Provenance checked

  • Codex Goal placement changes intended behavior with a stated reason (eec3594: Support core Goals on authenticated remote-exec cloud-worker sessions through existing admission and accounting owners.)
  • Automatic Goal queue keeps the original intent (c845d6d: Continue active Goals through fresh queued turns while preserving user-input priority, budgets, cancellation, and delivery.)
  • Child-return ownership changes intended behavior with a stated reason (d79b0a4: Return delegated built-in Goal work after committed child settlement, explicitly within the same process.)
  • Recovery discovery keeps the original intent (a9a4c5e: Select relevant accepted inputs in the database worker while preserving custody and validating authority before dispatch.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +1209, Tests +1830, Docs +18, Other -1. Total +3056 across 62 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 38 1386 177 +1209
Tests 19 1912 82 +1830
Docs 4 46 28 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 62 3344 288 +3056

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This improves a bounded Goal workflow without evidence of an urgent released regression.
  • merge-risk: 🚨 compatibility: Automatic startup replay expands the previous continuation lifecycle for accepted Goal work.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Remove or consolidate the duplicate skipped-before-adoption settlement test.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-19T14:05:08.889Z sha bbe772c :: needs real behavior proof before merge. :: [P1] Preserve the source tool restrictions when recovering Goal work | [P2] Restore a web-chat reply dispatcher for recovered continuations | [P2] Keep the persisted Goal identity type independent of SessionEntry
  • reviewed 2026-10-19T17:59:30.893Z sha 4ba6e39 :: needs real behavior proof before merge. :: none

Reviewed October 19, 2026, 2:08 PM ET / 18:08 UTC (Revision 3).

Baumus commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the three confirmed findings in 4ba6e39: durable source execution restrictions (including native tool disabling and independent glob caps), recovered attached-WebChat final delivery, and the type import cycle. Added real SQLite/operator-restoration/file-effect/revocation coverage plus authenticated WebSocket delivery proof. Both original behavior regressions were reproduced before the repair. The PR body now lists current validation and the remaining live-model/crash-window limits. The mock-export baseline changed only by removing its single stale entry.

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Oct 19, 2026

Baumus commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

The requested data-model compatibility proof is now complete and documented in the PR description. An isolated packaged-runtime drill upgraded state actually created by published 2026.10.5 (1b58cb9a1b4f) to 4ba6e39ad497: settings, the complete existing paused Goal, and all three transcript messages were preserved; the candidate then edited and completed that same Goal through the real API. Doctor migration and config validation passed. The only response difference was a verified additive contextUsage projection, with original persisted values preserved. Model responses were simulated; this does not claim live Codex execution or exhaustive coverage of every operator database. No production data or credentials were used in this proof.

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 19, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 19, 2026
@JUSTINFORSOUND

Copy link
Copy Markdown

Local foreground follow-through observation and a narrower contract question for #177351.

On core 2026.10.5 with the local Codex 2026.10.3 bridge (Codex dependency 0.160.0), two ordinary research turns ended with nonempty acknowledgements, no tool calls and successful terminal metadata, while the requested investigation was unfinished. This is not evidence that missing Goals caused the model to stop, nor a confirmed stock regression: the installation has unrelated local corrections.

Source inspection distinguishes turn settlement from task completion: classifyAgentHarnessTerminalOutcome bypasses empty-result classification when assistant text is nonempty. The bridge deliberately disables native autonomous Goals; the introducing commit 2b18ef7 explains the missing run-owner contract. Current main f3fccd0 admits core Codex Goal continuation for supported remote-exec workers, not local placement.

Could the owning maintainer confirm whether same-process local continuation through the existing core queue/admission owner is an acceptable first stage separately from restart replay, or whether #177351 must remain one combined capability? We are not proposing to enable native autonomous turns, bypass thread claims, retry every final reply, or add a scheduler.

The necessary acceptance case is a fresh explicitly scoped local read-only Goal: an acknowledgement-only terminal turn is followed by admitted real research and a delivered artifact without another user prompt; current tool restrictions, user-input/Stop precedence, finite budgets, native thread ownership and duplicate-effect/delivery prevention remain enforced. Ordinary completed no-tool answers must still terminate. Real-model proof and maintainer approval remain outstanding in this PR; no automatic-continuation repair is claimed here.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale after 7 days without qualifying human activity.
Without new human activity, Barnacle may close it as not planned 7 days after this message was posted. This is administrative inactivity cleanup, not a claim that the problem is fixed.
A human update restarts the inactivity clock; a new PR head also restarts it. A maintainer can add no-stale for a durable hold, or bad-barnacle to suppress Barnacle. Remove the hold when work can resume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: codex gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants