Skip to content

fix(codex): stop advertising unavailable subagent tools - #157684

Open
roboclaw-bot wants to merge 1 commit into
mainfrom
fix/codex-delegation-guidance
Open

roboclaw-bot wants to merge 1 commit into
mainfrom
fix/codex-delegation-guidance

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes Codex-backed agents receiving misleading subagent instructions: native collaboration tools were described as deferred OpenClaw tools, and policy-restricted turns still recommended native delegation that their request configuration disabled.

User Impact

Subagent guidance now follows the tools and calling conventions exposed by Codex. OpenClaw still describes its actual deferred tools, preserves offered OpenClaw delegation, and retains its background-completion handoff. No permissions, model defaults, configuration schema, or runtime delegation capabilities change.

Why This Change Was Made

Codex owns native collaboration discovery and invocation. Its v1 and v2 backends do not share the same exposure contract: v2 defaults to direct-only collaboration tools. OpenClaw should not prescribe one backend’s discovery convention to the other.

The prompt owner now honors the existing policy-restricted flag and limits dynamic-discovery guidance to registered deferred OpenClaw tools. Native follow-up and wait conventions remain with Codex instead of hardcoding tool names.

Reported by Vincent Koc.

Work sessions

Evidence

  • Three final regression cases fail against the pre-fix production modules and pass against the repair: restricted native guidance, preserved offered OpenClaw delegation, and native-versus-dynamic discovery. The original defects were captured before production edits; an independent actual request-builder probe corroborated the configuration/prompt contradiction.

  • Final focused prompt and thread-lifecycle coverage: 253 tests passed across two files. Command: node scripts/run-vitest.mjs extensions/codex/src/app-server/thread-prompt.test.ts extensions/codex/src/app-server/thread-lifecycle.test.ts --maxWorkers=1; warm-run wall 16.51 seconds; final refreshed-head runner 43.21 seconds (Vitest 41.59 seconds, including compiler artifact preparation). Added cases exercise the actual request builder and preserve offered OpenClaw delegation; existing native/deferred/yield cases cover the calling-convention change.

  • Independent Codex autoreview: scoped-clean through P3, no actionable findings. The subsequent base-only refresh retained an identical patch, verified with git range-diff.

  • Full changed-surface gate passed on final head 0cbc79a2f33b78a11c784d25b5d7d9d6bf1a842e, including extension production/test typechecks, lint, import-cycle and repository guards.

  • Production delta: +12/-12 (net zero). Tests: +40/-22.

  • Inspected pinned Codex 0.155.1: native collaboration instructions, direct-only v2 default, and tool registration.

  • Exact-head runtime build (pnpm build qaRuntime) and real Gateway → Codex subagent probe passed on a fresh Blacksmith Testbox: 72.135 seconds for the test, 83.31 seconds for Vitest. The probe covers initial spawning, two additional native-shell assignments on the same child, distinct durable task results, and retained child history. Settings: API-key authentication, low effort, one child; test runs gateway agent turns through the plugin-owned Codex app-server harness in src/gateway/gateway-codex-harness.live.test.ts.

  • Exact-head Testbox lease provenance: tbx_01m3awenxktf3vw96pcv12fprn; runner exit 0. The wrapper verified the source commit and materialized tree before execution. Both task-owned leases were stopped. Lease-workflow cleanup is not the test verdict.

Build context: the original baseline had an unrelated TS2459 in the npm-pack helper. Its existing fix, #157659, has merged. This branch was refreshed onto that landed prerequisite, without duplicating its change; tests, full changed checks, and the live probe were rerun on the refreshed head.

Scope: the baseline’s OpenClaw spawn/completion checks and native Codex child/follow-up checks passed with the tested target and control configurations. These checks do not establish a universal model-specific regression. This PR fixes the reproduced instruction-contract defects, not an unproven model-specific runtime issue.

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

Leave native collaboration discovery and calling conventions with Codex; emit dynamic discovery guidance only for actual deferred OpenClaw tools. Suppress native delegation guidance on policy-restricted turns without hiding offered OpenClaw delegation.

Co-authored-by: vincentkoc <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the fix/codex-delegation-guidance branch from dcb1812 to 0cbc79a Compare September 24, 2026 23:43
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 24, 2026 23:46
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

The PR aligns subagent instructions with effective tool restrictions and leaves native collaboration discovery and calling conventions to Codex.

Example: An agent runs with a restricted tool policy allowing only read

  • Before: The base request disables native agents but its instructions still recommend native delegation.
  • After: The instructions omit native delegation advice while preserving any offered OpenClaw delegation tools.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused contract repair with reported real runtime coverage and no actionable introduced defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied exact-head report exercises the real Gateway-to-Codex path with native spawning, repeated child assignments, durable results, and retained history; request-builder regressions separately cover restricted advice and preserved OpenClaw delegation. The lease workflow's cancellation is cleanup context, not the test verdict. No stored-data contract changes require migration.
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 agents receive instructions to discover or use subagent tools through conventions their current runtime does not expose.
Reason: Available capabilities should match agent instructions. The narrow repair preserves OpenClaw delegation and completion behavior while correcting a source-verified runtime contract mismatch.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR retains useful work: current main fixes restricted-turn advertising but still prescribes native discovery and waiting conventions that differ between Codex backends. No actionable introduced defect was found; overlapping main changes still require synchronization.

Priority: P2
Reviewed head: 0cbc79a2f33b78a11c784d25b5d7d9d6bf1a842e

Before merge

  • Complete next step - Sync the prompt changes with current main, preserving empty-allowlist and workspace-only restrictions plus code-mode-specific discovery guidance, and validate the combined prompt cases.

Findings

None.

Agent review details

How this fits together

The Codex plugin translates OpenClaw agent settings and available tools into requests and instructions for Codex's agent runtime. This change keeps those instructions consistent with the tools the runtime exposes.

flowchart TD
  A[Agent settings and tool policy] --> C[Codex request builder]
  B[Available OpenClaw tools] --> D[Instruction builder]
  A --> D
  D --> E[Policy-aware delegation guidance]
  E --> C
  C --> F[Codex runtime]
  F --> G[Native collaboration tools]
Loading

Technical review

Best possible solution:

Keep native collaboration instructions with Codex and describe only actually offered OpenClaw tools in the existing prompt owner.

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

Yes, the request-builder regression establishes the original policy/prompt contradiction, and inspected current-main and Codex source establish the remaining discovery-contract mismatch. No reviewer-side runtime execution was performed.

Is this the best way to solve the issue?

Yes, the patch repairs the existing instruction owner without changing permissions or adding another discovery mechanism; integration must preserve subsequent main changes.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff adds the existing restricted-policy flag to prompt gating, limits discovery advice to actual deferred OpenClaw tools, and replaces hardcoded native discovery and wait conventions. (extensions/codex/src/app-server/thread-prompt.ts:102, 0cbc79a2f33b)
  • Current-main necessity: Current main suppresses native advice for restricted policies and workspace-only runs, but still emits native-triggered deferred discovery advice and explicitly names spawn_agent and wait_agent. The broader calling-convention repair remains absent. (extensions/codex/src/app-server/thread-prompt.ts:86, a73ef559b23a)
  • Merged work preserves this PR's distinct scope: The merged fix(codex): reject unrelated-thread follow-ups at the input hook #167075 explicitly says its restricted-policy predicate overlaps while this PR's broader native wording, discovery, and waiting guidance is neither incorporated nor superseded. (9ed1b9d70a88)
  • Personally inspected dependency contract: The PR changes guidance about Codex-owned tools, establishing the dependency signal. The exact sibling checkout matches the GitHub-verified commit: V2 defaults non_code_mode_only to true and registers collaboration tools as DirectModelOnly, while V1 may defer them; Codex supplies native collaboration instructions itself. (codex-rs/core/src/tools/spec_plan.rs:1285, be2951ea34f0)
  • Regression contract: The added request-builder regression checks that agents.enabled and features.multi_agent_v2 are false and native delegation guidance is absent. A separate case preserves offered sessions_spawn guidance; existing cases retain deferred-tool discovery and completion handoff coverage. (extensions/codex/src/app-server/thread-prompt.test.ts:158, 0cbc79a2f33b)
  • Reported real runtime proof: The fully supplied body, captured as sourceRevision d48a9ef50f4a877e0153efe4974134abb41c8c226dd7f3b5c52746c1ce2a0c4e, records an exact-head real Gateway-to-Codex run with API-key authentication, native spawning, two follow-up assignments, distinct durable results, and retained child history. It separately records failing-before/passing-after instruction regressions. The linked Testbox lease workflow is cancelled and has a different workflow checkout SHA; its status alone neither proves nor disproves the reported remote test result. (src/gateway/gateway-codex-harness.live.test.ts, 0cbc79a2f33b)

Likely related people:

  • Peter Steinberger: Raw commit b9d0e13 adds extensions/codex/src/app-server/thread-prompt.ts:101 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b9d0e13b5d08; files: extensions/codex/src/app-server/thread-prompt.ts)

PR surface

Source 0, Tests +18. Total +18 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 12 12 0
Tests 2 40 22 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 52 34 +18

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: Misleading Codex delegation instructions are a bounded agent improvement without evidence of an urgent production outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-24T23:55:16.148Z sha 0cbc79a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-29T15:24:07.028Z sha 0cbc79a :: blocked before merge. :: none

Reviewed October 9, 2026, 1:34 AM ET / 05:34 UTC (Revision 3).

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026

This branch has not been deployed

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

Labels

extensions: codex P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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