Skip to content

Malformed input for a known tool is reported like an unknown tool call #25789

@johanhallberg

Description

@johanhallberg

Description

Problem

When a model selects a valid tool but emits malformed or truncated input for that tool, the failure can be routed through the invalid tool in a way that looks similar to an unknown tool call.

This makes it harder to distinguish between two different cases:

  1. the model called a tool that does not exist
  2. the model called a valid tool, but the tool input was malformed or could not be parsed

Expected behavior

These cases should be distinguishable in the invalid-tool result, so users and maintainers can tell whether the problem was an unavailable tool or malformed input for an available tool.

Why this matters

The two cases require different follow-up behavior:

  • unknown tool: the model/tool registry mismatch should be surfaced clearly
  • known tool with malformed input: the model should retry with valid input or split a large/truncated operation into smaller chunks

Related PR

I have a small fix ready that classifies these cases separately.

Plugins

none

OpenCode version

dev branch / source build from anomalyco/opencode dev at 5720883, with fix branch based on that commit

Steps to reproduce

  1. Have a model call an existing OpenCode tool, but with malformed or truncated JSON input.
  2. Observe that the failure is routed through the invalid tool.
  3. Compare this with a model calling a tool that does not exist.
  4. Both cases are hard to distinguish from the invalid-tool result, even though they mean different things.

Screenshot and/or share link

PR: #25788

Operating System

macOS 26.4 locally; also reproduced/validated on Debian 12 test host

Terminal

iTerm2 locally; OpenCode web UI/browser for manual validation

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions