Repository navigation
fix: show and write JSON file contents sent as a JSON value - #13364
Open
YauhenBichel wants to merge 1 commit into
Open
YauhenBichel wants to merge 1 commit into
YauhenBichel wants to merge 1 commit into
Conversation
Some models send the contents of a new .json file as a JSON value instead of a string. The tool call preview showed [object Object] (continuedev#13362), and the file was written on one line (continuedev#13363). A shared stringifyFileContents() turns such a value into indented JSON for both the preview and the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #13362 and #13363.
Some models (Qwen in particular) send the
contentsof a new.jsonfile as a JSON value instead of a string. Because the tool call arguments are parsed deeply:[object Object](Agent: creating a JSON file shows [object Object] instead of its contents #13362);create_new_filewrote the file on one line, throughgetStringArg's compactJSON.stringify(create_new_file writes a JSON file on one line when the model sends its contents as a JSON value #13363).A new
stringifyFileContents()incore/tools/parseArgs.tsturns such a value into indented JSON.createNewFileImpluses it whencontentsis an object or array, and the GUI preview uses it too, so the preview shows exactly what will be written.getStringArgis unchanged: compact JSON stays right for other string arguments, and its existing tests still pass.AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
Not included; the GUI test below renders the preview and checks its text.
Tests
gui/src/pages/gui/ToolCallDiv/CreateFile.test.tsx(new): the preview of acreate_new_filecall with object contents shows indented JSON, not[object Object]; string contents are unchanged. Fails before the fix.core/tools/implementations/createNewFile.vitest.ts(new): object contents are written as indented JSON; string contents unchanged. Fails before the fix.core/tools/parseArgs.vitest.ts: tests forstringifyFileContents.npx vitest run tools/parseArgs.vitest.ts tools/implementations/createNewFile.vitest.tsin core (54 passed) andnpx vitest run src/pages/gui/ToolCallDiv/in gui (22 passed).🤖 Generated with Claude Code