Repository navigation
fix(codex): keep native shell for hidden subagents by disabling native delegation - #192599
Conversation
…ithout gateway fallback
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves Codex native shell and file tools under session-tool denies by disabling native delegation instead. Example: A hidden child must write SUBAGENT-SHELL-8A6A3B while Gateway-local shell and file tools are excluded.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current hidden-subagent workflow failure and has no remaining actionable findings. The earlier conflict is resolved; exact-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCore prepares the effective tool policy, and the Codex plugin translates audited denies into native configuration and developer instructions before starting or resuming a thread. flowchart TD
A[Effective OpenClaw tool policy] --> B[Codex deny classification]
B --> C[Managed configuration preflight]
C --> D[Thread start or resume configuration]
D --> E[Native shell and file tools]
D --> F[Native delegation disabled]
Technical reviewBest possible solution: Retain the focused delegation-only restriction through the existing Codex configuration owner and complete the repository merge gates. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the restrictive path, and the contributor supplies real before/after Gateway output; no target code was executed during this review. Is this the best way to solve the issue? The smallest complete fix keeps core policy preparation intact and applies targeted native delegation flags, managed-pin rejection, and matching prompt guidance inside the existing Codex owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e81ab2295501. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +77, Tests +467, Docs +6, Other +2. Total +552 across 12 files. Added test files: 3. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed November 4, 2026, 10:56 AM ET / 15:56 UTC (Revision 4). |
… for session-tool denies Session-tool denies are enforced by disabling native delegation, so managed requirements or legacy managed layers that pin multi_agent/multi_agent_v2 on now fail the turn before inference. The live proof waits for the child settled reply and asserts delegation facts from the child native thread record. Docs updated; test lines allocated.
|
Addressed the ClawSweeper review of
Not live-tested: resuming an existing child thread (covered by the shared start/resume preflight), and an OCE cluster rather than a Linux Gateway. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ep-native-shell # Conflicts: # docs/plugins/codex-harness-reference/restricted-turns.md
|
Merged current |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…e delegation (openclaw#192599) * fix(codex): keep native shell for session-tool denies by disabling native delegation * test(codex): live proof that hidden subagents keep the native shell without gateway fallback * test(codex): support API-key auth in the hidden subagent shell live proof * test(codex): spawn live-proof subagents through the parent model turn * fix(codex): fail closed when managed config pins native delegation on for session-tool denies Session-tool denies are enforced by disabling native delegation, so managed requirements or legacy managed layers that pin multi_agent/multi_agent_v2 on now fail the turn before inference. The live proof waits for the child settled reply and asserts delegation facts from the child native thread record. Docs updated; test lines allocated. * fix(codex): restore live-proof path import and keep delegation deny list private * fix(codex): reject structured and aliased managed delegation pins for session-tool denies A legacy managed layer can enable native delegation as [features.multi_agent_v2] enabled = true (reported as features.multi_agent_v2: {enabled: true} with its origin on .enabled) or through the collab alias. Preflight now recognizes boolean, table and alias forms and checks the origin of the enabled field, failing the turn before thread admission. Cases use config/read shapes captured from Codex 0.164.0. * test(codex): match test-line allocation after merging main
…ue_delegate is a safe deny Upstream openclaw#192599 (37d5c24) made the leaf subagent's session-tool denies safe under the Codex harness, enforcing them by disabling native delegation so the native shell stays. Continuation also denies continue_delegate to leaf subagents (agent-tools.policy.ts), and that name was absent from Codex's audited safe-deny list, so every leaf at the depth cap still fell back to the restricted native surface and lost the shell: upstream's own "leaf at the depth cap" case fails at 349dfb3. continue_delegate has no Codex-native counterpart; the harness enforces its deny by not exposing the dynamic tool. It joins the audited safe-deny list (not the native-delegation set: denying continuation delegates must not switch off Codex's own native agents), and the restricted-turns reference lists it. RED: codex-subagent-tool-policy.test.ts "leaf at the depth cap" fails at 349dfb3 and with this line reverted; GREEN with it (7/7), plus the cron continuation tool-policy test (2/2) and the Codex policy consumers. Refs #1271 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Hidden subagents carry the built-in session/conversation tool denies (
sessions_send,conversations_*, and for leavessessions_spawn,subagents, …). The Codex harness treats any deny outsideCODEX_TOOL_POLICY_SAFE_DENY_NAMESas restricted and disables the whole native Codex surface. On Gateways that also exclude the Gateway-local replacements (read/write/edit/apply_patch/exec/process), as OpenClaw Enterprise dedicated Gateways do, a hidden subagent ends up with no shell or file tools at all.Change
CODEX_NATIVE_DELEGATION_DENY_NAMESinextensions/codex/native-tool-policy.ts).agents.enabled=falseand bothmulti_agentfeature flags off (isCodexNativeDelegationDisabledForRun). Those are the native counterparts (spawn_agent,send_input,resume_agent, v2 cross-thread) that can address other threads.Related: #192369 handles visible spawned sessions separately. This PR does not change subagent identity, inherited/operator restrictions, depth or child limits.
Real behavior proof
Opt-in live test
src/gateway/gateway-codex-subagent-shell.live.test.ts(OPENCLAW_LIVE_CODEX_SUBAGENT_SHELL=1). It starts a real Gateway and the real Codex app-server (0.164.0) with the OCE-equivalentcodexDynamicToolsExcludefor the Gateway-local tools. The parent session's own model turn spawns hidden subagents withsessions_spawn, as user sessions do. The test then checks:spawn_agent. The test reads the native thread records Codex wrote and requires exactly one child thread with all of the following:multi_agent_version: "disabled"in the thread metadata;spawn_agent/send_input/resume_agent/send_message/followup_task/wait_agent/list_agents/interrupt_agent/close_agentin the tools the model was given;Model
openai/gpt-6.1-solthrough an OpenAI-compatible router configured as a Codex native-command provider in isolated test state, on Linux.SUBAGENT-SHELL-8A6A3B)multi_agent_version: disabled, no delegation tools, no delegation calls, no helper threadmain@ bf10667 (earlier run, same shell probe)NO-SHELL-TOOLS, file not writtenFor contrast, the same run's top-level parent threads (no session-tool deny) were given
spawn_agent,send_message,followup_task,wait_agent,list_agentsandinterrupt_agent. Top-level sessions keep native delegation.Managed configuration cannot re-enable delegation. When a session-tool deny is active, preflight rejects the turn before thread admission in two cases:
featureRequirements) pinmulti_agent,multi_agent_v2orcollabon.multi_agent_v2 = true, the structured table[features.multi_agent_v2] enabled = true(reported asfeatures.multi_agent_v2: {enabled: true}with its origin on.enabled), or thecollabalias.This follows the existing
image_generate→image_generationpattern. The unit cases (thread-lifecycle-managed-feature-pins.test-support.ts, run by the binding suite) use theconfig/readshapes captured from the real Codex 0.164.0 app-server with/etc/codex/managed_config.toml. A session-overridable layer enabling V2 is still admitted, because OpenClaw'sfalsewins there.Live proof for managed pins and resume after tightening. Uncommitted test; source and full results are in the PR comments.
c5c6c55c/etc/codex/managed_config.toml=[features.multi_agent_v2] enabled = true, agent deniessessions_send(Docker, root-owned/etc/codex)multi_agent_version: "v2",spawn_agentoffered and called, helper thread startedCodex tool policy cannot override managed feature multi_agent_v2, 0 native threadstools.deny: ["sessions_send"], Gateway restart, session resumes and is told to callspawn_agentmulti_agent_version: "disabled"and no delegation tools; no delegation calls, no helper threadLimits of this proof
Tests
Managed-pin preflight cases (requirements and legacy layer) for
multi_agent,multi_agent_v2andcollab, alongside the existingimage_generationcase.Targeted unit tests:
codex-subagent-tool-policy.test.ts,thread-prompt.test.tsand related policy tests, covering subagent, visible spawn, capped subagent,sessions_senddeny, and an unrelated deny (nodes) still disabling the native surface.Live test above (opt-in).
Docs:
docs/plugins/codex-harness-reference/restricted-turns.mdnow lists the session/conversation safe denies and explains delegation-only denial.Test lines: 250 net, allocated in
config/test-lines-allocations/codex-subagent-native-shell-delegation-deny.txt. The ratchet's remaining overage (137) ismain's own.