When a refund tool times out, your OpenAI agent might think the transaction failed and retry, accidentally double-dipping into your customer's account. A new field note from developer ravi07 reveals that the OpenAI Agents SDK (version 0.26.0) provides minimal context on tool failures, turning critical ambiguity into a potential financial liability. The default behavior converts errors into a generic string, leaving the model to guess whether side effects occurred.
The Black Box of Failure
In a controlled testbench using a fake refund tool over MCP, the SDKβs default default_tool_error_function returns a single, unhelpful sentence: "An error occurred while running the tool." This message deliberately hides exception details to prevent context leakage, but it also strips away the only clues that might indicate whether the request reached the server or if the refund was actually committed. The model receives no information about idempotency or server state, forcing it to make a decision based on almost zero data.
Retries Without Keys Are Dangerous
The consequences of this ambiguity are severe. When the test agent was configured to retry on failureβa natural response to a generic error messageβwithout using idempotency keys, every order resulted in two refunds. In one independent run, five orders generated ten refunds, yet the agent reported "done" each time, unaware of the duplication. This demonstrates that "an error occurred" is often interpreted by models as "try again," regardless of whether the initial action succeeded.
Safety Lives in the Operation, Not the Message
The solution isn't to flood the model with complex error logs, but to enforce safety at the infrastructure level. Using a stable idempotency key derived from the operation (like refund-) ensures that retries are harmless, as the backend rejects duplicate requests. While status checks before retrying seem logical, they are fragile; tests showed they fail if the agent's process restarts or if the first request is still in flight. The safety net must be the operation itself, not the model's judgment or the error message's verbosity.
Key Takeaways
- The OpenAI Agents SDK default error handler provides no state information on failure.
- Retrying without idempotency keys leads to duplicate side effects, such as double refunds.
- Idempotency keys must be derived from the operation, not the attempt, to be effective.
- Status checks are unreliable in distributed systems compared to enforced idempotency.
The Bottom Line
Stop trusting your agent's intuition on failed transactions. If your SDK doesn't tell it what happened, your backend must make the retry safe by design.