continue icon indicating copy to clipboard operation
continue copied to clipboard

create_new_file fails on pure JSON contents

Open mcowger opened this issue 1 year ago • 6 comments

Before submitting your bug report

Relevant environment info

- OS: MacOS
- Continue version: 	1.3.24
- IDE version: 1.107
- Model: M2

Description

When the model calls create_new_file, and the contents argument is, itself, valid JSON, the contents argument is an object, not a string, because this snippet in core/context/retrieval/pipelines/BaseRetrievalPipeline.ts:

      const parsed = JSON.parse(responseContent);
      toolCalls = parsed.tools || [];

Will have deeply parsed the response. This causes getStringArg() to throw an error. Instead, if the type of args[argName] is 'object', it should be coerced back to a string with JSON.stringify()

I'll submit a PR shortly for this

To reproduce

  1. Enable tool calls
  2. Ask a model in agent mode: "Create a new file called sample.json"

Log output


mcowger avatar Dec 02 '25 19:12 mcowger

Related issues:

  • #8510 - Continue keeps sending json object as string as opposed to json.stringify() as parameter to mcp tools
  • #8764 - Can't create files (general file creation failures)
  • #5067 - builtin_create_new_file tool doesn't create missing folders and exceptions are not propagated to LLM
  • #8388 - cant create files and hangs a lot and errors
  • #8003 - Create File Fails and Loops when MaxTokens is reached
  • #6718 - Fails to create files in VSCodium on Windows due to "Registry key not found" error

continue avatar Dec 02 '25 19:12 continue

@mcowger thanks for the report, not sure the retrieveWithTools method is used for normal file creation, but I could see the tool call parsing logic causing it to try to write json instead of a string. The solution might be just to JSON.stringify in the create file implementation if the arg contents is valid JSON

EDIT I posted this the moment you opened the PR, ignore

RomneyDa avatar Dec 02 '25 20:12 RomneyDa

Yup that was my implementation in the PR

mcowger avatar Dec 02 '25 20:12 mcowger

:tada: This issue has been resolved in version 1.35.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Dec 04 '25 19:12 sestinj

:tada: This issue has been resolved in version 1.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Dec 04 '25 22:12 sestinj

:tada: This issue has been resolved in version 1.38.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Jan 13 '26 19:01 sestinj