feat(session): retry transient provider failures - #70
Merged
Conversation
Wrap each LLM call in the native runtime with a bounded retry policy
(default: 3 attempts, exponential backoff + jitter). The policy
classifies HTTP 408, 425, 429, 500, 502, 503, 504, and stream errors
that wrap one of those statuses, as retryable.
Streaming calls only retry while no event has been emitted to the
caller. Once a :text or :thinking chunk has reached the subscriber, the
underlying error is surfaced so the caller can decide how to recover
without silently duplicating partial output.
Configurable via the :retry option on Condukt.run/3, Condukt.stream/3,
and start_link/1 (boolean, keyword list, or %Condukt.Retry{} struct).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Folds :runtime_opts back into :runtime as a {module, opts} tuple so the
Session struct stays under credo's 32-field warning threshold after the
:retry field was added in the previous commit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
pepicrft
requested review from
a team,
esnunes and
fortmarek
and removed request for
a team
June 12, 2026 12:43
fortmarek
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
:retryoption onCondukt.run/3,Condukt.stream/3, andstart_link/1(boolean, keyword list, or%Condukt.Retry{}struct). Also accepts a custom:classifycallback.Why
In production we just hit a
503 service overloadedfrom an upstream LLM in the middle of a streaming Slack reply. The session bubbled the error straight to the user as a generic fallback message even though the call was a textbook transient failure. Retrying once at the provider boundary would have masked it entirely; in the steady state every Condukt consumer wants the same behavior.Test plan
mix test— 405 passed, 37 excludedmix credo lib/condukt/retry.ex lib/condukt/session.ex lib/condukt.ex— only the pre-existing 32-field struct warningmix format --check-formattedclean for changed files🤖 Generated with Claude Code