refactor(llm): keep a single transport-level retry policy - #130
Merged
Merged
Conversation
LLM retry had two implementations: providers.open moved retry into contract call options for runtime replay of the whole driver call, while the OpenAI clients retried in the shared transport. Only the transport layer remains. retry travels in the driver context from provider options, a per-call retry replaces it, and every driver (OpenAI, OpenAI-compatible, TypeSafe, Claude, Bedrock, Google) applies it before any response body is read, so streams are never replayed. Health probes always send a single request.
llm.lua hoists a per-call timeout to contract_args.timeout; the Bedrock embed handler read it from contract_args.options, so the timeout never reached the client.
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.
Cause
LLM retry had two implementations for one concern:
providers.openmovedretry({max_attempts, initial_delay}) out of the driver context into contract call options, so the runtime re-ran the whole driver call on a retryable error, including a streaming call that had already delivered chunks.{attempts, backoff_ms}), used only by the OpenAI and OpenAI-compatible clients. Claude, Bedrock and Google never received a retry policy, so a configured retry was silently ignored for them.Change
providers.openkeepsretryin the driver context;llm.luano longer copies providerretryinto contract arguments (it reaches the driver through its context); a per-callretryis still hoisted and replaces the provider policy.transport.request_retryresolves the policy per request (request value replaces context,falsesends once).retryoption.Tests
Converted: provider tests assert
retrystays in the driver context andwith_optionsis never used; the retry integration app asserts the driver receivesretrythrough its context and runs exactly once per call. Added: client retry tests (503 then 200, no retry, per-request override) for Claude, Bedrock and Google; handler forwarding tests; single-probe status tests for all six drivers; Bedrock embed timeout test. Each failed before its implementation.make run-tests,make run-lint,make check-manifests: pass