Skip to content

fix: Codex replies fail in standalone OpenClaw - #173473

Merged
steipete merged 1 commit into
mainfrom
fix/standalone-hook-relay-invocation
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/standalone-hook-relay-invocation

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Codex agent replies failing with “Cannot resolve OpenClaw CLI executable path for native hook relay” in a minimal Bun standalone installation.

Targets main. Parent #173154 merged as 3bfccdb9bd3df459931e9d6f8751acfc9f147dfa. Only the HR commit was cherry-picked onto fresh main 56c315156f4542f197a2b7f727681ba3f41c21b5; no pre-squash parent commits remain. Current head: 9f49792869814b2a344ef8d878cfafeb02347115, exactly 13 changed files (+368/-61).

User Impact

Standalone self-launches use the executable directly for native hook relays, ACP, TUI, completion refresh, and live CLI probes. Explicit OPENCLAW_CLI_PATH overrides and loose Node/Bun launch arguments retain their existing behavior. There is no configuration migration.

Why This Change Was Made

The minimal runtime deliberately contains no loose CLI entry files. Callers were requiring those files before consulting the canonical cli-invocation.mjs owner. The fix recognizes standalone identity first and delegates command construction to that owner; its exports and signatures are unchanged. The infra helper retains loose-install discovery and loader preparation as an adapter. Existing shell quoting, exec, nice, and the dedicated loose relay worker are preserved.

Daemon invocation and installation remain owned by #172569 and are untouched. Package/resource discovery, explicit child operands, scheduled-task observation, and separate MCP worker contracts are unchanged. Managed-service handoff and startup were already migrated on the base branch.

Evidence

Signed standalone before/after proof:

  • Before: signed c305e2e9, no physical loose CLI entries, real Codex turn failed with the exact relay-resolution error; exit 1 in 61.767s. This reference app used the older Bun compiler revision 65d94e715.
  • After proof ran at c93b1901ca8cd667524b3e86fbcd77ff76ba4fff, production-pinned Bun 1.4.3-canary.1+94f8f5ffe, JIT on macOS arm64. Production build passed in 379.919s; standalone build in 1229.085s. Developer ID signing and strict verification passed with the manifest-declared entitlements.
  • The plain real Codex turn returned exactly HR_OK, exit 0 in 35.260s.
  • The tool-using real Codex turn wrote the required HR_TOOL_OK marker and returned HR_OK, exit 0 in 36.796s. Process observation captured an actual child running <signed-executable> hooks relay --provider codex ... --event pre_tool_use --timeout 9000; there was no interpreter or loose entry argument.
  • Both turns used isolated OpenClaw HOME/config/state/workspace and native Codex REUSE via appServer.homeScope: "user". No OAuth copies or surviving captured child processes remained. All three physical loose entry paths were absent. Build outputs were deleted after recording manifests, signatures, process evidence, and results.
  • A reusable opt-in real Codex campaign cell and run instructions are retained in the task's HR evidence directory. It requires both the tool result and an observed standalone relay process.

The clean cherry-pick is patch-identical (git range-diff reports =), and all 13 touched file blobs match the proven head. The existing real Codex-turn proof and scoped-clean review carry over; no conflict resolution or code changes required re-review.

Focused regressions rerun on current head 9f49792869814b2a344ef8d878cfafeb02347115, each with pnpm test <file> --maxWorkers=1:

Resolver suite Wall time
Native hook relay 11.286s
Current CLI invocation adapter 18.766s
ACP client invocation 45.186s
TUI launch 3.414s
Completion command runner 15.054s
Live agent probes 4.637s

ACP test cost: the four cases execute in 41ms total. The 45.186s wrapper run includes 32.189s of compiler preparation; 96% of Vitest duration is transformation. The retained composition test proves that command selection and provider-credential filtering reach the actual spawn boundary. A pure helper test cannot prove that wiring, and retaining composition coverage after extracting a helper would retain its import cost.

Current-head targeted format (0.186s), lint (32.643s), core types (19.226s), docs config (5.502s), and diff checks passed. Full test types and relevant repository ratchets also passed before the patch-identical restack. Codex autoreview returned scoped-clean; the review is reused for that mechanical restack under repository policy. No substantive code changes followed review.

The initial continuation runner referenced an MS signing helper removed during lane cleanup. Signing was resumed successfully with the same documented recipe in a task-owned helper; no rebuild or source change was needed. Exact-head CI run 38837282260 completed successfully: all 70 jobs passed. No inherited-failure exception is needed.

@clawsweeper

clawsweeper Bot commented Oct 15, 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 cli CLI command changes agents Agent runtime and tooling size: M labels Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR routes standalone self-launches through the shared CLI invocation owner before attempting loose-script discovery.

Example: A Codex turn runs from a minimal standalone installation without runtime/openclaw.mjs.

  • Before: Relay discovery throws “Cannot resolve OpenClaw CLI executable path for native hook relay.”
  • After: The relay command directly invokes the standalone executable with hooks relay and the existing relay arguments.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is coherent and source-supported, with useful invocation-contract coverage; supplied after-fix evidence does not yet exercise the real standalone Codex flow.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; supplied after-fix evidence consists of focused resolver tests, while the author explicitly retains the draft hold for signed standalone qualification.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Codex replies fail in a minimal standalone installation because native hook relay discovery requires files excluded from that installation.
Reason: The source-backed failure affects a supported standalone runtime contract, and the maintainer-authored direction reuses existing ownership without adding settings or capabilities.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a concrete standalone runtime failure that remains on main; no definite introduced defect was found.

