[PR #9667] fix(opencode): preserve tool input from running state for MCP tool results #13179

Closed
opened 2026-02-16 18:18:03 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9667

State: closed
Merged: Yes


What does this PR do?

Fixes MCP tool results failing schema validation when the tool doesn't return input in the response.

When processing tool-result and tool-error events, value.input can be undefined for some MCP tools (e.g., chrome-devtools take_screenshot). This causes Zod schema validation to fail because ToolStateCompleted.input requires a record.

The fix preserves the input from the running tool state (match.state.input) when value.input is undefined.

Fixes #9666

How did you verify your code works?

  1. Configured chrome-devtools MCP with take_screenshot tool
  2. Before fix: calling screenshot without filePath fails with schema validation error
  3. After fix: screenshot completes successfully, input preserved from tool-call phase
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9667 **State:** closed **Merged:** Yes --- ### What does this PR do? Fixes MCP tool results failing schema validation when the tool doesn't return `input` in the response. When processing `tool-result` and `tool-error` events, `value.input` can be undefined for some MCP tools (e.g., chrome-devtools `take_screenshot`). This causes Zod schema validation to fail because `ToolStateCompleted.input` requires a record. The fix preserves the input from the running tool state (`match.state.input`) when `value.input` is undefined. Fixes #9666 ### How did you verify your code works? 1. Configured chrome-devtools MCP with `take_screenshot` tool 2. Before fix: calling screenshot without `filePath` fails with schema validation error 3. After fix: screenshot completes successfully, input preserved from tool-call phase
yindo added the pull-request label 2026-02-16 18:18:03 -05:00
yindo closed this issue 2026-02-16 18:18:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13179