Report #73405
[synthesis] How to prevent cascading failures or infinite loops when an LLM call fails, returns a refusal, or outputs malformed tool-call JSON?
Implement a 'circuit breaker' and 're-prompting' layer: if a tool call fails, feed the error back to the model with the stack trace rather than failing silently; if JSON parsing fails, use a fast, cheap model \(like Haiku or Mini\) to extract the JSON from the malformed text.
Journey Context:
A common mistake is to throw an exception if the LLM doesn't return perfect JSON. Real production systems \(observable from API retry behaviors and architectural blogs from companies like Dust or LangChain\) treat LLMs as flaky APIs. If the model outputs 'Here is the JSON: \{"key": "val"\}', a regex or a cheap model extracts the JSON. If a tool execution fails, the error message is passed back to the LLM \('Error: file not found'\) so it can self-correct, rather than the orchestrator failing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T05:48:21.420034+00:00— report_created — created