OpenProgram Docs

Retry decisions for model calls

Errors take shape in two places, and both become a message with stop_reason="error" and an error_message that may be empty: an exception caught in runtime/agent/loop/driver.py, or an error event from the provider stream.

AgentSessionRuntime.exec
Coderuntime/agent/loop/session.py, retry.pyruntime/agent/runtime/execution.py, shared.py
SeesThe last assistant messageAn exception from _call
BudgetInvocation's transport_limit (default 4); max_retries=3 without a recovery statemax_retries=3, OPENPROGRAM_MAX_RETRIES
Backoff2000·2^(attempt-1) ms1.5·2^attempt s, ±25%; OPENPROGRAM_RETRY_BACKOFF_BASE
With Retry-After–Lower bound, positive jitter only
Before a retryPops the failed assistant message–

AgentSession: is_retryable_error

Checked in orderRetry
stop_reason is not errorNo
Context overflowNo; compaction handles it
error_transport_exhaustedNo
error_retryable set by the providerThat verdict
Empty error_messageYes
Anything elseYes if it matches _RETRY_PATTERN

Empty counts as retryable because a dropped stream breaks before any error body arrives. _RETRY_PATTERN: overloaded, rate limit, too many requests, 429, 500, 502, 503, 504, service unavailable, server error, internal error, connection error, connection refused, other side closed, fetch failed, upstream connect, reset before headers, terminated, retry delay.

Runtime.exec

ExceptionAction
ExecInterrupt, TypeError, NotImplementedError, ImportError, StructuredOutputErrorRaised directly
retryable=False, or a marker in _PERMANENT_ERROR_MARKERSGives up, "failed permanently"
transport_exhausted, deadline passed, attempts spent, Retry-After past the capGives up
Sleeping would cross the deadlineGives up as TIMEOUT
OtherwiseSleeps and retries

Markers: not a valid image, invalid image, image data is not, login expired, login failed, re-auth, unauthorized, invalid api key, invalid_api_key.

The layers together

Transport retries are counted once: AgentSession and the provider stream draw on one RecoveryState. When it runs out the message is flagged error_transport_exhausted and exec does not restart the invocation with a fresh tool context.

What retry cannot solve

FailureGoes to
Gateway auth invalid (openai-codex login expired or failed)Permanent; sign in before a batch run
Context overflowCompaction
TypeError, NotImplementedErrorThe code

Messages

A caught exception becomes type_name: text, or the type alone when the text is empty, with the traceback on stderr. The final error lists each attempt's type_name: text and whether it failed permanently or after N attempts.

Last updated · 2026-11-25