test: set _incremental_persistence_failed=False on MagicMock agent

PR #72425 added getattr(agent, '_incremental_persistence_failed', False)
checks at the top of execute_tool_calls_{sequential,concurrent,segmented}.
A bare MagicMock auto-creates a truthy value for any attribute access,
so the interrupt-skip test's MagicMock agent short-circuited before
appending cancelled-tool messages — assert len(messages)==3 got 0.

Production is unaffected: run_conversation resets the flag to False
explicitly at turn start (conversation_loop.py:~1028).
This commit is contained in:
kshitijk4poor 2026-07-27 23:34:20 +05:00 committed by kshitij
parent 8e934e84ac
commit 51a36f1fc1
1 changed files with 5 additions and 0 deletions

View File

@ -122,6 +122,11 @@ class TestPreToolCheck:
agent._interrupt_requested = True
agent.log_prefix = ""
agent._persist_session = MagicMock()
# PR #72425: execute_tool_calls_* read _incremental_persistence_failed
# via getattr at loop top. A bare MagicMock auto-creates a truthy value
# for any attribute access, which would short-circuit the interrupt
# skip path before any cancelled-tool messages are appended.
agent._incremental_persistence_failed = False
# Import and call the method
import types