Priority: P2
Reviewed head: c93b1901ca8cd667524b3e86fbcd77ff76ba4fff

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The author’s stated qualification remains pending: signed standalone Codex reply and tool-using turns with verified tool results and an observed direct relay child command; baseline-failure runs for the added tests are not shown.
Agent review details

How this fits together

CLI launch adapters translate executable identity and command arguments into child-process invocations used by native hooks, ACP, TUI, completion refresh, and live probes.

flowchart TD
  A[Self-launch request] --> B[CLI launch adapter]
  B --> C[Standalone identity]
  B --> D[Loose entry discovery]
  C --> E[Shared invocation owner]
  D --> E
  E --> F[Child process]
  F --> G[Relay or CLI command]
Loading

Technical review

Best possible solution:

Keep standalone identity and argument construction in the existing shared owner while preserving loose-install discovery and the dedicated relay worker.

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

The minimal artifact deliberately omits loose CLI scripts, and current-main relay discovery consequently reaches the exact reported error; the linked signed packaging run corroborates this path, but no target code was executed during this review.

Is this the best way to solve the issue?

Recognizing standalone identity before loose discovery repairs the owning boundary and consistently covers sibling launchers without changing configuration, relay protocols, or public APIs.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared invocation ownership keeps the original intent (488f052: Distinguish standalone executable arguments from loose runtime-plus-entry launches while preserving profiles.)
  • Dedicated loose native relay keeps the original intent (9c962da: Reduce native hook startup cost through a dedicated entry in the unified runtime graph while preserving overrides and cleanup.)
  • Current-package discovery and installation pinning keeps the original intent (bfcce12: Resolve installed local-auth children from the correct package and working directory; later launcher pinning prevents prepared loose commands from switching releases.)
  • ACP provider credential filtering keeps the original intent (ff2e7a2: Strip provider credentials from the default ACP child while preserving explicitly configured custom-server environment contracts.)
  • TUI terminal handoff keeps the original intent (aae4b1b: Launch a fresh TUI child so onboarding and the TUI do not compete for terminal state.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

  • Pinned introduction: The reviewed changes are limited to the supplied parent-to-head diff; the shared cli-invocation.mjs implementation belongs to the stacked base. (src/agents/harness/native-hook-relay-command.ts:120, c93b1901ca8c)
  • Current-main failure path: Main searches for physical relay or CLI scripts and then an existing argv entry; it has no standalone identity branch before throwing the reported error. (src/agents/harness/native-hook-relay-command.ts:121, e95851fa65d3)
  • Existing launch contracts preserved: Standalone identity now precedes loose discovery, while the dedicated loose relay, explicit executable overrides, shell quoting, relay identity arguments, and exec-based shell replacement remain intact. (src/agents/harness/native-hook-relay-command.ts:66, c93b1901ca8c)
  • Discussion and explicit hold: The complete current body records the signed before-failure and focused pre-restack checks, explicitly leaves signed after-fix qualification pending, and says not to land yet; discussion adds only bot status messages. (c93b1901ca8c)
  • Independent runtime report: feat(macos): launch the compiled OpenClaw runtime #172569 records the same relay-resolution failure during a real signed standalone chat turn and assigns its repair to the shared invocation owner.
  • Intent and feature history: Feature history identifies the shared current-package resolver, installation pinning, dedicated relay startup work, and standalone builder ownership; available blame confirms retained lines. Follow and content-history searches encountered missing historical blobs, so no unsupported introduction claim is made. (src/infra/openclaw-cli-invocation.ts:114, e95851fa65d3)

Likely related people:

  • Peter Steinberger: Raw commit c90b91b adds src/infra/openclaw-cli-invocation.ts:98 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c90b91b3e4c8; files: src/infra/openclaw-cli-invocation.ts)
  • Vincent Koc: Raw commit bfcce12 adds src/infra/openclaw-cli-invocation.ts:59 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bfcce12e6b38; files: src/infra/openclaw-cli-invocation.ts)

PR surface

Source +47, Tests +255, Docs +5. Total +307 across 13 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 76 29 +47
Tests 6 286 31 +255
Docs 1 6 1 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 368 61 +307

Review metrics

Metric Value Why it matters
Production versus test changes Production +76/-29; tests +286/-31 The production growth connects existing launch adapters to standalone identity; tests cover distinct invocation boundaries and retained loose-install behavior.

Labels

Label changes:

  • add P2: The failure blocks Codex turns in the developer-oriented standalone packaging path, with limited demonstrated reach beyond that installation mode.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The failure blocks Codex turns in the developer-oriented standalone packaging path, with limited demonstrated reach beyond that installation mode.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Attach the signed standalone qualification already identified in the PR body, including the direct relay process command and verified tool result.

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.

Reviewed October 15, 2026, 5:07 PM ET / 21:07 UTC.

@steipete
steipete marked this pull request as ready for review October 15, 2026 22:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T01:54:29.732616Z 9f49792 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from fix/standalone-doctor-snapshot to main October 16, 2026 01:24
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts commands Command implementations docker Docker and sandbox tooling size: XL and removed size: M labels Oct 16, 2026
@steipete
steipete force-pushed the fix/standalone-hook-relay-invocation branch from c93b190 to 9f49792 Compare October 16, 2026 01:50
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed scripts Repository scripts commands Command implementations docker Docker and sandbox tooling size: XL labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f49792869

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/acp/client.invocation.test.ts Resolved
@steipete
steipete merged commit bf18487 into main Oct 16, 2026
156 of 159 checks passed
@steipete
steipete deleted the fix/standalone-hook-relay-invocation branch October 16, 2026 06:15
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant