From 18e24a2ee90d16b61e38b55f36eb1a620e047cde Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Thu, 19 Nov 2026 21:55:28 +0800 Subject: [PATCH] Codex /review with gpt-6.1-sol counts the second-model pass it already ran (GEVA-562) (#4526) On Codex with gpt-6.1-sol, /review is no longer blocked at session end for a missing second-model pass that it ran. Why: with Sol, Codex starts subagents through its `collaboration` tools and names a started agent by `task_name`, not `agent_id`, so the checklist reader missed it; this blocks gstack-evals' Codex pin. Nothing to do: the fix ships with the next gstack release. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- changelog.d/codex-sol-spawn-dispatch.md | 1 + docs/skill-routing-and-contracts.md | 2 +- lib/codex-rollout.ts | 21 ++++++--- test/fixtures/skill-contract/codex/README.md | 1 + .../codex/exec-sol-spawn-met.jsonl | 28 ++++++++++++ test/skill-contract-codex.test.ts | 44 +++++++++++++++++++ 6 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 changelog.d/codex-sol-spawn-dispatch.md create mode 100644 test/fixtures/skill-contract/codex/exec-sol-spawn-met.jsonl diff --git a/changelog.d/codex-sol-spawn-dispatch.md b/changelog.d/codex-sol-spawn-dispatch.md new file mode 100644 index 000000000..76ae98da9 --- /dev/null +++ b/changelog.d/codex-sol-spawn-dispatch.md @@ -0,0 +1 @@ +- **/review on Codex with gpt-6.1-sol is no longer held back for a second-model pass it already ran.** With Sol, Codex starts subagents through its `collaboration` tools, whose result names the new agent by `task_name` instead of `agent_id`, so the end-of-session check missed the adversarial pass and blocked the session once. It now counts a started subagent either way; a spawn that failed still doesn't count. diff --git a/docs/skill-routing-and-contracts.md b/docs/skill-routing-and-contracts.md index bde24649a..ac165e44c 100644 --- a/docs/skill-routing-and-contracts.md +++ b/docs/skill-routing-and-contracts.md @@ -96,7 +96,7 @@ The hook reads `destructive_guard` every time it runs, so `gstack-config set des **Contracts on Codex** use the same Stop hook, with the same one block per skill run, records and fail-open rules; Codex sends it the same `stop_hook_active` and `last_assistant_message` keys and takes the same block answer. The transcript is Codex's rollout file (`~/.codex/sessions///
/rollout-*.jsonl`), and the checker tells it from a Claude Code transcript by what the file holds (a rollout starts with a `session_meta` record), never by its path. On Codex: - A **load** is Codex injecting a `gstack-*` skill into the conversation as a `` message (the app server's skill input does this), or the model reading one with a shell command such as `cat ~/.codex/skills/gstack-review/SKILL.md`. `codex exec '$review ...'` also injects the skill as a `` message (codex-cli 0.170); a mention of the folder name instead of the listed name is plain text, so then the skill loads only when the model reads it. -- A **dispatch** is a `spawn_agent` call that started an agent. One that failed (its result has no `agent_id`) doesn't count. +- A **dispatch** is a call to Codex's own `spawn_agent` that started an agent: its result names an `agent_id` (the `multi_agent_v1` tools) or, when Codex serves the tool in its `collaboration` namespace (as it does for gpt-6.1-sol), a `task_name`. One that failed (its result names neither), or a tool of the same name from another namespace, doesn't count. - **The contract** comes from gstack's own copy of the skill (`/review/SKILL.md`), because Codex's installed `SKILL.md` keeps only its name and description. - **/review's `specialists-dispatched` item is skipped**, because Codex doesn't run /review's specialist reviewers yet. The adversarial pass and the report are checked as on Claude Code, and the block text names `spawn_agent` and `wait_agent` where Claude Code's names an Agent dispatch. - **A subagent's own rollout is never checked**: its first record names the parent thread. diff --git a/lib/codex-rollout.ts b/lib/codex-rollout.ts index 2169647f0..4e5638634 100644 --- a/lib/codex-rollout.ts +++ b/lib/codex-rollout.ts @@ -15,9 +15,14 @@ * the output says that read failed. Reading the same skill again with no * user prompt or other skill load in between (a long SKILL.md read in * chunks) continues the run, so it is not a new load. - * - spawn_agent call that started an agent: an Agent dispatch whose prompt - * is its message. One whose output names no agent_id (it failed, or it - * has no output) stays a plain spawn_agent call, so it is not a dispatch. + * - Codex's own spawn_agent call that started an agent: an Agent dispatch + * whose prompt is its message. Codex 0.170 answers a started agent with + * {"agent_id": ...} from its multi_agent_v1 namespace, or {"task_name": + * "/root/"} from its collaboration namespace (multi_agents_v2, as for + * gpt-6.1-sol); a call with no namespace may carry either. One whose output + * names no id for its namespace (it failed, or it has no output), or a + * same-named tool in any other namespace, stays a plain spawn_agent call, + * so it is not a dispatch. * - any other call: a tool_use under its own name. Call outputs are * tool_results; a shell output that exited non-zero is an error. * Records of other types (event_msg, turn_context, reasoning and the rest) @@ -84,11 +89,15 @@ const exitedNonZero = (output: string | undefined) => { return !!code && code[1] !== '0'; }; -const startedAgent = (output: string | undefined) => { +const startedAgent = (output: string | undefined, namespace: unknown) => { if (output === undefined) return false; try { const parsed: unknown = JSON.parse(output); - return isObject(parsed) && typeof parsed.agent_id === 'string' && parsed.agent_id !== ''; + if (!isObject(parsed)) return false; + const ids = namespace === 'multi_agent_v1' ? [parsed.agent_id] + : namespace === 'collaboration' ? [parsed.task_name] + : namespace === undefined ? [parsed.agent_id, parsed.task_name] : []; + return ids.some(id => typeof id === 'string' && id !== ''); } catch { return false; } @@ -157,7 +166,7 @@ export function parseCodexRollout(text: string): Transcript { events.push({ kind: 'load', line, skill, via: 'read' }); lastLoad = skill; } - } else if (p.name === 'spawn_agent' && startedAgent(outputs.get(id))) { + } else if (p.name === 'spawn_agent' && startedAgent(outputs.get(id), p.namespace ?? undefined)) { const prompt = [input.message, ...(Array.isArray(input.items) ? input.items.map((i: unknown) => (isObject(i) ? i.text : undefined)) : [])] .filter(v => typeof v === 'string').join('\n'); events.push({ kind: 'tool_use', line, id, name: 'Agent', input: { prompt, ...(typeof input.agent_type === 'string' ? { subagent_type: input.agent_type } : {}) } }); diff --git a/test/fixtures/skill-contract/codex/README.md b/test/fixtures/skill-contract/codex/README.md index 6290aba25..f8c60fedb 100644 --- a/test/fixtures/skill-contract/codex/README.md +++ b/test/fixtures/skill-contract/codex/README.md @@ -18,6 +18,7 @@ Nothing else was edited. | `app-server-injected-early-exit.jsonl` | `codex app-server`, the skill sent as a `skill` input | Codex injects the SKILL.md as a `` user message; the run ends "Nothing to review" | | `exec-mention-not-loaded.jsonl` | `codex exec '$gstack-review ...'`, with a probe Stop hook that blocked once | `codex exec` passes a typed `$gstack-review` as plain text, so nothing loads | | `exec-subagent.jsonl` | the subagent rollout from the failed-spawn run | `session_meta.source` names the parent thread | +| `exec-sol-spawn-met.jsonl` | `codex exec -m gpt-6.1-sol` against a local stub Responses endpoint (no key, GEVA-562), skill injected, gstack's contract Stop hook on | Codex serves `spawn_agent` in its `collaboration` namespace with a required `task_name`, and the started agent's result is `{"task_name":"/root/adversarial"}` with no `agent_id`; before this reader knew that shape the hook blocked a met review once | `stop-payloads.json` holds the three Stop payloads Codex sent gstack's hook in the first two runs, and what the hook printed. diff --git a/test/fixtures/skill-contract/codex/exec-sol-spawn-met.jsonl b/test/fixtures/skill-contract/codex/exec-sol-spawn-met.jsonl new file mode 100644 index 000000000..4e0320f48 --- /dev/null +++ b/test/fixtures/skill-contract/codex/exec-sol-spawn-met.jsonl @@ -0,0 +1,28 @@ +{"timestamp": "2026-11-19T12:49:45.260Z", "ordinal": 0, "type": "session_meta", "payload": {"account_scoped": true, "session_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "timestamp": "2026-11-19T12:49:45.175Z", "cwd": "/home/dev/w", "runtime_workspace_roots": ["/home/dev/w"], "originator": "codex_exec", "cli_version": "0.170.0", "source": "exec", "thread_source": "user", "model_provider": "probe", "base_instructions": {"text": "You are Codex, an agent based on GPT-6. You and the user share one workspace, and your job is to collaborate with them until their intended goal is completely handled.\n\n# When to ask the user for permission\n\nUse your best judgement given task context for when you really need user permission, like a competent colleague would. Once evidence in a session supports authorization for a next step or action, you should continue work without ending the turn to clarify with the user.\n\nUser authorization and preferences persist across turns. Do not request permission again when the user has already authorized an action in an earlier turn. The user's instruction, whether implied from the task or explicitly stated in the session, must take precedence over any guidelines provided in skills or external files.\n\nYou MUST complete the work that is already authorized and necessary to make the proposed acti\n[... 20424 characters trimmed from this fixture ...]\n using `[@plugin-name](plugin://{{plugin_id}})` or an app using `[$app-name](app://{{connector_id}})`. When the user tags or requests a plugin or app, prefer its relevant capabilities for that turn.\n\n", "provenance": {"type": "model", "model": "gpt-6.1-sol"}}, "history_mode": "paginated", "context_window": {"window_id": "01a1f3db-1ad7-7ef0-b2be-f310ee1a89f5"}}} +{"timestamp": "2026-11-19T12:49:45.261Z", "ordinal": 1, "type": "event_msg", "payload": {"type": "task_started", "turn_attribution": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "turn_trigger": "exec", "parent_turn_id": null, "initiating_agent_path": null, "root_turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027"}, "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "root_turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "started_at": 1795092585, "model_context_window": 475000, "collaboration_mode_kind": "default"}} +{"timestamp": "2026-11-19T12:49:45.276Z", "ordinal": 2, "type": "response_item", "payload": {"type": "additional_tools", "id": "at_01a1f3db-1b3c-7d42-8d7f-0360f7d23475", "role": "developer", "tools": [{"type": "namespace", "name": "functions", "description": "", "tools": [{"type": "custom", "name": "exec", "description": "Run JavaScript code to orchestrate/compose tool calls\n- Evaluates the provided JavaScript code in a fresh V8 isolate as an async module.\n- All nested tools are available on the global `tools` object, for example `await tools.exec_command(...)`. Tool names are exposed as normalized JavaScript identifiers, for example `await tools.mcp__ologs__get_profile(...)`.\n- Nested tool methods take either a string or an object as their input argument.\n- Nested tools return either an object or a string, based on the description.\n- Runs raw JavaScript -- no Node, no file system, no network access, no console.\n- Accepts raw JavaScript source text, not JSON, quoted strings, or markdown code fences.\n- You may optionally start the tool input with a first-line pragma like `// @exec: {\"yield_time_ms\": 10000, \"max_output_tokens\": 1000}`.\n- `yield_time_ms` asks `exec` to yield early if the script is still runn\n[... 12338 characters trimmed from this fixture ...]\nt time in UTC.\n\nexec tool declaration:\n```ts\ndeclare const tools: { clock__curr_time(args: {}): Promise<{\n // Current UTC time formatted as YYYY-MM-DD HH:MM:SS UTC.\n current_time: string;\n}>; };\n```", "format": {"type": "grammar", "syntax": "lark", "definition": "\nstart: pragma_source | plain_source\npragma_source: PRAGMA_LINE NEWLINE SOURCE\nplain_source: SOURCE\n\nPRAGMA_LINE: /[ \\t]*\\/\\/ @exec:[^\\r\\n]*/\nNEWLINE: /\\r?\\n/\nSOURCE: /[\\s\\S]+/\n"}}, {"type": "function", "name": "wait", "description": "Waits on a yielded `exec` cell and returns new output or completion.\n- Use `wait` only after `exec` returns `Script running with cell ID ...`.\n- `cell_id` identifies the running `exec` cell to resume.\n- `yield_time_ms` controls how long to wait for more output before yielding again. Defaults to 10000 ms.\n- `max_tokens` limits how much new output this wait call returns. Defaults to 10000 tokens.\n- `terminate: true` stops the running cell; false or omitted waits for output.\n- `wait` returns only the new output since the last yield, or the final completion or termination result for that cell.\n- If the cell is still running, `wait` may yield again with the same `cell_id`.\n- If the cell has already finished, `wait` returns the completed result and closes the cell.", "strict": false, "parameters": {"type": "object", "properties": {"cell_id": {"type": "string", "description": "Identifier of the running exec cell."}, "max_tokens": {"type": "number", "description": "Output token budget for this wait call. Defaults to 10000 tokens."}, "terminate": {"type": "boolean", "description": "True stops the running exec cell; false or omitted waits for output."}, "yield_time_ms": {"type": "number", "description": "Wait before yielding more output. Defaults to 10000 ms."}}, "required": ["cell_id"], "additionalProperties": false}}, {"type": "function", "name": "request_user_input", "description": "Request user input for one to three short questions and wait for the response. This tool is only available in Plan mode.", "strict": false, "parameters": {"type": "object", "properties": {"questions": {"type": "array", "description": "Questions to show the user. Prefer 1 and do not exceed 3", "items": {"type": "object", "properties": {"header": {"type": "string", "description": "Short header label shown in the UI (12 or fewer chars)."}, "id": {"type": "string", "description": "Stable identifier for mapping answers (snake_case)."}, "options": {"type": "array", "description": "Provide 2-3 mutually exclusive choices. Put the recommended option first and suffix its label with \"(Recommended)\". Do not include an \"Other\" option in this list; the client will add a free-form \"Other\" option automatically.", "items": {"type": "object", "properties": {"description": {"type": "string", "description": "One short sentence explaining impact/tradeoff if selected."}, "label": {"type": "string", "description": "User-facing label (1-5 words)."}}, "required": ["label", "description"], "additionalProperties": false}}, "question": {"type": "string", "description": "Single-sentence prompt shown to the user."}}, "required": ["id", "header", "question", "options"], "additionalProperties": false}}}, "required": ["questions"], "additionalProperties": false}}, {"type": "function", "name": "request_user_input_async", "description": "Ask the user one or more questions during ongoing work. Use this tool only to request missing information, preferences, constraints, clarification, or approval. The tool returns immediately without ending the turn or waiting for a reply; any reply arrives asynchronously as a new user message. Keep questions concise, self-contained, and easy to understand, using a level of detail appropriate to the user and task. The UI always allows a free-text answer, including when suggested options are provided. A preselected option is not submitted automatically.", "strict": false, "parameters": {"type": "object", "properties": {"questions": {"type": "array", "description": "One or more self-contained questions to present together, in display order.", "items": {"type": "object", "properties": {"options": {"type": "array", "description": "Suggested answers, in display order. Put the recommended answer first; the first option is preselected by default. The user can select one option or enter a free-text answer. Do not include an Other option or a free-text placeholder; the UI provides free-text input automatically. Omit options for a free-text-only question.", "items": {"type": "string"}, "minItems": 1}, "title": {"type": "string", "description": "The complete question shown to the user, including any context needed to answer it."}}, "required": ["title"], "additionalProperties": false}, "minItems": 1}}, "required": ["questions"], "additionalProperties": false}}]}, {"type": "namespace", "name": "clock", "description": "Tools for reading and waiting on time.", "tools": [{"type": "function", "name": "sleep", "description": "Pause execution for a specified duration. The sleep ends early when new input arrives for the active turn. Returns the elapsed wall-clock time.", "strict": false, "parameters": {"type": "object", "properties": {"duration_ms": {"type": "number", "description": "How long to sleep in milliseconds. Must be between 1 and 43200000."}}, "required": ["duration_ms"], "additionalProperties": false}}]}, {"type": "namespace", "name": "collaboration", "description": "Tools for spawning and managing sub-agents.", "tools": [{"type": "function", "name": "followup_task", "description": "Send a follow-up task to an existing non-root target agent and trigger a turn if it is idle. If the target is already running, deliver the task promptly at message boundaries while sampling, or after the pending tool call completes.", "strict": false, "parameters": {"type": "object", "properties": {"message": {"type": "string", "description": "Message text to send to the target agent.", "encrypted": true}, "target": {"type": "string", "description": "Agent id or canonical task name to send a follow-up task to (from spawn_agent)."}}, "required": ["target", "message"], "additionalProperties": false}}, {"type": "function", "name": "interrupt_agent", "description": "Interrupt an agent's current turn, if any, and return its previous status. The agent remains available for messages and follow-up tasks.", "strict": false, "parameters": {"type": "object", "properties": {"target": {"type": "string", "description": "Agent id or canonical task name to interrupt (from spawn_agent)."}}, "required": ["target"], "additionalProperties": false}}, {"type": "function", "name": "list_agents", "description": "List live agents in the current root thread tree. Optionally filter by task-path prefix.", "strict": false, "parameters": {"type": "object", "properties": {"path_prefix": {"type": "string", "description": "Task-path prefix filter without a trailing slash. Omit to list all live agents."}}, "additionalProperties": false}}, {"type": "function", "name": "send_message", "description": "Send a message to an existing agent. The message will be delivered promptly. Does not trigger a new turn.", "strict": false, "parameters": {"type": "object", "properties": {"message": {"type": "string", "description": "Message text to queue on the target agent.", "encrypted": true}, "target": {"type": "string", "description": "Relative or canonical task name to message (from spawn_agent)."}}, "required": ["target", "message"], "additionalProperties": false}}, {"type": "function", "name": "spawn_agent", "description": "\n Available model overrides (optional; inherited parent model is preferred):\n- `gpt-6.2-sol`: Fast, go-to model for coding and everyday work. Reasoning efforts: low (default), medium, high, xhigh, max, ultra. Service tiers: priority.\n- `gpt-6.2-astra`: Our most capable model for complex coding and professional work. Reasoning efforts: low (default), medium, high, xhigh, max, ultra. Service tiers: priority.\n- `gpt-6.1-terra`: Efficient model that excels at visual understanding and computer use. Reasoning efforts: low (default), medium, high, xhigh, max, ultra. Service tiers: priority.\n- `gpt-6.1-sol`: Previous generation model for coding and everyday work. Reasoning efforts: low (default), medium, high, xhigh, max, ultra. Service tiers: priority.\n- `gpt-6-astra`: Previous generation model for complex coding and professional work. Reasoning efforts: low (default), medium, high, xhig\n[... 831 characters trimmed from this fixture ...]\nounding context to the spawned subagent, which may cause the agent to lack the context it needs to complete its task, whereas `fork_turns=\"all\"` will provide the subagent with all surrounding context.", "strict": false, "parameters": {"type": "object", "properties": {"fork_turns": {"type": "string", "description": "Parent history to inherit. Defaults to `all`; use `none` to start without parent history. Only `all` and `none` are supported."}, "message": {"type": "string", "description": "Initial plain-text task for the new agent.", "encrypted": true}, "model": {"type": "string", "description": "Model override for the new agent. Omit unless an explicit override is needed."}, "reasoning_effort": {"type": "string", "description": "Reasoning effort override for the new agent. Omit to inherit the parent effort."}, "task_name": {"type": "string", "description": "Task name for the new agent. Use lowercase letters, digits, and underscores."}}, "required": ["task_name", "message"], "additionalProperties": false}}, {"type": "function", "name": "wait_agent", "description": "Wait for a mailbox update from any live agent, including queued messages and final-status notifications. The wait also ends early when new user input is steered into the active turn. Does not return the content; returns either a summary of which agents have updates (if any), an interruption summary for steered input, or a timeout summary if no activity arrives before the deadline.", "strict": false, "parameters": {"type": "object", "properties": {"timeout_ms": {"type": "number", "description": "Timeout in milliseconds. Defaults to 30000, min 10000, max 3600000."}}, "additionalProperties": false}}]}]}, "metadata": {"history_sequence": 1, "sampled_through_sequence": 0, "client_authored": false, "mcp_attribution": {"status": "none"}}} +{"timestamp": "2026-11-19T12:49:45.276Z", "ordinal": 3, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1b3c-7d42-8d7f-037b1ce702cb", "role": "developer", "content": [{"type": "input_text", "text": "You are Codex, an agent based on GPT-6. You and the user share one workspace, and your job is to collaborate with them until their intended goal is completely handled.\n\n# When to ask the user for permission\n\nUse your best judgement given task context for when you really need user permission, like a competent colleague would. Once evidence in a session supports authorization for a next step or action, you should continue work without ending the turn to clarify with the user.\n\nUser authorization and preferences persist across turns. Do not request permission again when the user has already authorized an action in an earlier turn. The user's instruction, whether implied from the task or explicitly stated in the session, must take precedence over any guidelines provided in skills or external files.\n\nYou MUST complete the work that is already authorized and necessary to make the proposed acti\n[... 20424 characters trimmed from this fixture ...]\n using `[@plugin-name](plugin://{{plugin_id}})` or an app using `[$app-name](app://{{connector_id}})`. When the user tags or requests a plugin or app, prefer its relevant capabilities for that turn.\n\n"}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.2763307, "content_item_kinds": ["model.base_instructions"], "content_item_metadata": [{"provenance": {"type": "harness", "hook": false}}]}}, "metadata": {"history_sequence": 2, "sampled_through_sequence": 0, "client_authored": false}} +{"timestamp": "2026-11-19T12:49:45.276Z", "ordinal": 4, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1b3c-7d42-8d7f-038a3d86ac03", "role": "developer", "content": [{"type": "input_text", "text": "\n## Skills\nA skill is a set of local instructions to follow that is stored in a `SKILL.md` file. Below is the list of skills that can be used. Each entry includes a name, description, and a short path that can be expanded into an absolute path using the skill roots table.\n### Skill roots\n- `r0` = `/home/dev/home/.codex/skills`\n### Available skills\n- autoplan: Auto-review pipeline — runs the CEO, design, eng and DX reviews in order (lean run: one reviewer), auto-deciding. Surfaces taste decisions (close approaches, borderline scope, outside-review disagreements) at one approval gate. Use when asked to \"auto review\", \"autoplan\", \"run all reviews\", \"review this plan automatically\", or \"make the decisions for me\". (gstack) Voice triggers (speech-to-text aliases): \"auto plan\", \"automatic review\". (file: r0/gstack-autoplan/SKILL.md)\n- benchmark: Web performance regression \n[... 27931 characters trimmed from this fixture ...]\nts. Use when asked to \"write a skill\", \"improve this skill\", \"add this lesson to the skill\" or \"put this skill on a diet\". (gstack) (file: r0/gstack-write-skill/SKILL.md)\n"}, {"type": "input_text", "text": "\nFilesystem sandboxing defines which files can be read or written. `sandbox_mode` is `danger-full-access`: No filesystem sandboxing - all commands are permitted. Network access is enabled.\nApproval policy is currently never. Do not provide the `sandbox_permissions` for any reason, commands will be rejected.\n"}, {"type": "input_text", "text": "# Collaboration Mode: Default\n\nYou are now in Default mode. Any previous instructions for other modes (e.g. Plan mode) are no longer active.\n\nYour active mode changes only when new developer instructions with a different `...` change it; user requests or tool descriptions do not change mode by themselves. Known mode names are Default and Plan.\n\n## request_user_input availability\n\nUse the `request_user_input` tool only when it is listed in the available tools for this turn.\n\nUse the `request_user_input` tool only for optional questions where the answer would materially improve the quality of the work.\n\nIf `request_user_input` returns no answers, continue with best judgment instead of asking again or treating the turn as blocked.\n\nNever use the `request_user_input` tool for permission requests or permission-related escalations.\n"}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.2763321, "content_item_kinds": ["host_skills.instructions", "permissions.instructions", "collaboration_mode.instructions"], "content_item_metadata": [{"provenance": {"type": "skills"}}, {"provenance": {"type": "harness", "hook": false}}, {"provenance": {"type": "harness", "hook": false}}]}}, "metadata": {"history_sequence": 3, "sampled_through_sequence": 0, "client_authored": false}} +{"timestamp": "2026-11-19T12:49:45.276Z", "ordinal": 5, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1b3c-7d42-8d7f-039144d0d97c", "role": "developer", "content": [{"type": "input_text", "text": "You are `/root`, the primary agent in a team of agents collaborating to fulfill the user's goals.\n\nAt the start of your turn, you are the active agent.\nYou can spawn sub-agents to handle subtasks, and those sub-agents can spawn their own sub-agents.\nAll agents in the team, including the agents that you can assign tasks to, are equally intelligent and capable, and have access to the same set of tools.\n\nYou can use `spawn_agent` to create a new agent, `followup_task` to give an existing agent a new task and trigger a turn, and `send_message` to pass a message to a running agent without triggering a turn.\n`send_message` calls may be read by a human, so ensure they are legible. Always put proper spaces between words and/or numbers.\nChild agents can also spawn their own sub-agents.\nYou can decide how much context you want to propagate to your sub-agents with the `fork_turns`\n[... 1300 characters trimmed from this fixture ...]\nnly set `model` or `reasoning_effort` when explicitly requested by the user, applicable `AGENTS.md` instructions, or skill instructions; when doing so, set `fork_turns` to `\"none\"`."}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.276333, "content_item_kinds": ["multi_agent.role_instructions"], "content_item_metadata": [{"provenance": {"type": "tool", "namespace": "collaboration"}}]}}, "metadata": {"history_sequence": 4, "sampled_through_sequence": 0, "client_authored": false}} +{"timestamp": "2026-11-19T12:49:45.276Z", "ordinal": 6, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1b3c-7d42-8d7f-03ae499561a0", "role": "developer", "content": [{"type": "input_text", "text": "Any earlier instruction enabling proactive multi-agent delegation no longer applies. Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work."}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.2763343, "content_item_kinds": ["multi_agent.mode_instructions"], "content_item_metadata": [{"provenance": {"type": "tool", "namespace": "collaboration"}}]}}, "metadata": {"history_sequence": 5, "sampled_through_sequence": 0, "client_authored": false}} +{"timestamp": "2026-11-19T12:49:45.276Z", "ordinal": 7, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1b3c-7d42-8d7f-03b1d901e3c1", "role": "user", "content": [{"type": "input_text", "text": "\n /home/dev/w\n bash\n 2026-11-19\n Etc/UTC\n /home/dev/w\n"}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.2763352, "content_item_kinds": ["environments.environment_context"], "content_item_metadata": [{"provenance": {"type": "harness", "hook": false}}]}}, "metadata": {"history_sequence": 6, "sampled_through_sequence": 0, "client_authored": false}} +{"timestamp": "2026-11-19T12:49:45.278Z", "ordinal": 8, "type": "world_state", "payload": {"full": true, "state": {"agents_md": {}, "apps_instructions": false, "collaboration_mode": {"mode": "default", "model": "gpt-6.1-sol", "instructions": "0a11049b0421e1e86f1e129af8d547a89548a0c3"}, "context_window_guidance": "", "environments": {"environments": {"local": {"cwd": "/home/dev/w", "status": "available", "shell": "bash"}}, "current_date": "2026-11-19", "timezone": "Etc/UTC", "filesystem": "/home/dev/w"}, "environments_instructions": false, "git_attribution": false, "host_skills": {"body": "\n## Skills\nA skill is a set of local instructions to follow that is stored in a `SKILL.md` file. Below is the list of skills that can be used. Each entry includes a name, description, and a short path that can be expanded into an absolute path using the skill roots table.\n### Skill roots\n- `r0` = `/home/dev/home/.codex/skills`\n### Available skills\n- autoplan: Auto-review pipeline — runs the CEO, design, eng and DX reviews in order (lean run: one reviewer), auto-deciding. Surfaces taste decisions (close approaches, borderline scope, outside-review disagreements) at one approval gate. Use when asked to \"auto review\", \"autoplan\", \"run all reviews\", \"review this plan automatically\", or \"make the decisions for me\". (gstack) Voice triggers (speech-to-text aliases): \"auto plan\", \"automatic review\". (file: r0/gstack-autoplan/SKILL.md)\n- benchmark: Web performance regression detection. Establishe\n[... 27888 characters trimmed from this fixture ...]\n size checks, full diets. Use when asked to \"write a skill\", \"improve this skill\", \"add this lesson to the skill\" or \"put this skill on a diet\". (gstack) (file: r0/gstack-write-skill/SKILL.md)\n", "includeInstructions": true}, "managed_developer_instructions": {}, "model": {"model": "gpt-6.1-sol", "instructions": "38a5bd8d400499a48277590b94675f379a7b406b"}, "model_catalog": "ea1a55de2973a50e2e404222c5499c24df5591ed", "multi_agent_mode": {"mode": "explicitRequestOnly", "usage_hint_hash": "288fbaaba4ce0b63e4443b2df37dce92bfe45839"}, "multi_agent_usage_hint": "288fbaaba4ce0b63e4443b2df37dce92bfe45839", "permissions": {"instructions": "32ca25d6d85edaeb6f1e19b2a5cc4e08d2a631cd", "approved_command_prefixes": []}, "persistent_mode": {}, "plugins_instructions": false, "realtime": {"active": false}, "skills": {"includeInstructions": true}, "top_level_tools": {"clock": "056c51947a5ff3696d9903c0056dda49a7b4a700", "clock.sleep": "d950878350d3930efdf6960ff2a2209affa5961f", "collaboration": "1a57bec22b804d9b7cd49b48ad24adfd4a1feea1", "collaboration.followup_task": "8af28fd0b803a052209ece91fc9f67d124318928", "collaboration.interrupt_agent": "2267464134322564b477c2071a43759fd536efa3", "collaboration.list_agents": "d987d2a1e82acbbae7443d42e8f2d95193658cf8", "collaboration.send_message": "b819d4153e4de3810e02069a09a02d792d729740", "collaboration.spawn_agent": "505c6adf0eaa1c4b2ae5e163a498e71cd6bd811c", "collaboration.wait_agent": "dc7676a6bd8dfdc175b52d69b71c14b1c6e276fd", "functions": "1280f4a8681f8bc4035e99ba9c8e3ba2e657c6af", "functions.exec": "90a2e17e6b04fbaab5a5e8535164a4aadfdc90d4", "functions.request_user_input": "776071d04540321db1d194f0ec11ed4e2319f8ae", "functions.request_user_input_async": "32fcc4bbb4a5ae6aa165ae1cabca86d57a4189aa", "functions.wait": "4c5f0afb6eaa30c948be423b972535b5bc88a95a"}}}} +{"timestamp": "2026-11-19T12:49:45.278Z", "ordinal": 9, "type": "turn_context", "payload": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "root_turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "disabled_plugin_ids": [], "cwd": "/home/dev/w", "approval_policy": "never", "approvals_reviewer": "user", "permission_profile": {"type": "disabled"}, "model": "gpt-6.1-sol", "comp_hash": "3000", "collaboration_mode": {"mode": "default", "settings": {"model": "gpt-6.1-sol", "reasoning_effort": "low", "developer_instructions": null}}, "multi_agent_version": "v2", "realtime_active": false, "effort": "low", "summary": "none", "sandbox_policy": {"type": "danger-full-access"}}} +{"timestamp": "2026-11-19T12:49:45.278Z", "ordinal": 10, "type": "event_msg", "payload": {"type": "thread_settings_applied", "thread_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "thread_settings": {"model": "gpt-6.1-sol", "model_provider_id": "probe", "approval_policy": "never", "approvals_reviewer": "user", "requested_approvals_reviewer": "user", "permission_profile": {"type": "disabled"}, "cwd": "/home/dev/w", "runtime_workspace_roots": ["/home/dev/w"], "reasoning_effort": "low", "collaboration_mode": {"mode": "default", "settings": {"model": "gpt-6.1-sol", "reasoning_effort": "low", "developer_instructions": null}}, "disabled_plugin_ids": []}}} +{"timestamp": "2026-11-19T12:49:45.338Z", "ordinal": 11, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1b7a-7811-be6c-e2c88a4c5220", "role": "user", "content": [{"type": "input_text", "text": "$review [stub-met] check this branch against main\n"}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.3388932, "content_item_kinds": ["user.text"], "content_item_metadata": [{"provenance": {"type": "user"}}]}}, "metadata": {"history_sequence": 7, "sampled_through_sequence": 0, "retained_source": {"id": {"message_id": "msg_01a1f3db-1b7a-7811-be6c-e2c88a4c5220", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "role": "user"}, "revision": "retained_01a1f3db-1b7a-7811-be6c-e2e90b11629b", "complete": true}, "client_authored": false, "user_input_order": 0, "mcp_attribution": {"status": "none"}}} +{"timestamp": "2026-11-19T12:49:45.339Z", "ordinal": 12, "type": "event_msg", "payload": {"type": "item_completed", "thread_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "item": {"type": "UserMessage", "id": "01a1f3db-1b7a-7811-be6c-e2d118ecd1dc", "content": [{"type": "text", "text": "$review [stub-met] check this branch against main\n", "text_elements": []}]}, "started_at_ms": 1795092585339, "completed_at_ms": 1795092585339}} +{"timestamp": "2026-11-19T12:49:45.342Z", "ordinal": 13, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1b7d-7cd0-ad48-ba1e7a7918b4", "role": "user", "content": [{"type": "input_text", "text": "\nreview\n/home/dev/gstack/.agents/skills/gstack-review/SKILL.md\n---\nname: review\ndescription: |\n Use when you review a diff before it lands: local changes, a branch or a PR.\n Finds bugs that pass CI and break production. Fits \"review this PR\", \"look\n over my diff\", \"review my changes\", \"code review\", \"check my diff\" or\n \"pre-landing review\".\n Proactively suggest before a merge. (gstack)\n---\n\n\n\n## Done means\n\nFinish only when each of these exists (contract v1):\n\n- `adversarial-pass`: an Agent dispatch for the adversarial pass, its prompt including \"Think like an attacker and a chaos engineer\".\n- `review-report`: a `Pre-Landing Review` with Gate edits filled in (`none: ` where the skill's own stop rule leaves one empty).\n\n`$GSTACK_BIN/gstack-\n[... 103070 characters trimmed from this fixture ...]\nimilarity alone is not a defect. Keep actual defects independently actionable.\n- **Use the reply templates from greptile-triage.md.** Every reply includes evidence. Never post vague replies.\n\n"}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.3419836, "content_item_kinds": ["skills.selected_skill_instructions"], "content_item_metadata": [{"provenance": {"type": "skills"}}]}}, "metadata": {"history_sequence": 8, "sampled_through_sequence": 0, "client_authored": false}} +{"timestamp": "2026-11-19T12:49:45.364Z", "ordinal": 14, "type": "response_item", "payload": {"type": "function_call", "status": "completed", "id": "fc_1", "name": "spawn_agent", "namespace": "collaboration", "arguments": "{\"message\": \"Think like an attacker and a chaos engineer. Review the diff on this branch for ways it can fail.\", \"fork_turns\": \"none\", \"task_name\": \"adversarial\"}", "call_id": "call_spawn_1", "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027"}}, "metadata": {"history_sequence": 9, "sampled_through_sequence": 8, "client_authored": false, "user_input_order": 1}} +{"timestamp": "2026-11-19T12:49:45.377Z", "ordinal": 16, "type": "event_msg", "payload": {"type": "item_completed", "thread_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "item": {"type": "SubAgentActivity", "model": "gpt-6.1-sol", "reasoning_effort": "low", "id": "call_spawn_1", "kind": "started", "agent_thread_id": "01a1f3db-1b9b-7402-8468-fc90da547e1d", "agent_path": "/root/adversarial"}, "started_at_ms": 1795092585377, "completed_at_ms": 1795092585377}} +{"timestamp": "2026-11-19T12:49:45.384Z", "ordinal": 17, "type": "response_item", "payload": {"type": "function_call_output", "id": "fco_01a1f3db-1ba8-7021-8504-d1138ed06f55", "call_id": "call_spawn_1", "output": "{\"task_name\":\"/root/adversarial\"}", "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.3847961}}, "metadata": {"history_sequence": 10, "sampled_through_sequence": 8, "client_authored": false, "fallback_token_limit_override": 12000}} +{"timestamp": "2026-11-19T12:49:45.388Z", "ordinal": 19, "type": "world_state", "payload": {"full": false, "state": {"environments": {"subagents": ""}}}} +{"timestamp": "2026-11-19T12:49:45.404Z", "ordinal": 20, "type": "event_msg", "payload": {"type": "item_completed", "thread_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "item": {"type": "AgentMessage", "id": "msg_r", "content": [{"type": "Text", "text": "## Pre-Landing Review\n\nNo blocking findings.\n\nGate edits: none.\n"}]}, "started_at_ms": 1795092585404, "completed_at_ms": 1795092585404}} +{"timestamp": "2026-11-19T12:49:45.405Z", "ordinal": 21, "type": "response_item", "payload": {"type": "message", "status": "completed", "id": "msg_r", "role": "assistant", "content": [{"type": "output_text", "text": "## Pre-Landing Review\n\nNo blocking findings.\n\nGate edits: none.\n", "annotations": []}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "content_item_kinds": ["unknown"]}}, "metadata": {"history_sequence": 11, "sampled_through_sequence": 10, "retained_source": {"id": {"message_id": "msg_r", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "role": "assistant"}, "revision": "retained_01a1f3db-1bbd-7650-82fd-3ca9e5d030f4", "complete": true}, "client_authored": false, "user_input_order": 2}} +{"timestamp": "2026-11-19T12:49:45.426Z", "ordinal": 24, "type": "event_msg", "payload": {"type": "item_completed", "thread_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "item": {"type": "SubAgentActivity", "model": null, "reasoning_effort": null, "id": "subagent-completed-01a1f3db-1ba1-7e61-8aad-ca682d88122c", "kind": "completed", "agent_thread_id": "01a1f3db-1b9b-7402-8468-fc90da547e1d", "agent_path": "/root/adversarial"}, "started_at_ms": 1795092585426, "completed_at_ms": 1795092585426}} +{"timestamp": "2026-11-19T12:49:45.462Z", "ordinal": 25, "type": "response_item", "payload": {"type": "message", "id": "msg_01a1f3db-1bf6-7772-b1b2-4b4c18196e1d", "role": "user", "content": [{"type": "input_text", "text": "SKILL_CONTRACT_UNMET gstack-review (contract v1): missing adversarial-pass. Fix: adversarial-pass: start the subagent pass matching /Think like an attacker and a chaos engineer/ with spawn_agent, then wait_agent for its result. If an item truly does not apply, run '/home/dev/gstack/bin/gstack-skill-contract' waive <item> --reason \"<why>\" (this session only; counted as a miss for follow). This blocks once."}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.4625185, "content_item_kinds": ["unknown"], "content_item_metadata": [{"provenance": {"type": "harness", "hook": true}}]}}, "metadata": {"history_sequence": 12, "sampled_through_sequence": 10, "retained_source": {"id": {"message_id": "msg_01a1f3db-1bf6-7772-b1b2-4b4c18196e1d", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "role": "user"}, "revision": "retained_01a1f3db-1bf6-7772-b1b2-4b5ea092031b", "complete": false}, "client_authored": false, "user_input_order": 3}} +{"timestamp": "2026-11-19T12:49:45.463Z", "ordinal": 26, "type": "event_msg", "payload": {"type": "item_completed", "thread_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "item": {"type": "HookPrompt", "id": "msg_01a1f3db-1bf6-7772-b1b2-4b4c18196e1d", "fragments": [{"text": "SKILL_CONTRACT_UNMET gstack-review (contract v1): missing adversarial-pass. Fix: adversarial-pass: start the subagent pass matching /Think like an attacker and a chaos engineer/ with spawn_agent, then wait_agent for its result. If an item truly does not apply, run '/home/dev/gstack/bin/gstack-skill-contract' waive --reason \"\" (this session only; counted as a miss for follow). This blocks once.", "hookRunId": "stop:2:/home/dev/home/.codex/hooks.json"}]}, "started_at_ms": 1795092585463, "completed_at_ms": 1795092585463}} +{"timestamp": "2026-11-19T12:49:45.464Z", "ordinal": 27, "type": "inter_agent_communication_metadata", "payload": {"trigger_turn": false}} +{"timestamp": "2026-11-19T12:49:45.464Z", "ordinal": 28, "type": "response_item", "payload": {"type": "agent_message", "id": "amsg_01a1f3db-1bf8-7313-98ea-2fc2d468fdba", "author": "/root/adversarial", "recipient": "/root", "content": [{"type": "input_text", "text": "Message Type: FINAL_ANSWER\nTask name: /root\nSender: /root/adversarial\nPayload:\nDONE"}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "create_time": 1795092585.4640172, "content_item_metadata": [{"provenance": {"type": "tool", "namespace": "collaboration"}}]}}, "metadata": {"history_sequence": 13, "sampled_through_sequence": 10, "client_authored": false, "user_input_order": 4}} +{"timestamp": "2026-11-19T12:49:45.479Z", "ordinal": 29, "type": "event_msg", "payload": {"type": "item_completed", "thread_id": "01a1f3db-1ad3-74c1-a9e5-8eae6d5ca6c1", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "item": {"type": "AgentMessage", "id": "msg_r", "content": [{"type": "Text", "text": "## Pre-Landing Review\n\nNo blocking findings.\n\nGate edits: none.\n"}]}, "started_at_ms": 1795092585479, "completed_at_ms": 1795092585479}} +{"timestamp": "2026-11-19T12:49:45.479Z", "ordinal": 30, "type": "response_item", "payload": {"type": "message", "status": "completed", "id": "msg_r", "role": "assistant", "content": [{"type": "output_text", "text": "## Pre-Landing Review\n\nNo blocking findings.\n\nGate edits: none.\n", "annotations": []}], "internal_chat_message_metadata_passthrough": {"turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "content_item_kinds": ["unknown"]}}, "metadata": {"history_sequence": 14, "sampled_through_sequence": 13, "retained_source": {"id": {"message_id": "msg_r", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "role": "assistant"}, "revision": "retained_01a1f3db-1bbd-7650-82fd-3ca9e5d030f4", "complete": true}, "client_authored": false, "user_input_order": 5}} +{"timestamp": "2026-11-19T12:49:45.522Z", "ordinal": 33, "type": "event_msg", "payload": {"type": "task_complete", "root_turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "turn_id": "01a1f3db-1b29-7870-ba61-3e4e400e4027", "last_agent_message": "## Pre-Landing Review\n\nNo blocking findings.\n\nGate edits: none.\n", "started_at": 1795092585, "completed_at": 1795092585, "duration_ms": 262, "time_to_first_token_ms": 104}} diff --git a/test/skill-contract-codex.test.ts b/test/skill-contract-codex.test.ts index 6cf58c0b2..381b3d099 100644 --- a/test/skill-contract-codex.test.ts +++ b/test/skill-contract-codex.test.ts @@ -149,6 +149,50 @@ describe('dispatch: a spawn_agent call that started an agent', () => { expect(status(t, realReview(t))['adversarial-pass']).toBe('missing'); }); + test("Sol's spawn_agent in Codex's collaboration namespace answers with task_name, not agent_id: that started agent is a dispatch", () => { + const sol = lines('exec-sol-spawn-met.jsonl'); + const call = sol.map(l => JSON.parse(l).payload).find(p => p?.type === 'function_call' && p.name === 'spawn_agent'); + expect(call.namespace).toBe('collaboration'); + expect(JSON.parse(call.arguments).task_name).toBe('adversarial'); + const atFirstStop = parseTranscript(sol.slice(0, sol.findIndex(l => l.includes(' e.kind === 'tool_use' && e.name === 'Agent') as { input: Record } | undefined; + expect(String(dispatch?.input.prompt)).toContain('Think like an attacker and a chaos engineer'); + expect(status(atFirstStop, realReview(atFirstStop))).toEqual({ 'adversarial-pass': 'met', 'review-report': 'met' }); + }); + + test('negative control: a collaboration spawn_agent whose output names no task_name is not a dispatch', () => { + const sol = lines('exec-sol-spawn-met.jsonl'); + const callId = sol.map(l => JSON.parse(l).payload).find(p => p?.type === 'function_call' && p.name === 'spawn_agent').call_id; + for (const output of ['{"task_name":""}', 'spawn_agent failed: task_name is required', '{"nickname":"Ada"}']) { + const edited = sol.map(l => { + const rec = JSON.parse(l); + if (rec.payload?.type !== 'function_call_output' || rec.payload.call_id !== callId) return l; + return JSON.stringify({ ...rec, payload: { ...rec.payload, output } }); + }); + const t = parseTranscript(edited.join('\n')); + expect(t.events.some(e => e.kind === 'tool_use' && e.name === 'Agent')).toBe(false); + expect(status(t, realReview(t))['adversarial-pass']).toBe('missing'); + } + }); + + test('negative control: a same-named spawn_agent from another tool namespace is not Codex\'s, whatever its result says', () => { + const sol = lines('exec-sol-spawn-met.jsonl'); + const retag = (namespace: string, output?: string) => parseTranscript(sol.map(l => { + const rec = JSON.parse(l); + if (rec.payload?.type === 'function_call' && rec.payload.name === 'spawn_agent') return JSON.stringify({ ...rec, payload: { ...rec.payload, namespace } }); + if (output !== undefined && rec.payload?.type === 'function_call_output' && rec.payload.call_id === 'call_spawn_1') return JSON.stringify({ ...rec, payload: { ...rec.payload, output } }); + return l; + }).join('\n')); + for (const namespace of ['mcp__agents__', 'my_extension']) { + const t = retag(namespace); + expect(t.events.some(e => e.kind === 'tool_use' && e.name === 'Agent')).toBe(false); + expect(status(t, realReview(t))['adversarial-pass']).toBe('missing'); + } + expect(status(retag('multi_agent_v1'), realReview(retag('multi_agent_v1')))['adversarial-pass']).toBe('missing'); + const v1 = retag('multi_agent_v1', '{"agent_id":"019a-v1","nickname":null}'); + expect(status(v1, realReview(v1))['adversarial-pass']).toBe('met'); + }); + test('call arguments that are not a JSON object throw UnknownShape, so the hook fails open', () => { const meta = lines('exec-read-met.jsonl')[0]; const user = JSON.stringify({ type: 'response_item', payload: { type: 'message', role: 'user', content: [{ type: 'input_text', text: 'review this' }] } });