[fix] Add exponential backoff to retry in prompts#4240
Merged
junaway merged 2 commits intofeat/extend-prompt-templatesfrom Apr 30, 2026
Merged
[fix] Add exponential backoff to retry in prompts#4240junaway merged 2 commits intofeat/extend-prompt-templatesfrom
junaway merged 2 commits intofeat/extend-prompt-templatesfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Railway Preview Environment
Updated at 2026-04-30T15:36:49.533Z |
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.
PR description
feat(sdk): exponential backoff for LLM prompt retries
What
Replaces the fixed-delay retry in the prompt execution engine with exponential backoff, and tightens the
RetryConfigmodel with proper bounds and optional semantics. Updates all UI copy and published docs to match.Changes
SDK —
types.pyRetryConfig.max_retries:int = 0→Optional[int] = None, range[0, 5]RetryConfig.delay_ms→base_delay:Optional[int] = None, range[100, 1000]msSDK —
handlers.py_coerce_retry_configtakesretry_policyand fills safe defaults when policy is active and fields areNone(max_retries=1,base_delay=1000)(base_delay / 1000) * 2^attempt— first sleep equalsbase_delay, doubles each retry_should_retryand_run_prompt_llm_config_with_retrypass policy through to coercionFrontend —
agenta-entity-uiRetryConfigTab:delayMs→baseDelay, field key"delay_ms"→"base_delay", description updated, hardcodedmax=10000slider override removedPlaygroundConfigSection: all references updatedDocs
07-fallback-models-and-retry.mdx: JSON example + prose updated01-configuration-management.mdx: reference table + JSON example updated03-custom-workflow.mdx: code example + parameter description updatedTests
Summary of changes and implications
Model (
sdk/agenta/sdk/utils/types.py)RetryConfig.max_retries:int = 0→Optional[int] = None, capped at 5RetryConfig.delay_msrenamed tobase_delay:Optional[int] = None, constrained to 100–1000 msNoneis the canonical "not configured" state for both fieldsRetry execution (
sdk/agenta/sdk/engines/running/handlers.py)_coerce_retry_confignow acceptsretry_policyand fills safe defaults when the policy is active and a field isNone:max_retries → 1,base_delay → 1000delay_ms / 1000to exponential(base_delay / 1000) * 2^attempt(attempt is 0-indexed, so first sleep =base_delay, second =base_delay * 2, etc.)_should_retryand_run_prompt_llm_config_with_retrypassretry_policythrough to coercion so defaults apply consistentlyRetry schedule
Max retries is capped at 5, giving a worst-case total wait of ~3.1s at 100ms base and ~31s at 1000ms base.
Frontend (
agenta-entity-ui)RetryConfigTab: propdelayMs→baseDelay, field key"delay_ms"→"base_delay", slider description updated to reflect exponential behavior; removed hardcodedmax=10000override (bounds now come from schema)PlaygroundConfigSection: alldelay_msreferences updated throughoutDocs (
docs/docs/)prompt-engineering/integrating-prompts/07-fallback-models-and-retry.mdx: JSON example updated, prose updated to describe exponential backoffreference/sdk/01-configuration-management.mdx: reference table updated (delay_ms→base_delaywith range), JSON example updatedreference/sdk/03-custom-workflow.mdx: code example and parameter description updatedTests
"delay_ms"→"base_delay") in SDK and API unit tests_coerce_retry_configdefault assertions updated to reflectNonedefaults