Skip to content

fix(codex): allow follow-up replies while background listeners run - #171963

Merged
steipete merged 6 commits into
openclaw:mainfrom
Matuno:fix/codex-followup-claimed-thread
Oct 15, 2026
Merged

steipete merged 6 commits into
openclaw:mainfrom
Matuno:fix/codex-followup-claimed-thread

Conversation

@Matuno

@Matuno Matuno commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #171954

What Problem This Solves

Fixes follow-up messages failing with “claimed by active work” when a managed Codex conversation has a background listener and a prompt hook returns changing recall or time context.

User Impact

Users can continue the same conversation while the listener runs. Real policy and tool configuration changes retain the guarded reload path; a systemPrompt replacement remains thread policy.

Why This Change Was Made

The shared prompt builder previously mixed changing hook context into persistent developer instructions. That changed the thread configuration fingerprint, forcing a reload that correctly refused to release a thread protected by background work. The producer now separates policy from wrapped turn context. Codex uses its existing parent-only inference relay, with volatile hook context after stable parent context; other harnesses retain the complete merged instructions. Connections without the relay retain the existing native refreshable-instruction behavior.

The two optional result fields on the existing agent-harness-runtime helper are the minimum additive SDK contract needed to preserve the merged result while exposing both carriers. They are documented; no new export, subpath, configuration option, or protocol is introduced. The existing relay bounds the combined parent context to 256 KiB. Native children, memory requests, and compaction do not receive managed hook context.

Original fix by @Matuno; maintainer cleanup simplifies split-result construction, preserves stable prefix order, extends the regression to check a genuine policy-change refusal, and reconciles the patch with the lifecycle fixes in #172287 and #172145.

Evidence

PR CI is the test and typecheck gate per maintainer policy. Live Gateway proof, Crabbox/Testbox leases, local tests/typechecks, and a new production-reverted negative control were intentionally skipped per that policy. The contributor's earlier synthetic test results are historical evidence, not verification of this updated head.

  • Regression: delivers fresh parent context on the same protected thread runs two production attempts with synthetic native notifications, receives both replies on the original protected thread, checks current context exactly once, stable prefix order, and child/compaction exclusion, then verifies that changed systemPrompt policy is refused without unsubscribing or sending a third turn. It uses no sleeps or polling.
  • Shared SDK contract: classifies restrictive globs before building system instructions verifies preserved merged instructions, separated context, and policy replacement.
  • Local changed-file oxfmt passed on eight files. Core oxlint passed on six code files using trusted main tooling and all applicable rules; UI-only overrides were excluded because the shared install lacks their Solid lint package. No dependency installation was performed. git diff --check passed.
  • Independent isolated Codex autoreview at P0–P2: scoped-clean, no accepted/actionable findings. The reviewer did not execute project code or tests.
  • Exact-head CI: run 38707593147, head b22a9b8effad4a8ec0315c27d755a976dddbb39c. Success: 48 jobs passed, including openclaw/ci-gate; 28 jobs were scope-skipped. Test bundles, production/test typechecks, lint, docs, prompt snapshots, security-fast, package-boundary checks, and baseline ratchets passed. There are no inherited failures to classify on this head. Full artifact-build and live/UI lanes were scope-skipped and are not claimed as proof.
  • Regression cost: 5.493 seconds in job 116331437903. Its owning shard passed 9 files / 59 tests, with 190.34 seconds command wall time including shared preparation; no separate local file timing was run. The three-attempt production boundary checks two replies and then a policy refusal with the same listener custody.
  • CI repair: the first updated-head run passed both replies and context/prefix assertions but failed the added post-refusal listener-protection check. The fixture used an unleased client registered as isolated, so expected startup-error cleanup closed it. Switching to the existing leased wire harness models production shared retirement and preserves all assertions; the updated regression passes. This was a fixture correction, not an inherited failure or a production-code change.

Source confirmation on main: hook context enters developerInstructions, which feeds thread setup; warm configuration mismatch requests resume, and releaseCodexBoundLiveThread refuses active background custody. The nearby landed lifecycle repairs retain that guard and do not fix the context producer.

