diff --git a/plugins/codex/commands/rescue.md b/plugins/codex/commands/rescue.md index c92a2896..56de9555 100644 --- a/plugins/codex/commands/rescue.md +++ b/plugins/codex/commands/rescue.md @@ -1,11 +1,11 @@ --- description: Delegate investigation, an explicit fix request, or follow-up rescue work to the Codex rescue subagent argument-hint: "[--background|--wait] [--resume|--fresh] [--model ] [--effort ] [what Codex should investigate, solve, or continue]" -context: fork -allowed-tools: Bash(node:*), AskUserQuestion +allowed-tools: Bash(node:*), AskUserQuestion, Agent --- -Route this request to the `codex:codex-rescue` subagent. +Invoke the `codex:codex-rescue` subagent via the `Agent` tool (`subagent_type: "codex:codex-rescue"`), forwarding the raw user request as the prompt. +`codex:codex-rescue` is a subagent, not a skill — do not call `Skill(codex:codex-rescue)` (no such skill) or `Skill(codex:rescue)` (that re-enters this command and hangs the session). The command runs inline so the `Agent` tool stays in scope; forked general-purpose subagents do not expose it. The final user-visible response must be Codex's output verbatim. Raw user request: diff --git a/tests/commands.test.mjs b/tests/commands.test.mjs index ef5adb09..3724ffa4 100644 --- a/tests/commands.test.mjs +++ b/tests/commands.test.mjs @@ -90,7 +90,16 @@ test("rescue command absorbs continue semantics", () => { const runtimeSkill = read("skills/codex-cli-runtime/SKILL.md"); assert.match(rescue, /The final user-visible response must be Codex's output verbatim/i); - assert.match(rescue, /allowed-tools:\s*Bash\(node:\*\),\s*AskUserQuestion/); + assert.match(rescue, /allowed-tools:\s*Bash\(node:\*\),\s*AskUserQuestion,\s*Agent/); + // Regression for #234: `Skill(codex:rescue)` from the main agent recursed + // because rescue.md named the routing with ambiguous prose ("Route this + // request to the `codex:codex-rescue` subagent") while running under + // `context: fork` — forked general-purpose subagents do not expose the + // `Agent` tool, so the fork fell back to `Skill` and re-entered this + // command. Pin the explicit transport and the inline (no-fork) execution. + assert.match(rescue, /subagent_type: "codex:codex-rescue"/); + assert.match(rescue, /do not call `Skill\(codex:codex-rescue\)`/i); + assert.doesNotMatch(rescue, /^context:\s*fork\b/m); assert.match(rescue, /--background\|--wait/); assert.match(rescue, /--resume\|--fresh/); assert.match(rescue, /--model /); @@ -165,9 +174,9 @@ test("result and cancel commands are exposed as deterministic runtime entrypoint const resultHandling = read("skills/codex-result-handling/SKILL.md"); assert.match(result, /disable-model-invocation:\s*true/); - assert.match(result, /codex-companion\.mjs" result \$ARGUMENTS/); + assert.match(result, /codex-companion\.mjs" result "\$ARGUMENTS"/); assert.match(cancel, /disable-model-invocation:\s*true/); - assert.match(cancel, /codex-companion\.mjs" cancel \$ARGUMENTS/); + assert.match(cancel, /codex-companion\.mjs" cancel "\$ARGUMENTS"/); assert.match(resultHandling, /do not turn a failed or incomplete Codex run into a Claude-side implementation attempt/i); assert.match(resultHandling, /if Codex was never successfully invoked, do not generate a substitute answer at all/i); });