Skip to content

Tool mapping bugs causing task failures and missing functionality #7

@BNasraoui

Description

@BNasraoui

Issue: Tool mapping bugs causing task failures and missing functionality

Environment

  • OpenCode 1.3.17
  • opencode-claude-bridge 1.9.0
  • Claude Sonnet 4.6

Bug 1: Agent subagent_type not required — causes task validation errors

Observed: When the model calls the Agent tool without subagent_type, OpenCode's task tool rejects it:

The task tool was called with invalid arguments: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": ["subagent_type"],
    "message": "Invalid input: expected string, received undefined"
  }
]

Root cause: src/claude-tools.ts:217 has required: ["description", "prompt"] — missing subagent_type. OpenCode's task tool requires it.

Fix: Add "subagent_type" to the required array.

Bug 2: general-purpose maps to build instead of general

Observed: When the model picks general-purpose, the bridge translates it to build. But OpenCode has a dedicated general subagent (per official docs). This sends general-purpose tasks to the wrong agent with different permissions.

Also, general was missing from the outbound map, so OpenCode's general type couldn't translate back to general-purpose for the API.

Root cause: src/index.ts:749 maps "general-purpose": "build". Outbound map at src/index.ts:592 doesn't include general.

Fix: Map "general-purpose": "general" inbound, add general: "general-purpose" outbound.

Bug 3: AskUserQuestion has no mapping to OpenCode's question tool

Observed: The model tries to call AskUserQuestion to ask clarifying questions, but the bridge treats it as a stub tool with no mapping to OpenCode's question tool. All clarification attempts fail.

Root cause: AskUserQuestion is only in STUB_TOOLS, not in INBOUND_TOOL_NAME_MAP or OUTBOUND_TOOL_NAME_MAP.

Fix: Add AskUserQuestion: "question" to inbound map, question: "AskUserQuestion" to outbound map.

Additional finding: SSE chunk boundary fragility

The inbound stream parameter translation (e.g. "file_path""filePath", "activeForm""priority") uses regex on raw SSE text chunks. If a chunk boundary splits a key name, the translation silently fails. This causes intermittent failures on Edit, Read, Write, and TodoWrite tools. This is harder to fix (requires buffering) but worth noting.

PR

PR submitted with fixes for bugs 1-3.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions