Skip to content

fix: show and write JSON file contents sent as a JSON value - #13364

Open
YauhenBichel wants to merge 1 commit into
continuedev:mainfrom
YauhenBichel:13362-create-file-json-contents
Open

YauhenBichel wants to merge 1 commit into
continuedev:mainfrom
YauhenBichel:13362-create-file-json-contents

Conversation

@YauhenBichel

Copy link
Copy Markdown

Description

Fixes #13362 and #13363.

Some models (Qwen in particular) send the contents of a new .json file as a JSON value instead of a string. Because the tool call arguments are parsed deeply:

A new stringifyFileContents() in core/tools/parseArgs.ts turns such a value into indented JSON. createNewFileImpl uses it when contents is an object or array, and the GUI preview uses it too, so the preview shows exactly what will be written. getStringArg is unchanged: compact JSON stays right for other string arguments, and its existing tests still pass.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created (none needed)
  • The relevant tests, if any, have been updated or created

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 a create_new_file call 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 for stringifyFileContents.

npx vitest run tools/parseArgs.vitest.ts tools/implementations/createNewFile.vitest.ts in core (54 passed) and npx vitest run src/pages/gui/ToolCallDiv/ in gui (22 passed).

🤖 Generated with Claude Code

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>
@YauhenBichel
YauhenBichel requested a review from a team as a code owner October 9, 2026 19:55
@YauhenBichel
YauhenBichel requested review from sestinj and removed request for a team October 9, 2026 19:55
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent: creating a JSON file shows [object Object] instead of its contents

1 participant