fix(test_concurrent_interrupt): add _tool_guardrails to _Stub fixture (partial close hermes-agent#9) #13
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/concurrent-interrupt-stub-guardrails"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The
_Stubfixture intests/run_agent/test_concurrent_interrupt.pybypassesAIAgent.__init__, so it must mirror any new instance attributes that production methods rely on. Tool-loop guardrails (introduced in58b89965— fix(agent): add tool-call loop guardrails, 2026-04-27) added three integration points inside_execute_tool_calls_concurrentthat the stub had not been updated for:self._tool_guardrails.before_call(...)run_agent.py:9447self._append_guardrail_observation(...)run_agent.py:9672self._guardrail_block_result(...)Result: both
test_concurrent_interrupt_cancels_pendingandtest_running_concurrent_worker_sees_is_interruptedraisedAttributeError: '_Stub' object has no attribute '_tool_guardrails'the moment the first concurrent tool call entered the guardrail check.Fix
Single-file fixture update —
tests/run_agent/test_concurrent_interrupt.pyonly:self._tool_guardrails = ToolCallGuardrailController()to_Stub.__init__, mirroringAIAgent.__init__atrun_agent.py:1160. Default config is warning-only so the controller observes but never blocks — the tests still exercise interrupt fan-out, not guardrail behaviour._append_guardrail_observationand_guardrail_block_resulthelpers fromAIAgent(same pattern as the existing_execute_tool_calls_concurrent/interrupt/clear_interruptbindings)._set_tool_guardrail_haltas a no-op + add_tool_guardrail_halt_decision = None.slow_toolandpolling_toolside-effect signatures with**kwargsto swallow new production-only_invoke_toolkwargs (messages,pre_tool_block_checked) — same drift class.Diff: 21 insertions, 2 modifications, single file.
Test plan
pytest tests/run_agent/test_concurrent_interrupt.py -v— 4/4 pass (the two named tests + the two pre-existing passers, no regressions)pytest tests/run_agent/— 1193 passed, 9 skipped. The single failure (test_primary_runtime_restore.py::test_allowed_for_anthropic_direct) is unrelated — it fails because noOPENROUTER_API_KEYis set locally; it's part of the broader #9 cluster and explicitly out of scope for this PR.class _Stub:exists undertests/(tests/gateway/test_vision_memory_leak.py) — it stubsGatewayRunner, completely unrelated toAIAgent/_tool_guardrails. No further drift to mirror.Partial close of #9 — the concurrent-interrupt cluster only; the other ~19 failures are untouched.
🤖 Generated with Claude Code
LGTM. Root-caused via git blame to commit
58b89965('add tool-call loop guardrails'). Fixture mirrors new production attributes (_tool_guardrails + 3 integration points). Sibling audit confirmed no other drift. 4/4 named tests pass; 1193 in directory pass.