Repository navigation
fix(plugins): drop per-invocation retry counts when a run ends - #7638
Open
Somay-kousis wants to merge 1 commit into
Open
Somay-kousis wants to merge 1 commit into
Somay-kousis wants to merge 1 commit into
Conversation
ReflectAndRetryToolPlugin and ReflectAndRetryModelPlugin track failures per invocation by default. The entry for an invocation was created on its first failure and never removed: a success only cleared the tool or model name inside it. A long-running server therefore kept one entry for every invocation that ever saw a failure. Add ScopedFailureTracker.clear_scope and have both plugins clear the invocation's scope from after_run_callback and on_run_error_callback when tracking per invocation. GLOBAL scope counts are kept.
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
ReflectAndRetryToolPluginandReflectAndRetryModelPlugintrack failures per invocation by default. An invocation's entry was created on its first failure and never removed. A success only cleared the tool or model name inside it, so a long-running server kept one entry for every invocation that ever saw a failure.Solution:
ScopedFailureTracker.clear_scope(scope_key)drops a whole scope under the tracker's lock.after_run_callbackandon_run_error_callback. UnderTrackingScope.INVOCATIONthey clear that invocation's scope. The runner calls one or the other at the end of every run, so the entry goes away whether the run finished, ran out of retries, or failed because the plugin re-raised the tool error.TrackingScope.GLOBALis untouched, so its counts still carry across runs.Counting inside a run doesn't change.
One behavior note: a resumable invocation that pauses and is resumed later now starts its counts from zero in the resumed run, because the paused run ended. Happy to skip clearing for paused invocations instead if you prefer.
Testing Plan
Unit Tests:
New tests:
test_reflect_retry_tool_plugin.py, throughInMemoryRunner: the tracker is empty after runs where the tool fails then succeeds, after runs where retries run out, and after a run that fails because the plugin re-raises. AGLOBALscope test checks that its counts survive the run.test_reflect_retry_model_plugin.py, throughInMemoryRunner: the tracker is empty after runs with a malformed model response.test_reflect_retry_utils.py:clear_scopedrops only the named scope, and is a no-op for an unknown one.Removing each new cleanup call makes the matching test fail.
tests/unittests/pluginsandtests/unittests/runnerspass (1514 passed, 2 skipped, 3 xfailed). isort, pyink and mypy are clean on the changed files.Manual End-to-End (E2E) Tests:
The repro in the issue (
App+Runner, scripted model, flaky tool):Checklist