You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subagent tool: sessionID not clearly marked as optional in serialized JSON schema #55503
The subagent tool's sessionID parameter is correctly defined as optional in the TypeScript source (Schema.optionalKey(SessionSchema.ID)), but some models do not reliably infer optionality from the serialized JSON schema. They see sessionID in properties and treat it as required, filling it with garbage values like "sesh" or "sesh_omit_should_not_be_here".
This results in Subagent session not found errors that confuse the model, which then retries with more garbage values in a loop.
Evidence
Source: packages/core/src/tool/plugin/subagent.ts line 40 — Schema.optionalKey(SessionSchema.ID)
Serialization: packages/ai/src/tool.ts — Schema.toJsonSchemaDocument() produces a JSON schema where sessionID is in properties but not in required
The serialized schema is technically correct, but some models do not check the required array and instead pattern-match "fill in all properties"
Expected Behavior
Models should omit sessionID when starting a new subagent. The tool description already says "Calls without a sessionID start a new conversation," but models ignore this.
Actual Behavior
Models fill sessionID with fabricated values, causing Subagent session not found errors. Explicit user prompts to omit the field do not reliably fix the behavior.
Suggested Fix
Add explicit "optional": true to the serialized JSON schema for sessionID, background, model, and agent in the subagent tool definition. Alternatively, add a stronger hint in the tool description (e.g., "IMPORTANT: Do NOT include sessionID unless continuing a previous subagent").
Environment
OpenCode version: latest (desktop)
Model: third-party model with weaker JSON schema adherence
Thanks for the detailed report, @throny! Your request is to make it clearer to models that sessionID (and the other optional subagent parameters) should be left out when starting a new subagent. Some models, like aqua/gpt-6-luna, fill it in with made-up values and then loop on Subagent session not found.
The current schema already marks sessionID as optional: it is left out of required, and its description says calls without it start a new conversation. So this is a model-compatibility improvement rather than a bug. Also, "optional": true isn't a JSON Schema keyword, so a stronger warning in the description is the more likely way to help. Maintainers will consider it.
In the meantime, the plugin session context hook can change each tool's description and input schema before the request is sent. A small plugin could add a firmer "do not pass sessionID unless continuing a previous subagent" line to the subagent tool for that model.
Related: #53615 (another change to the subagent tool's wording for the model).
Activity
opencode-agent commentedon Oct 14, 2026
Thanks for the detailed report, @throny! Your request is to make it clearer to models that
sessionID(and the other optional subagent parameters) should be left out when starting a new subagent. Some models, likeaqua/gpt-6-luna, fill it in with made-up values and then loop onSubagent session not found.The current schema already marks
sessionIDas optional: it is left out ofrequired, and its description says calls without it start a new conversation. So this is a model-compatibility improvement rather than a bug. Also,"optional": trueisn't a JSON Schema keyword, so a stronger warning in the description is the more likely way to help. Maintainers will consider it.In the meantime, the plugin session context hook can change each tool's
descriptionandinputschema before the request is sent. A small plugin could add a firmer "do not pass sessionID unless continuing a previous subagent" line to the subagent tool for that model.Related: #53615 (another change to the subagent tool's wording for the model).