copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

fails to write markdown because of JSON validation

Open rbavery opened this issue 2 months ago β€’ 6 comments

Describe the bug

I asked it to dump it's comments of our chat to a file.

result

 > dump your comments to a file in rustac folder

 βœ— Execution failed: Expected ',' or '}' after property value in JSON at position 65 (line 1 column 66)

 > save markdown of your recommendations to a folder

 βœ— Execution failed: Expected ',' or '}' after property value in JSON at position 73 (line 1 column 74)

Affected version

β†’ copilot --version 0.0.350 Commit: 6bd4106

Steps to reproduce the behavior

No response

Expected behavior

No response

Additional context

No response

rbavery avatar Oct 24 '25 02:10 rbavery

I cannot reproduce this. Can you share logs or more context of that conversation? πŸ™

Thank you!

sergiou87 avatar Oct 24 '25 10:10 sergiou87

I faced this multiple times...though sporadic..will try to capture some logs

But def happens..usually saying "continue" or "Retry" seemes like worked for me

yaananth avatar Nov 02 '25 17:11 yaananth

Same.

βœ“ Find getEntityFromLogEntry function
   $ grep -n "getEntityFromLogEntry" /home/enrique/xx/resources/js/game -r --include="*.ts" | head -5
   β†ͺ 6 lines...

 βœ— Execution failed: Expected ',' or '}' after property value in JSON at position 218 (line 1 column 219)

EnriqueGF avatar Nov 02 '25 17:11 EnriqueGF

@sergiou87 - Personally I encountered this when using non-interactive mode and a very long running task. My assumption is GHCP CLI tried to ask for permission to continue or something like that but error-ed out after a couple of minutes instead with the below. Chat output was a few minutes before the error and then I just get the request stats summary output afterwards (you can see it was a pretty long request ).

copilot --version 0.0.354 Commit: 076bd172b

Perfect! Now I have a complete understanding of the codebase. Let me create a comprehensive, machine-readable implementation plan with atomic phases and executable tasks.
Execution failed: Expected ',' or '}' after property value in JSON at position 81 (line 1 column 82)

Total usage est:       1 Premium request
Total duration (API):  4m 44.5s
Total duration (wall): 4m 50.2s
Total code changes:    0 lines added, 0 lines removed
Usage by model:
    claude-sonnet-4.5    561.4k input, 17.6k output, 0 cache read, 0
  cache write (Est. 1 Premium request)

I was doing a development planning task similar to:

copilot -p "Plan this really big task with lots of context and save the plan in plan.md" --allow-all-tools

When I changed the prompt to allow for incremental outputs it succeeded. Something like:

copilot -p "Plan this really big task with lots of context and for each phase in the plan save it in phase_<number>.md" --allow-all-tools

Hopefully the long running request gives you a reproducible condition to track down the root cause.

autonomousit avatar Nov 04 '25 03:11 autonomousit

Thank you very much!! πŸ’–

I've been trying this for a long time today and haven't been able to reproduce this. Not sure what could be going on here 😒 I made it generate lots of markdown files, longer and shorter, with JSON, JS code, just text… no luck so far 😒

sergiou87 avatar Nov 04 '25 16:11 sergiou87

@sergiou87 - thanks for the effort on this. From your last comment I'm worried I didn't explain clearly. The trigger for me seemed to be holding on one single file creation task for ~4-5 mins, nothing on the actual number of chars, etc but more the fact that a specific file generation task wasn't completing. As soon as I got it to incrementally output smaller files that all completed relatively quickly then it was fine even though the overall request "session" time was the same or longer. Hope that is more specific

autonomousit avatar Nov 05 '25 02:11 autonomousit

Thanks for your clarification! I managed to repro it with this prompt:

Study this codebase and create a very long plan.md file with at least 300 suggestions of big potential tasks with big context, don't be scarce in words. Make sure to include JavaScript and JSON examples where appropriate. Use headings and subheadings where appropriate. Format the file using markdown syntax. The file should be named PLAN.md. Duplicate every paragraph. Again, write a very long file!!!! Write as much as you can per task.

Let's see if I can find why πŸ•΅οΈ

EDIT: The problem I see is the LLM is returning an incorrect JSON that we assume is correct. In my case, it was the JSON where the path of the PLAN.md file is specified, which is supposed to be an object, but the last curly brace is missing 😬

sergiou87 avatar Nov 05 '25 09:11 sergiou87

πŸ‘‹ Just FYI I've submitted a fix that prevents the "Execution failed" error but not the actual problem (getting an invalid JSON from the LLM). What this means is that the app might run into this problem again, but instead of stopping, the agent will get to know about the error you ran into, and try other ways to create the file.

I know it's not optimal, but I'll work with the right team about the JSON issue separately, since it's not a problem of the app itself.

In any case, this is how the app should behave with such errors: get back to the LLM with the error as new context and let it work around it 🀞

sergiou87 avatar Nov 06 '25 10:11 sergiou87

Well, I've got confirmation that this is a problem of the LLM, so I'm afraid the only actual fix for this will come from the model itself πŸ˜“

I can only advice to try with another model, if my fix/workaround is not enough whenever you encounter this error.

Sorry I can't be of more help!!

sergiou87 avatar Nov 06 '25 11:11 sergiou87

Thanks for the detailed debrief @sergiou87, appreciate it

autonomousit avatar Nov 07 '25 01:11 autonomousit