Codex source inspected read-only at be2951ea34f0d295ed0becf97079f92fa5f6950e: codex-rs/app-server-protocol/src/protocol/v2/turn.rs:167-180 exposes per-turn Responses metadata; codex-rs/app-server/src/request_processors/turn_processor.rs:625-658 separates it from sticky thread settings. codex-rs/core/src/state/additional_context.rs:16-32 turns native additional context into conversation input, and turn.rs:244-251 gives collaboration-mode instructions policy semantics. The existing inference relay therefore preserves parent-only, nonpersistent delivery without reloading configuration.

ClawSweeper review 6164233569 reported no code findings. Its live-proof request is superseded by the maintainer's PR-CI proof policy. The narrow documented SDK result addition is handled under this campaign's additive SDK exception; no separate approval is claimed. No human review findings were present.

Deferred-effect facts: hook text is the immutable snapshot prepared for this admitted turn; authority/lifetime, physical connection, thread/route identity, and live custody continue to be revalidated by the existing inference registration immediately before inference. Configuration, workspace paths, and limits retain their existing owners; this patch introduces no background task or new side-effect owner.

LOC against the merged main base: production +35/-14 (net +21), tests +181/-0, test routing +1/-0, docs +14/-2. The production-growth exception is necessary to preserve the existing merged SDK result and expose the separate carriers without duplicating hook execution; unrelated code was not deleted to fund it.

@clawsweeper

clawsweeper Bot commented Oct 14, 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 agents Agent runtime and tooling extensions: codex size: M labels Oct 14, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Oct 14, 2026
@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Separates changing prompt-hook context from persistent Codex thread instructions.

Example: A background callback listener remains active while hook context changes from “Synthetic first-turn recall” to “Synthetic second-turn recall.”

  • Before: The follow-up fails with “Codex thread thread-1 is claimed by active work; stop it first.”
  • After: The same thread answers with fresh context while the listener remains protected.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) A focused, source-supported repair with useful regression coverage and passing exact-head CI, but required real-behavior proof remains absent.
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: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Follow-up messages fail after a completed Codex turn when a background listener remains active and plugin recall or time context changes.
Reason: The source-backed failure affects normal continuation, and the recorded area-owner cleanup supports the focused repair and retained policy semantics.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR addresses a current Codex continuation bug at its producer while preserving background-work protection; no introduced code defect was found.

Priority: P1
Reviewed head: b22a9b8effad4a8ec0315c27d755a976dddbb39c

Before merge

  • Add real behavior proof - The changed prompt builder and Codex adapter run through production attempts with synthetic native/provider I/O, while the body explicitly says live verification was skipped. The prior shipped-entry-point request remains unresolved under this external-PR gate: provide redacted logs, terminal capture, or a recording showing two replies on the same managed thread with fresh hook context while its real listener continues, removing IPs, API keys, phone numbers, and non-public endpoints. CI and the recorded skip do not replace that evidence, and no proof override is present. 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.

Findings

None.

Tests

  • Missing end-to-end proof: Missing a real managed Gateway or CLI continuation with changing hook context and an active background listener; the updated head also lacks a fresh failing-base negative control.
Agent review details

How this fits together

The shared prompt builder prepares plugin instructions; the Codex adapter sends stable policy to thread setup and changing context through the existing parent-only inference relay.

flowchart TD
  A[User follow-up] --> B[Shared prompt builder]
  B --> C[Stable thread policy]
  B --> D[Changing hook context]
  C --> E[Codex thread lifecycle]
  D --> F[Parent inference relay]
  E --> F
  F --> G[Model reply]
Loading

Technical review

Best possible solution:

Deliver changing hook context through the existing parent-local relay while retaining stable thread policy and background-work custody.

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

Current main shows the complete changing-context, fingerprint-mismatch, and protected-release refusal path matching the official-release report; no target code was executed during this review.

Is this the best way to solve the issue?

The repair addresses the context producer and reuses the existing carrier without weakening lifecycle protection or changing other harnesses' merged instructions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 86380bba721a.

