Skip to main content
Set a model retry policy to retry failed model requests inside a run, and a parser or schema to turn the final answer into a checked value before it reaches the rest of your application. Gateway defaults, such as a provider or a strict response format, go on the gateway agent client.

Retry failed model requests

The retry count is the number of extra attempts after the first request, and defaults to 0. Each step records how many attempts it took in its model attempts field (modelAttempts, model_attempts or ModelAttempts). Only model requests are retried: tool errors follow the tool’s own error policy, so put retries for side-effecting tools inside the tool and make them idempotent. The wait between attempts and which errors are retried differ by language: With a linear wait and a 500 ms backoff, three retries wait 0.5 s, 1 s, then 1.5 s.

Validate the final output

When the model answers without calling a tool, a parser turns the final text into your value and a schema checks it. If either fails, the run fails with an Invalid agent output: ... error, so bad output stops at the agent boundary. Keep validators deterministic and free of side effects.
For stricter model behaviour, also ask the gateway for structured output. Set a JSON Schema response format (and optionally the response-healing plugin) on the gateway agent client:
Python, PHP and Ruby take the same response_format/responseFormat and plugins options. Go, C# and Java have no response format option; set the field through the client’s escape hatch for other request fields (next section).

Keep routing defaults in a preset

Set preset on the agent (Preset in Go and C#) when routing, prompt, or parameter defaults should stay in the dashboard:
Rust has no preset option.

Set gateway defaults on the client

The gateway agent client (createGatewayAgentClient(), create_gateway_agent_client(), CreateGatewayAgentClient) carries request defaults for every model turn, so you don’t rebuild them on each run. The agent still owns model, input, instructions and its function tools; the model default applies only when the agent sets none. Java and Rust take fewer options: The Responses parameters page explains each field. To read usage, cost and status from the result, see Observability.
Last modified on November 5, 2026