Repository navigation
Configurable retries; retry empty answers instead of ending the turn silently - #320
Merged
Merged
Conversation
…ing the turn One RetryPolicy (llm::retry, retry.json, Settings → General) bounds the retries of a failed LLM request — at most N or until it succeeds — and the wait between them. The clients use it for rate limits and transient errors, the agent loop for broken or stalled streams. An answer without content ended the turn as if the model had answered: nothing was recorded, the history still ended in the user's message, and the session showed Resume without an error. The agent loop now treats it as a failed request (EmptyResponse) and retries it under the same policy.
The agent loop recognised errors by their text and retried overloaded and network errors the client had already given up on, so N retries became (N+1)² − 1 requests. A client now marks such an error RetriesExhausted and the agent loop leaves it alone. A maximum wait of 0 counts as one second, so retrying forever cannot send requests back to back.
A model that answers a prompt empty may do so every time, so unlimited retries could send paid requests until someone stops the session. The policy is now just the number of retries and the longest wait.
None of the zip code paths is reached: nothing extracts to the file system, reads archives as a stream, decrypts entries or builds legacy-zip. chrono has no maintained release to move to. Also update the yanked async-executor.
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.
Problem
Users came back to sessions that had stopped with the Resume button showing, but no error and no visible retries.
One cause: when the model answered with no content at all, the agent loop treated that as the end of the turn. Nothing was recorded, so the history still ended with the user's message or the tool results, and the session sat idle and resumable.
How rate limits are handled also couldn't be configured: there were always 3 retries, and the backoff had no upper bound.
Change
llm::RetryPolicy,<config_dir>/retry.json, Settings → General → Failed requests): retry until the request succeeds, or at most N times, plus the longest wait between retries. This cap also applies when the provider asks for a longer wait. Defaults: 5 retries, at most 300 s.LLMProvider::set_retry_policy; the default for that method is a no-op, which Ollama and the WebSocket client keep.agent_core::types::EmptyResponse).DefaultRecoveryretries it under the policy, together with broken streams and, new, stalled streams. Once the retries run out, the session fails and shows the error.attempt/max, or onlyattemptwhen there is no limit (max_attempts: Option<u32>).docs/retry-policy.mdand a section in AGENTS.md.Not tried in the app
Not tried in the app yet.
cargo test,clippyandfmtall pass.