Skip to content

fix(opencode): accept agent and agent_type as task tool parameter aliases#20805

Open
jbmml wants to merge 1 commit intoanomalyco:devfrom
jbmml:fix/task-tool-agent-alias
Open

fix(opencode): accept agent and agent_type as task tool parameter aliases#20805
jbmml wants to merge 1 commit intoanomalyco:devfrom
jbmml:fix/task-tool-agent-alias

Conversation

@jbmml
Copy link
Copy Markdown

@jbmml jbmml commented Apr 3, 2026

Issue for this PR

Fixes #20804

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Non-Claude models (MiniMax, Gemini, Qwen) send agent or agent_type instead of subagent_type when calling the task tool. Zod rejects these because subagent_type is the only accepted parameter name and it's required. Models retry in a loop (20+ times in my testing) without ever guessing the right name.

The fix makes subagent_type optional and adds agent and agent_type as optional aliases. A new exported resolveAgentType() function normalizes these to a single value at the top of execute() with clear precedence: subagent_type > agent > agent_type. If none are provided, it throws the same error as before.

This is the minimal change — one source file and one test mock updated. The resolver is a pure function with no side effects.

How did you verify your code works?

  • 170/170 existing tool tests pass (bun test test/tool/)
  • 6 new unit tests for resolveAgentType covering all alias paths and the error case
  • Runtime tested with MiniMax M2.5 Free: agent resolved correctly on first call (was failing 20+ times before)
  • Runtime tested with Gemini 2.5 Flash: same fix confirmed
  • Full turbo typecheck passes across all 13 packages

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ases

Non-Claude models consistently send "agent" or "agent_type" instead of
"subagent_type" when calling the task tool, causing repeated Zod validation
failures. Accept all three parameter names with a clear precedence order:
subagent_type > agent > agent_type.

Fixes anomalyco#20804

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jbmml pushed a commit to jbmml/opencode that referenced this pull request Apr 8, 2026
Applies both open PRs (anomalyco#20805, anomalyco#20809) to current dev for local use:
- task tool: accept agent/agent_type as aliases for subagent_type
- experimental.ts: replace broken zodToJsonSchema with z.toJSONSchema

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-Claude models fail to call task tool due to required subagent_type parameter

1 participant