fix: update facade tests for contextvar hooks + fix ephemeral guard

The test_run_populates_tools_used_across_iterations,
test_run_populates_final_messages, and
test_run_user_hooks_still_fire_alongside_capture tests were reading
bot._loop._extra_hooks directly in their fake_process_direct mocks,
but the contextvar change moved per-call hooks to _per_call_hooks.

Also fixes the ephemeral guard: per_call hooks should not be used in
ephemeral mode (the original code incorrectly applied them regardless).
This commit is contained in:
michaelxer
2026-06-21 15:59:28 +08:00
committed by Xubin Ren
parent 0bb1b0b3c2
commit 345ef80571
2 changed files with 13 additions and 5 deletions
+3 -1
View File
@@ -728,7 +728,9 @@ class AgentLoop:
)
hook: AgentHook = loop_hook
per_call = _per_call_hooks.get()
extra_hooks = per_call if per_call is not None else (self._extra_hooks if not ephemeral else None)
extra_hooks = None
if not ephemeral:
extra_hooks = per_call if per_call is not None else self._extra_hooks
if extra_hooks:
hook = CompositeHook([loop_hook] + extra_hooks)