Continue error 'Unexpected non-whitespace character after JSON' with Gemini 2.5 Pro or Ollama
Continue (latest version) on Windows throws 'Unexpected non-whitespace character after JSON' when chatting with Gemini 2.5 Pro, and other users report the same with a local Ollama model. Is there a fix or workaround for this agent-mode error?
Originally asked on GitHub: https://github.com/continuedev/continue/issues/5253
4 answers
Status: explained, not fixed. A Continue contributor said on 2025-05-27 that the error appears to be caused by parallel tool calls from Gemini 2.5 Pro and that they would look into it; the issue was later closed as NOT_PLANNED.
One workaround from a commenter worked for them: add a
contextfield to the model entry in the config file. For an Ollama model (llama3.1:8b) they changed config.json so the model entry included acontextstring such as "You are a helpful AI assistant", and the error stopped. This was not confirmed by a maintainer.Another commenter using a local Ollama setup in Docker (apiBase http://localhost:11434/llama2) said the same error appears when no context is passed to the chat, and that passing a context is the solution. The original reporter's config used the gemini provider with model gemini-2.5-pro-exp-03-25 and chat/edit/apply roles; no config-level workaround for Gemini is shown in the thread.
General advice, not confirmed in the thread: if you hit this with Gemini 2.5 Pro, try a model or a setting that does not emit parallel tool calls, and watch Continue release notes for a fix.
Did this work for you?What @drakgoku tried on GitHub (Didn't work)
Reporter used a Continue config v1 YAML with the gemini provider, model gemini-2.5-pro-exp-03-25, chat/edit/apply roles, and defaultCompletionOptions contextLength 1048576 / maxTokens 65536. The agent failed with the JSON error and the reporter said it could be reproduced with anything.
Source: https://github.com/continuedev/continue/issues/5253 (opens external site)
Did this work for you?What @Karan-p-singh tried on GitHub (Worked)
Commenter added a
contextstring to the Ollama model entry in config.json (title 'Llama3.1 8B', provider ollama, model llama3.1:8b). They reported that this fixed the problem for them.Source: https://github.com/continuedev/continue/issues/5253#issuecomment-2867702524 (opens external site)
Did this work for you?What @dgenezini tried on GitHub (Outcome unclear)
Commenter ran Ollama in Docker with several models and apiBase http://localhost:11434/llama2, and shared their full config. The thread does not show whether this configuration alone changed the error.
Source: https://github.com/continuedev/continue/issues/5253#issuecomment-2820822931 (opens external site)
Did this work for you?
Related questions
- Continue error with Llama via LiteLLM: Cannot set properties of undefined (setting 'parsedArgs')
- Continue 1.1.45-1.1.47: Gemini agent mode fails with 400 INVALID_ARGUMENT 'alwaysApply'
- How to enable Agent mode (tool use) for LM Studio models in Continue?
- How to make Continue's @folder/@codebase send full file contents?
- MCP tool call times out at 60s even with connectionTimeout set in Continue