Repository navigation
feat(tools): environment simulation chaos engineering — call targeting (1/3) - #8474
Open
sadayamuthu wants to merge 5 commits into
Open
sadayamuthu wants to merge 5 commits into
sadayamuthu wants to merge 5 commits into
Conversation
A run that pauses on a tool confirmation or credential request is resumed under the same invocation id, so its call counts are kept and on_calls numbering continues. A run that fails now releases the invocation's call counts through on_run_error_callback.
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:
This is PR 1 of 3 adding chaos engineering for ADK agents to Environment Simulation. It adds call targeting. PR 2 adds real-result corruption and PR 3 adds an injection record.
Problem:
An
InjectionConfigapplies to every call of a tool that matches itsmatch_args. That cannot express the most common resilience scenario: the first call fails, and the agent's retry should reach the real tool. Users have to approximate this with probabilities, which are not repeatable and can fail every call.Solution:
Add
InjectionConfig.on_calls, a list of 1-based call numbers within one invocation at which the injection may apply.EnvironmentSimulationPlugin.after_run_callbackdrops the session's counts when the run ends (only if they still belong to that invocation). A run that ends paused on an unanswered interrupt (a tool confirmation or credential request) keeps its counts, detected with the sameis_paused_invocationcheckReflectAndRetryToolPluginuses: the answer continues the invocation under the same invocation id, so numbering carries over to the resumed run. A call held for confirmation is counted when first attempted and again when it re-executes on resume.on_run_error_callbackdrops the counts unconditionally when a run fails. Without the plugin (create_callback), a call from a new invocation replaces the session's counts.on_callsexcludes the current call is skipped beforematch_argscomparison and before any draw, so it does not advance a seeded random sequence or start a semantic comparison.on_calls=None(the default) keeps today's behaviour. Existing configs are unaffected.on_callsmust be a non-empty list of distinct positive integers._drawand_seeded_generatorsare not touched.Testing Plan
Unit Tests:
pytest tests/unittests/tools/environment_simulation -q: 94 passed. New tests cover first-call failure with a real retry, unlisted calls, counts restarting per invocation, counts per session, combination withmatch_args, ineligible configs not consuming a seeded draw,on_calls=Noneunchanged, and MagicMock contexts.Added in review rounds:
test_ineligible_args_matcher_config_starts_no_comparison,test_ineligible_catch_all_does_not_block_later_exact_config,test_ineligible_config_is_not_compared_while_others_wait:on_callswithargs_matcherand catch-all ordering.test_release_invocation_drops_call_counts,test_release_invocation_keeps_newer_invocation,test_release_invocation_without_counts_is_noop: releasing counts at the end of an invocation.test_after_run_releases_call_counts: counts are gone after a realRunnerrun.test_paused_run_keeps_call_counts_for_resume: a call paused for confirmation and resumed withconfirmed=Trueis numbered 2, soon_calls=[2]applies on resume.test_run_error_releases_call_counts: counts are gone after aRunnerrun that fails.Multi-version tests: not run locally; relying on CI.
Manual End-to-End (E2E) Tests:
An
LlmAgentongemini-3.7-flashwith a reallookup_customertool runs throughRunnerwithon_calls=[1]and a 503 error.The run log will be added as a comment on this PR. Expected: the first
lookup_customercall returns the 503, the retry returns real data, and the agent answers correctly.Checklist
Additional context
1 of 3. PR 2 (real-result corruption) and PR 3 (injection record) are stacked on this branch.