fix(tools): add acp-only guidance to sessions_spawn streamTo parameter#63121
fix(tools): add acp-only guidance to sessions_spawn streamTo parameter#63121SuperSupeng wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes a common LLM failure mode where The schema fix and new test are clean. The one P2 concern is in the updated tool description, which lists only Confidence Score: 5/5Safe to merge; the core schema fix is correct and the only remaining finding is a P2 wording issue in the tool description prose. The primary fix (adding a description to the src/agents/tool-description-presets.ts — the new guidance sentence's subagent param allowlist may be too narrow.
|
| '`mode="run"` is one-shot and `mode="session"` is persistent or thread-bound.', | ||
| "Subagents inherit the parent workspace directory automatically.", | ||
| "Use this when the work should happen in a fresh child session instead of the current one.", | ||
| 'For subagent spawns, only pass task, agentId, and runTimeoutSeconds. Do not set streamTo or resumeSessionId — those require runtime="acp".', |
There was a problem hiding this comment.
Overly restrictive subagent param list
The guidance says "only pass task, agentId, and runTimeoutSeconds" for subagent spawns, but several other schema params are valid and useful for subagents — model, thinking, cwd, mode, sandbox, lightContext, attachments, label, etc. Restricting the guidance to three params may cause models to silently omit useful options like cwd or model when spawning subagents.
Consider tightening the guidance to just the "do not set" prohibition instead of an allowlist:
| 'For subagent spawns, only pass task, agentId, and runTimeoutSeconds. Do not set streamTo or resumeSessionId — those require runtime="acp".', | |
| 'For subagent spawns, do not set streamTo or resumeSessionId — those require runtime="acp".', |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/tool-description-presets.ts
Line: 40
Comment:
**Overly restrictive subagent param list**
The guidance says "only pass `task`, `agentId`, and `runTimeoutSeconds`" for subagent spawns, but several other schema params are valid and useful for subagents — `model`, `thinking`, `cwd`, `mode`, `sandbox`, `lightContext`, `attachments`, `label`, etc. Restricting the guidance to three params may cause models to silently omit useful options like `cwd` or `model` when spawning subagents.
Consider tightening the guidance to just the "do not set" prohibition instead of an allowlist:
```suggestion
'For subagent spawns, do not set streamTo or resumeSessionId — those require runtime="acp".',
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 380078f2b2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| '`mode="run"` is one-shot and `mode="session"` is persistent or thread-bound.', | ||
| "Subagents inherit the parent workspace directory automatically.", | ||
| "Use this when the work should happen in a fresh child session instead of the current one.", | ||
| 'For subagent spawns, only pass task, agentId, and runTimeoutSeconds. Do not set streamTo or resumeSessionId — those require runtime="acp".', |
There was a problem hiding this comment.
Remove misleading subagent parameter restriction in description
The new guidance says subagent spawns should "only pass task, agentId, and runTimeoutSeconds," but the implementation still supports additional subagent fields (mode, thread, cleanup, sandbox, model, thinking, attachments, etc. in sessions_spawn). In practice, models that follow this text will stop sending those valid parameters, which can silently disable intended behaviors like persistent/thread-bound sessions or model overrides for subagent runs; this should be narrowed to only prohibit the ACP-only fields (streamTo, resumeSessionId).
Useful? React with 👍 / 👎.
LLMs using sessions_spawn tend to pass streamTo: "parent" even when runtime is "subagent", causing 100% spawn failures because the validation rejects streamTo for non-acp runtimes. This happens because the streamTo schema field has no description indicating it is acp-only, so the model treats it as a generally useful option. This change: - Adds a description to the streamTo schema field stating it requires runtime="acp" and must not be set for runtime="subagent" - Updates the tool description to explicitly list which params are subagent-safe and which require acp - Adds a test verifying the schema description contains acp guidance Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
Address review feedback: the previous wording "only pass task, agentId, and runTimeoutSeconds" was overly restrictive and could cause LLMs to skip valid subagent params like model, cwd, attachments, etc. Changed to a prohibit-list approach: "do not set streamTo or resumeSessionId". Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
33f4780 to
111e5ba
Compare
|
Codex automated review: keeping this open. Keep this PR open. Current main still lacks the proposed Best possible solution: Keep this PR open for maintainer handling. The best product path is to review and land #72331, or an equivalent maintainer-approved fix that adds clear ACP-only schema/tool guidance and tolerates ACP-only fields for native subagent calls; after that lands, explicitly close or supersede this PR while preserving SuperSupeng’s reproduction and schema-guidance contribution. What I checked:
Remaining risk / open question:
Codex Review notes: model gpt-5.5, reasoning high; reviewed against 4878d3e059ce. |
|
Thanks @SuperSupeng for the focused schema-guidance PR and the paired reproduction in #63120. I am closing this as superseded by #72614 because that landed the canonical sessions_spawn fix: subagent runtime now tolerates ACP-only streamTo/resumeSessionId fields, ACP behavior is preserved, and the schema/docs path was updated alongside regression coverage. Clownfish is carrying the attribution from this source PR in the closeout trail with #63120 and #72614. If the schema guidance in #72614 still leaves a distinct provider case uncovered, please reply here and we can reopen or split it back out. |
Summary
descriptiontostreamToschema field insessions_spawntool, explicitly stating it requiresruntime="acp"and must not be set forruntime="subagent"describeSessionsSpawnTool()to list which params are subagent-safe vs acp-onlyCloses #63120
Context
LLMs using
sessions_spawnconsistently passstreamTo: "parent"even whenruntimeis"subagent", because nothing in the schema tells them it's acp-only. This causes 100% spawn failures in multi-agent setups. Other acp-only params likeresumeSessionIdalready have descriptions stating the requirement —streamTowas the only one missing this guidance.Test plan
sessions-spawn-tool.test.tstests pass (13/13)streamToschema description mentions both "acp" and "subagent"🤖 Generated with Claude Code
via Happy