Provenance checked

  • Shared prompt-hook system context changes intended behavior with a stated reason (e8b56a9: The original hook integration supplied prompt and developer-instruction rewrites to native Codex attempts; later wrapping attributed plugin context.)
  • Parent-local skills, persona, and memory delivery keeps the original intent (fix(codex): restore installed skills with catalog-backed models #140422: Keep managed instructions parent-only and preserve native fallback delivery when collaboration instructions are model-owned.)
  • Native execution authority keeps the original intent (17d2faf: Native execution must continue to satisfy admitted authority and current role policy.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +21, Tests +182, Docs +12. Total +215 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 35 14 +21
Tests 3 182 0 +182
Docs 2 14 2 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 231 16 +215

Review metrics

Metric Value Why it matters
Production versus tests Production +35/-14; tests +181/-0 The production growth exposes separated carriers without rerunning hooks; the integration regression covers continuation and retained policy refusal.
SDK result additions 2 optional fields The documented additions preserve the existing merged result and introduce no config option, export, subpath, or native protocol field.

Root-cause cluster

Relationship: same_root_cause
Canonical: #171954
Summary: The linked issue owns this exact producer defect; related context and lifecycle changes address different boundaries.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: An official-release report and current source establish ordinary follow-up replies blocked while background work continues.
  • merge-risk: 🚨 compatibility: The public SDK result and Codex instruction-carrier behavior change; additive fields preserve existing consumers, and the recorded area-owner cleanup accepts the direction.
  • 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.

  • Capture successful continuation through a real managed Gateway or CLI conversation at the reviewed head.

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-14T08:29:36.518Z sha 827fc88 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T08:50:09.728Z sha 827fc88 :: needs real behavior proof before merge. :: none

Reviewed October 15, 2026, 5:10 AM ET / 09:10 UTC (Revision 3).

@Matuno

Matuno commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@clawsweeper Thanks for the review. The remaining proof and owner-decision requirements are now explicit in the PR body.

The existing negative control ran the final regression against incoming production and reproduced the exact Codex thread thread-1 is claimed by active work; stop it first. error at releaseCodexBoundLiveThread. Restoring the patch passed the same regression. It executes two production runCodexAppServerAttempt calls, verifies both replies on the original protected thread, and checks fresh hook context, absence of stale copies, and child/compaction exclusion. Native/provider I/O is synthetic; real Gateway/CLI continuation evidence remains pending.

For the SDK decision: both added fields are optional, and the existing complete merged developerInstructions result remains unchanged for other consumers. Hook systemPrompt replacements remain persistent policy; managed Codex uses the separate per-turn carrier, while uncovered connections retain the native refreshable fallback. Maintainer acceptance of this supported contract remains pending.

All 18 focused cases, core/Codex typechecks, targeted type-aware lint, formatting, and independent scoped review were recorded in the PR evidence. This clarification does not request a merge or a waiver of the two remaining requirements.

steipete and others added 5 commits October 15, 2026 01:15
Keep volatile prompt-hook context after stable parent-local instructions,
simplify the shared split result, and extend the continuation regression
with prefix-order and genuine-policy-change refusal checks.

Fixes openclaw#171954. Original fix by @Matuno in openclaw#171963.
PR CI owns tests and typechecks; live proof intentionally skipped per
maintainer policy. No thread lifecycle or claim-custody guard is bypassed.

Co-authored-by: Matuno <[email protected]>
Use the existing leased wire harness instead of manually registering an
unleased fake client as isolated. Real shared retirement preserves native
background leases after a policy refusal; isolated fixture cleanup closes
the client. Keep the refusal and listener-survival assertions unchanged.

CI exposed the fixture mismatch after both follow-up replies and context
assertions passed. No production code changed. PR CI remains the test gate.
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 8da316f into openclaw:main Oct 15, 2026
146 of 147 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…penclaw#171963)

* fix(codex): keep hook context from blocking background follow-ups

* fix(codex): preserve stable context during background follow-ups

Keep volatile prompt-hook context after stable parent-local instructions,
simplify the shared split result, and extend the continuation regression
with prefix-order and genuine-policy-change refusal checks.

Fixes openclaw#171954. Original fix by @Matuno in openclaw#171963.
PR CI owns tests and typechecks; live proof intentionally skipped per
maintainer policy. No thread lifecycle or claim-custody guard is bypassed.

Co-authored-by: Matuno <[email protected]>

* test(codex): retain shared listener custody in continuation fixture

Use the existing leased wire harness instead of manually registering an
unleased fake client as isolated. Real shared retirement preserves native
background leases after a policy refusal; isolated fixture cleanup closes
the client. Keep the refusal and listener-survival assertions unchanged.

CI exposed the fixture mismatch after both follow-up replies and context
assertions passed. No production code changed. PR CI remains the test gate.

---------

Co-authored-by: Matuno <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: changing prompt-hook context blocks Codex replies while a background listener runs

2 participants