Repository navigation
fix(agent): retry a repetition cut that produced nothing - #1667
Merged
Merged
Conversation
A gateway with its own repetition guard can stop a looping model with a non-standard `finish_reason` (`repetition`) and no content at all. The chat adapter mapped that to `FinishReason::Unknown`, so the run loop classified the cut as `finish_unknown` and ended the whole run as an unconfirmed stream — the failure mode behind three dead runs in one eight-run session. - `FinishReason::Repetition` keeps the reason distinct, wire name `repetition`; every existing finish-reason mapping is unchanged. - `run_loop` classifies the cut as `provider_repetition` and re-sends the same turn inside the run when the cut left no text and no tool call: at most twice, under the existing automatic-retry switch, without consuming a turn. - Each retry is logged with `detected_by` and its attempt number. A cut that produced visible text or a tool call is never retried, and still ends the run with the same verdict as before. - Regression tests cover retry-then-recover, the two-retry ceiling, and both no-retry cases; removing the retry makes them fail. ## User-visible changes A run no longer dies when the model server's repetition guard cuts a turn that had produced nothing: the same turn is retried inside the run (twice at most) and the conversation continues. When the cuts repeat, or when the turn had already produced text or a tool call, the run still ends `incomplete` — now carrying `[RESPONSE_UNCONFIRMED] provider_repetition` instead of `finish_unknown`.
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.
A run no longer dies when a model gateway's repetition guard cuts a turn that had produced nothing. The chat adapter keeps
repetitionas its own finish reason, and the run loop classifies such a cut asprovider_repetitionand re-sends the same turn inside the run (at most twice, under the existing automatic-retry switch) instead of ending as an unconfirmedfinish_unknownstream. This was the failure mode behind three dead runs in one eight-run session.Commits
Verification
Local self-test at 588dcbb with the pinned Rust 1.99.1 toolchain and
ulimit -n 8192:cargo fmt --all -- --check-> cleancargo check -p future-agent --all-targets-> cleancargo clippy -p future-agent --all-targets -- -D warnings-> cleancargo test -p future-agent --lib-> 3124 passed, 0 failed, 7 ignoredUser-visible changes
A run that the model server's repetition guard cut before producing any text or tool call now retries that turn inside the same run (twice at most) and the conversation continues, instead of ending as an unconfirmed stream. A cut that produced visible text or a tool call is still never retried, and repeated cuts still end the run
incomplete-- now carrying[RESPONSE_UNCONFIRMED] provider_repetitioninstead offinish_unknown. Revert 5f0f28d.