fix(opencode): repair malformed JSON in tool call arguments#23064
fix(opencode): repair malformed JSON in tool call arguments#23064ahamza360 wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found one potentially related PR: Related PR:
The current PR (#23064) appears to be the primary fix for JSON parsing errors in tool call arguments, addressing a specific issue that wasn't directly targeted in previous PRs. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
- Add strategy to handle duplicated/overlapping JSON objects - Add pattern matching for specific malformed JSON cases - Insert missing commas that might cause parsing issues - Improve logging for repair attempts
|
Updated the PR with improved JSON repair logic that handles more complex cases including duplicated/overlapping JSON objects. This addresses the specific issue mentioned in the comments where tool calls like confluence_confluence_search_content were still failing with JSON parsing errors. |
|
This PR has been superseded by #23067 which contains improved JSON repair logic that handles more complex cases including duplicated/overlapping JSON objects. |
Issue for this PR
Closes #23065
Type of change
What does this PR do?
This PR fixes the recurring JSON parsing errors that occur when LLMs generate malformed/truncated JSON for tool call arguments.
Problem:
LLMs occasionally generate malformed/truncated JSON for tool call arguments, resulting in "JSON parsing failed" errors.
Solution:
Enhanced the
experimental_repairToolCallcallback inpackages/opencode/src/session/llm.tswith improved JSON repair logic that:"value→"value"){ "key": "value"→{ "key": "value" })This makes opencode more robust when dealing with imperfect LLM JSON output.
How did you verify your code works?
Checklist