[PR #8362] fix(opencode): repair malformed JSON in MCP tool calls #12723

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

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

State: closed
Merged: No


Summary

  • Adds JSON repair utility to handle malformed JSON from LLMs (like GLM-4.7)
  • Integrates repair into experimental_repairToolCall before falling back to invalid tool handler
  • Uses tool schema to help repair enum values

Test plan

  • Added 29 unit tests for JSON repair functionality
  • All 690 existing tests pass
  • Tested repair of unquoted values, single quotes, trailing commas

Fixes #8102

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8362 **State:** closed **Merged:** No --- ## Summary - Adds JSON repair utility to handle malformed JSON from LLMs (like GLM-4.7) - Integrates repair into `experimental_repairToolCall` before falling back to invalid tool handler - Uses tool schema to help repair enum values ## Test plan - [x] Added 29 unit tests for JSON repair functionality - [x] All 690 existing tests pass - [x] Tested repair of unquoted values, single quotes, trailing commas Fixes #8102
yindo added the pull-request label 2026-02-16 18:17:37 -05:00
yindo closed this issue 2026-02-16 18:17:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12723