Description
Nanocoder crashes with an Unexpected token 'D', " [DONE]" is not valid JSON error when using certain OpenAI-compatible APIs (like Atlas Cloud). This happens because these providers send data: [DONE] (with two spaces) instead of the standard data: [DONE]. The strict @ai-sdk/openai-compatible parser strips only one space, leaving " [DONE]", which fails strict string comparison and falls through to JSON.parse().
Environment
- OS: Linux
- Node version: (insert your node version here)
- Nanocoder version: 1.28.0
- Provider: OpenAI-compatible API (Atlas Cloud)
- Model:
deepseek-ai/deepseek-r1-0528
Steps to Reproduce
- Configure an OpenAI-compatible provider in
agents.config.json that sends data: [DONE] at the end of SSE streams (e.g., Atlas Cloud).
- Start a chat session using this provider and any model.
- Wait for the model to finish generating the response.
Expected Behavior
The stream should complete successfully and the response should be processed.
Actual Behavior
Nanocoder crashes at the end of the stream with the error Unexpected token 'D', " [DONE]" is not valid JSON and silently attempts to retry the request 4 times before failing.
Logs/Screenshots

Description
Nanocoder crashes with an
Unexpected token 'D', " [DONE]" is not valid JSONerror when using certain OpenAI-compatible APIs (like Atlas Cloud). This happens because these providers senddata: [DONE](with two spaces) instead of the standarddata: [DONE]. The strict@ai-sdk/openai-compatibleparser strips only one space, leaving" [DONE]", which fails strict string comparison and falls through toJSON.parse().Environment
deepseek-ai/deepseek-r1-0528Steps to Reproduce
agents.config.jsonthat sendsdata: [DONE]at the end of SSE streams (e.g., Atlas Cloud).Expected Behavior
The stream should complete successfully and the response should be processed.
Actual Behavior
Nanocoder crashes at the end of the stream with the error
Unexpected token 'D', " [DONE]" is not valid JSONand silently attempts to retry the request 4 times before failing.Logs/Screenshots