fix(tools): map cursor-agent subagentType to canonical subagent_type - #122
Merged
Merged
Conversation
- add ["subagenttype", "subagent_type"] to ARG_KEY_ALIASES - unwrap cursor-agent single-key subagent wrappers to a string - map unspecified/generalPurpose to OpenCode general - forward every other value untouched so OpenCode reports its own "Agent not found: X. Available agents: ..." instead of a schema error
Owner
|
Thanks Griffin, I merged your patch unchanged and followed it with a small compatibility fix on main. Your change now handles cursor-agent’s The follow-up preserves configured opencode agents named I verified the combined tree with 585 unit tests, 43 integration tests with one intentional skip, the build, and an npm package dry-run. Thanks for tracking down the task-loop failure and supplying the fixture and tests. cheers, RAMA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Under a Cursor-hosted model, every OpenCode
taskcall can fail schema validation:The model emits the Cursor
Taskenvelope instead of the OpenCode one. Two things differ, andARG_KEY_ALIASEScovered neither:TasktasksubagentTypesubagent_type"explore", or a single-key wrapper such as{ "unspecified": {} }/{ "custom": "reviewer" }Because the key never normalized,
sanitizeArgumentsForSchemadropped it as an unexpected property and validation reportedsubagent_typemissing. Retrying re-emits the same envelope, so the call never converges.This adds:
["subagenttype", "subagent_type"]toARG_KEY_ALIASES. Key normalization (lowercase + strip non-alphanumerics) means the one entry coverssubagentType,subagent_type, andsubagenttype.taskbranch innormalizeToolSpecificArgsthat resolves the value to a string:{ custom: "reviewer" }carries the name in the value, while oneof markers such as{ unspecified: {} }carry it in the key.unspecifiedandgeneralPurposemap togeneral.Cursor-only agent types (
computer_use,browser_use,shell,vm_setup_helper,video_review) are deliberately not mapped. They are forwarded untouched so OpenCode answers with its ownAgent not found: "shell". Available agents: ..., which names the valid set and lets the model self-correct. Silently rewriting them togeneralwould dispatch the wrong agent with no signal.Cursor-only extras (
agentId,attachments,mode,environment,respondingToMessageIds) already fall out viasanitizeArgumentsForSchema; a test pins that.How it was found
Reading the cursor-agent client bundle (
2026.08.04-aaa8809), whosemapSubagentTypeenumerates the vocabulary:That
defaultbranch is where the object-shaped values come from, which is why resolving the value has to handle both the wrapper and the bare string.Prior art: #60 (closed as a duplicate of #51) is the same report. It was addressed prompt-side via
TASK_BRIDGE_JSON_CONTEXTplus a higher loop-guard threshold. That guidance only binds when the model chooses the bridge-JSON envelope; when it emits a native CursorTasktool call instead, nothing normalized the arguments. This closes that path. Reproduced on 2.5.4 /main@ 013ff8e.Test
tests/unit/provider-tool-schema-compat.test.tscovering: key alias, oneof unwrap,unspecifiedtogeneral,{custom:...}unwrap, cursor-only pass-through, an already-canonical value left untouched, and extras being dropped.bun test tests/unit/provider-tool-schema-compat.test.ts: 46 pass / 0 fail (39 before).bun run test:ci:unit: 572 pass / 5 fail. The failures are intests/unit/proxy/plugin-resume.test.ts, reproduce on cleanmain(baseline 564 pass / 6 fail), and are flaky across repeat runs (3 / 6 / 5 failing). Unrelated to this change.