Claude, Gemini and GPT Function Calling: Comparing How Each Handles Tool Errors

Close-up of a green circuit board with components and traces

Claude, GPT, and Gemini all let a model call a function and get a result back, but their official documentation disagrees sharply on what happens when that function call fails. Claude’s docs define an explicit error convention and describe how the model is expected to react to it. OpenAI’s docs show the message format for returning a result but say nothing about marking one as a failure. Gemini’s current documentation shows only successful results and does not mention a failure convention at all. That gap matters more than it sounds, because it decides whether a model can tell the difference between “the tool returned no data” and “the tool is broken,” and whether it tries again or just makes something up.

This isn’t an academic distinction. Teams that build an agent against one provider and later add a second model as a fallback, or migrate between providers for cost reasons, routinely carry over an error-handling pattern that only worked because of a convention the original provider happened to document — and the new provider never mentioned.

Close-up of a green circuit board with components and traces
Photo by Peter Shanks from Hobart, Australia, CC BY 2.0, via Wikimedia Commons.

What each provider’s own documentation actually says

This comparison is built only from each provider’s current official docs, not from community workarounds or third-party wrappers, because the gaps between them are the point.

Claude (Anthropic)GPT (OpenAI)Gemini (Google)
Result message formattool_result block in a user message, matched by tool_use_idtool role message (Chat Completions) or function_call_output (Responses API), matched by tool_call_id / call_idfunction_result step matched by call_id (per current Interactions API docs)
Documented error fieldYes — optional is_error: true on the result blockNot documentedNot documented
Documented retry behaviorYes — docs say the model “might then call the tool again” and advise capping retriesNot documented on the function-calling guideNot documented
Schema enforcement optionstrict mode to constrain tool inputsstrict: true plus additionalProperties: falseA documented “validated” mode described as ensuring schema adherence, not detailed further
Multiple calls in one turnSupported; one result block required per tool-use block, in orderSupported; app loops over all returned tool callsSupported; docs note the model “supports calling multiple functions in a single turn”
Error handling among multiple callsNot separately documented beyond “one result per call, even if the tool failed”Not documentedNot documented

Claude: the only one of the three with a documented error convention

Anthropic’s tool-use documentation is explicit about failure. A tool_result block can carry "is_error": true, and the docs give concrete examples — a connection failure returned as "ConnectionError: the weather service API is not available (HTTP 500)", or a validation failure as "Error: Missing required 'location' parameter." The documentation also describes what the model is expected to do next: for an invalid call, “Claude can then call the tool again with the missing information filled in,” and for a failed execution, “Claude can then call the tool again or tell the user what happened.” It also warns developers directly that the model “might then call the tool again with a new tool_use block, so limit how many retries your loop allows” — which is a tacit admission that an unbounded retry loop is a real failure mode worth guarding against, not a hypothetical one. For every tool-use block Claude emits, the integration must send back exactly one tool_result block, in the same order, even when the tool failed — skipping a failed call entirely is not a documented option.

OpenAI: a result format, but no failure convention

OpenAI’s function-calling guide shows how to send a result back — a tool role message with a tool_call_id in Chat Completions, or a function_call_output item with a call_id in the newer Responses API — and says the output “can either be structured JSON or plain text.” What it does not do, anywhere on that page, is define a convention for marking a result as an error. There is no documented error field and no documented guidance on how many times a model should retry a failed call before giving up. The page does document a strict flag (paired with additionalProperties: false) that constrains the shape of the arguments the model is allowed to generate, which reduces one category of failure — malformed arguments — at the input side, but that is a different problem from telling the model a call it already made came back broken. In practice, teams building on OpenAI’s APIs end up inventing their own error-signaling convention (an {"error": "..."} JSON string returned as a normal, successful-looking tool output) because the platform does not supply one.

Gemini: no documented failure path at all

Google’s current function-calling documentation is the sparsest of the three on this specific question. Every example on the page returns a successful result; none shows what a failed or errored function execution looks like, and the docs state plainly that “the model doesn’t execute the function itself” — the calling application owns that responsibility entirely, including, implicitly, whatever happens when it fails. The page documents a “validated” mode described only as ensuring “function schema adherence,” with no detail on what the model sees when adherence fails. It confirms that “the model supports calling multiple functions in a single turn,” but gives no guidance on what to do when one of several parallel calls fails while the others succeed. For teams building on Gemini, that means the error-signaling convention is entirely undocumented and left to the integrator to invent and test, with no provider guidance to check it against.

What this means for how you build the integration

  • On Claude, use the documented is_error field and write the error content the way Anthropic’s own examples do — specific and instructive (“Rate limit exceeded. Retry after 60 seconds”) rather than a bare stack trace — and cap retries in your own orchestration loop, since the model is explicitly documented to keep trying otherwise.
  • On OpenAI, do not assume the model will recognize a plain-text error message as different from a real result — since there is no documented convention, pick a consistent shape for errors (for example, always returning a JSON object with an explicit “error” key) and say so in your system prompt, because the model has no built-in signal to tell the two apart.
  • On Gemini, treat error handling as entirely your application’s responsibility with zero platform guidance to lean on — test explicitly for what the model does when it receives an error-shaped payload in a function_result, since the documented examples never show that case.
  • Across all three, build your own retry cap and circuit breaker in the orchestration layer rather than relying on provider-documented limits — only Claude mentions retry behavior at all, and even there the guidance is “limit it yourself,” not a hard platform-enforced ceiling.

If you are building anything that chains several of these tool calls together — an agent that calls one tool, feeds the result into a decision, and calls another — the failure points multiply, and this breakdown of common failure points when chaining AI agents for approvals covers where those chains actually break in practice. Before shipping any agent that relies on tool calls in production, this pre-ship checklist built from Anthropic’s and OpenAI’s own eval guidance is a useful companion to the comparison above, and if the tools in question are exposed through MCP rather than defined inline, what an MCP server’s permission scope actually grants is worth checking before any of this error-handling logic matters at all.

A minimal error convention for providers that don’t define one

Since neither OpenAI’s nor Gemini’s current function-calling documentation defines an error field, the fix is to invent one consistently and tell the model about it in your system prompt, rather than returning an ad hoc string every time a different tool fails. A shape that works across both looks like this — always a JSON object, always with the same two keys, whether the call succeeded or not:

{
  "ok": false,
  "error": "Rate limit exceeded on orders API, retry after 60s"
}

Returning this exact shape for every tool result (including successes, as {"ok": true, "result": {...}}) gives the model one consistent signal to check instead of asking it to infer failure from the prose of an error message, and it gives your own orchestration code a single, reliable field to branch on before the model ever sees the result — which matters because, as shown above, none of the three providers document a hard ceiling on retries. Your own loop is the only thing enforcing one on OpenAI or Gemini.

None of the three providers is “wrong” here — Claude’s docs are simply the most opinionated about failure, while OpenAI and Gemini leave more of the convention to the integrator. The practical takeaway is to never assume parity: a tool-error strategy that works cleanly against Claude’s documented is_error field will silently do nothing useful if you swap in a model whose provider never defined that field in the first place.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top