I am requesting the content for a series of files to be given in JSON format. Below is an abbreviated version of the response.
{
"files": {
"main.py": "{complete file content included}",
...
"README.md": "# Personal Library API\n\nA RESTful API for managing your personal library, built with Flask and SQLite.\n\n## Features\n- CRUD for books and authors\n- Track reading status, progress, and dates\n- Search, filter, and sort books\n- Pagination for all list endpoints\n- Input validation and error handling\n- Automated tests\n\n## Setup\n\n1. **Install dependencies:**\n\n ```sh\n pip install -r requirements.txt\n ```\n\n2. **Set environment variable:**\n\n ```sh\n export DATABASE_URL=\"sqlite:
...
"src/models.py": "{complete file content included}",
...
}
}
I am familiar with “URL mangling” but this seems a little different. Notice that for “README.md” is breaks right after the “sqlite:”, presumably on the double slash “//”, and never closes the quote. It then continues on to complete the next element successfully. If the LLM doesn’t happen to include a URL it works perfectly fine. It only breaks if it does include a URL.
I am generous with token limit so that isn’t the cause and, even if it was, it would truncate at the token limit, not somewhere in the middle, then continue on.
I also include language on escaping URLs:
Return a raw JSON object with the following structure, without markdown formatting or comments. All URLs, including HTTP, HTTPS, and database protocols, must be properly escaped — meaning:
Enclose URLs in double quotes.
Escape backslashes with \\.
Escape forward slashes with \/.
Escape double quotes with \".
Percent-encode reserved characters if necessary.
Ensure the JSON is complete, valid, and well-formed.
Example:
{{
"website": "http:\/\/example.com",
"database": "sqlite:\/\/\/path\/to\/db"
}}
The end result is JSON parsing fails because the element isn’t well-formed.
Anyone seen this behavior? Any strategies for getting the LLM to complete it?