Summary
Running an agentic coding session with a newer model on an OpenAI-compatible provider (GLM 5.2 via Fireworks AI), Crush hard-exits mid-session whenever the model emits an edit/write tool call, with:
ERROR Agent processing failed: failed to start agent processing stream:
bad request: Invalid tool call in messages:
tool_calls[].function.arguments for function 'edit' must be a JSON object string (or an object), got invalid JSON.
The whole crush run process dies (exit 1). The model's accumulated progress in that turn is lost.
Environment
- Crush v0.76.0 (also nothing relevant in v0.77.0 changelog).
- Provider: custom
fireworks (OpenAI-compatible, https://api.fireworks.ai/inference/v1).
- Model:
accounts/fireworks/models/glm-5p2 (GLM 5.2). Headless crush run -m … -c … --quiet.
Key observation
It crashes only on tool calls with large/complex string arguments — edit and write (which carry code blobs with newlines/quotes/special chars). The same model's read/grep/reasoning tool calls in the same session work fine, and it produces excellent diagnoses. So GLM 5.2 is emitting the arguments field in a shape Crush's strict parser rejects (e.g. not a JSON-stringified object, or with unescaped content), specifically when the payload is big.
Other models on the same Fireworks provider (DeepSeek V4 Pro, Kimi K2.7) emit clean tool args and never hit this — resuming the same session on one of those lets the edit go through, which confirms it's a per-model tool-arg-serialization mismatch, not a session/config problem.
Impact
The model can't apply any file edit → unusable for coding with GLM 5.2, and a single bad tool-call kills the run rather than being recoverable/retried.
Suggested fix
Be lenient when normalizing tool_calls[].function.arguments from OpenAI-compatible providers:
- If
arguments is a string that fails JSON.parse, attempt a repair pass (strip markdown fences, fix common escaping) before rejecting.
- Treat a malformed tool-call as a recoverable turn error (feed the parse error back to the model to retry) instead of a fatal stream error that exits the process.
Happy to provide a fuller repro (the GLM 5.2 raw tool-call payload) if useful.
Summary
Running an agentic coding session with a newer model on an OpenAI-compatible provider (GLM 5.2 via Fireworks AI), Crush hard-exits mid-session whenever the model emits an
edit/writetool call, with:The whole
crush runprocess dies (exit 1). The model's accumulated progress in that turn is lost.Environment
fireworks(OpenAI-compatible,https://api.fireworks.ai/inference/v1).accounts/fireworks/models/glm-5p2(GLM 5.2). Headlesscrush run -m … -c … --quiet.Key observation
It crashes only on tool calls with large/complex string arguments —
editandwrite(which carry code blobs with newlines/quotes/special chars). The same model's read/grep/reasoning tool calls in the same session work fine, and it produces excellent diagnoses. So GLM 5.2 is emitting theargumentsfield in a shape Crush's strict parser rejects (e.g. not a JSON-stringified object, or with unescaped content), specifically when the payload is big.Other models on the same Fireworks provider (DeepSeek V4 Pro, Kimi K2.7) emit clean tool args and never hit this — resuming the same session on one of those lets the edit go through, which confirms it's a per-model tool-arg-serialization mismatch, not a session/config problem.
Impact
The model can't apply any file edit → unusable for coding with GLM 5.2, and a single bad tool-call kills the run rather than being recoverable/retried.
Suggested fix
Be lenient when normalizing
tool_calls[].function.argumentsfrom OpenAI-compatible providers:argumentsis a string that failsJSON.parse, attempt a repair pass (strip markdown fences, fix common escaping) before rejecting.Happy to provide a fuller repro (the GLM 5.2 raw tool-call payload) if useful.