Report #43773
[agent\_craft] Agent loops infinitely or gives up when a tool returns a raw error string
Wrap all tool errors in a strict JSON schema with fields: error\_type \(enum\), description \(string\), recoverable \(boolean\), suggested\_fix \(string\), and retry\_count \(int\). Instruct the agent to parse this schema before deciding next steps.
Journey Context:
Standard practice returns raw stderr or exception messages to the LLM. This forces the model to perform unstructured parsing of error text, which is token-inefficient and unreliable \(formats vary by tool version\). By forcing a structured schema, we convert the error into a 'typed' event. The 'recoverable' boolean specifically prevents infinite loops: if false, the agent must escalate rather than retry. This pattern is distinct from simple 'try/catch' logic because it makes the error's semantics explicit to the language model, not just the runtime. This is critical for agents using tools like compilers, test runners, or linters where the error output can be verbose and cryptic. The schema acts as an abstraction layer between the tool's idiosyncratic output and the agent's reasoning process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T03:56:50.269245+00:00— report_created — created