Retry policy applied to provider calls in the native runtime.
Each call to the LLM is wrapped with bounded exponential backoff plus jitter. By default, the following are retried:
- HTTP
408,425,429,500,502,503,504 - Streaming failures whose underlying
causematches the list above - Stream errors whose textual reason mentions overload, rate-limit, or timeout when no structured cause is available
Streaming calls only retry while no event has been emitted to the
caller. Once a :text or :thinking chunk has been delivered the
policy stops, so the consumer never sees the same content twice. The
underlying error is surfaced and the caller can decide how to recover
(re-enqueue, fail open, etc.).
Configuration
Pass :retry to any session entry point:
Condukt.run("Hello", retry: false)
Condukt.run("Hello", retry: [max_attempts: 5, base_delay_ms: 500])
Condukt.run("Hello", retry: %Condukt.Retry{max_attempts: 2})Set globally via Application.put_env(:condukt, :retry, ...) or
per-agent via start_link(retry: ...).
Custom classifier
Provide a :classify callback to override the default error
classification:
classify = fn
%MyApp.RateLimit{} -> :retry
_ -> :stop
end
Condukt.run("Hello", retry: [classify: classify])
Summary
Functions
Returns true when a provider rejected a request because its input exceeds
the model's context window.
Returns the default retry policy.
Returns a policy that performs a single attempt with no retries.
Normalizes a session-level :retry option into a policy struct.
Runs fun.() and retries transient failures.
Functions
Returns true when a provider rejected a request because its input exceeds
the model's context window.
Native sessions with a compactor compact and retry such a request once. A
provider error matches when it has HTTP status 413, or status 400 (or
none, for stream failures) together with a known context-length message or
error code from Anthropic, OpenAI, Google, Amazon Bedrock, xAI, Groq,
Mistral, or an OpenAI-compatible server. A stream that fails with an error
event, such as OpenAI's response.failed, matches on its message. Only the
provider's error message, code, and type are inspected, never the request
that was sent or input that the provider echoes back.
Returns the default retry policy.
Returns a policy that performs a single attempt with no retries.
Normalizes a session-level :retry option into a policy struct.
Accepts:
nil/true→default/0false→disabled/0- A
%Condukt.Retry{}struct → returned as-is - A keyword list of overrides merged into
default/0
Runs fun.() and retries transient failures.
emitted?.() must return true if the call has already produced a
side-effect visible to the caller (e.g. a stream chunk). The policy
stops retrying as soon as emitted? reports true, so the caller
sees partial output followed by the underlying error rather than a
silent re-attempt.
fun returns {:ok, value} / {:error, reason} (or any non-tuple
value). Non-error results are returned verbatim.
The optional wait callback receives the backoff in milliseconds. It
returns :ok to retry or {:error, reason} to stop. By default it sleeps;
native sessions use an interruptible receive so cancellation wakes it.