test(run_agent): align concurrent-interrupt _Stub with current AIAgent interface#18974
Open
Sanjays2402 wants to merge 1 commit into
Open
Conversation
…t interface `_execute_tool_calls_concurrent` has gained two attribute / call-site dependencies that the lightweight `_Stub` test fixture didn't carry: 1. `self._tool_guardrails.before_call(...)` is now consulted before each tool runs, and the result's `.allows_execution` gate decides whether to invoke the tool. The stub had no `_tool_guardrails` attribute, so both interrupt-fanout tests crashed with `AttributeError: '_Stub' object has no attribute '_tool_guardrails'`. 2. `self._append_guardrail_observation(name, args, result, failed=...)` is called for non-blocked results to fold guardrail observations into the tool output. The stub had no such method. Additionally, `_invoke_tool` is now invoked with `messages=` and `pre_tool_block_checked=` kwargs by the concurrent path, so the test fixtures' `slow_tool` / `polling_tool` callables raised `TypeError: ... got an unexpected keyword argument 'pre_tool_block_checked'`. Fix all three drifts: - `_tool_guardrails` is set to a permissive `MagicMock` whose `before_call`/`after_call` return objects with `allows_execution=True` (these tests aren't exercising guardrails). - `_append_guardrail_observation` is stubbed as a no-op pass-through. - `slow_tool` / `polling_tool` accept `**kwargs` so any future `_invoke_tool` plumbing is absorbed without yet another rewrite. The interrupt-fanout invariants the tests *do* exercise (worker-thread tid registration, `is_interrupted()` propagation across ThreadPoolExecutor workers, post-clear cleanup) are unchanged. No production code change. Fixes the two assertion failures observed on `main` (run 25250051126): `tests/run_agent/test_concurrent_interrupt.py::test_concurrent_interrupt_cancels_pending` `tests/run_agent/test_concurrent_interrupt.py::test_running_concurrent_worker_sees_is_interrupted`
This was referenced May 2, 2026
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.
Summary
Fixes two
Testsfailures observed onmain(and therefore propagating to every open PR):Reference run: 25250051126 on
5d3be898a.Root cause
_execute_tool_calls_concurrenthas gained three dependencies the lightweight_Stubfixture didn't carry:self._tool_guardrails.before_call(...)is consulted before each tool runs, and.allows_executiongates invocation. The stub had no_tool_guardrailsattribute →AttributeError: '_Stub' object has no attribute '_tool_guardrails'.self._append_guardrail_observation(name, args, result, failed=...)is called for non-blocked results to fold guardrail observations into the tool output. The stub had no such method._invoke_toolis called withmessages=andpre_tool_block_checked=kwargs by the concurrent path, so the fixtures'slow_tool/polling_toolcallables raisedTypeError: ... got an unexpected keyword argument 'pre_tool_block_checked'.Fix
_tool_guardrailsset to a permissiveMagicMockwhosebefore_call/after_callreturn objects withallows_execution=True(these tests aren't exercising guardrails)._append_guardrail_observationstubbed as a no-op pass-through.slow_tool/polling_toolaccept**kwargsso any future_invoke_toolplumbing is absorbed without yet another rewrite.The interrupt-fanout invariants the tests do exercise (worker-thread tid registration,
is_interrupted()propagation acrossThreadPoolExecutorworkers, post-clear cleanup) are unchanged.Validation
Scope
Out of scope
The other ~13 main-CI failures — happy to send those as separate focused PRs (one already up: #18972).