MCPcopy Create free account
hub / github.com/LLMQuant/quant-mind / _RecordingHooks

Class _RecordingHooks

tests/flows/test_runner.py:19–45  ·  view source on GitHub ↗

Test hook that records every lifecycle call on a shared list.

Source from the content-addressed store, hash-verified

17
18
19class _RecordingHooks(RunHooks[Any]):
20 """Test hook that records every lifecycle call on a shared list."""
21
22 def __init__(self, label: str, log: list[tuple[str, str]]) -> None:
23 self.label = label
24 self.log = log
25
26 async def on_llm_start(self, *_: Any, **__: Any) -> None:
27 self.log.append((self.label, "on_llm_start"))
28
29 async def on_llm_end(self, *_: Any, **__: Any) -> None:
30 self.log.append((self.label, "on_llm_end"))
31
32 async def on_agent_start(self, *_: Any, **__: Any) -> None:
33 self.log.append((self.label, "on_agent_start"))
34
35 async def on_agent_end(self, *_: Any, **__: Any) -> None:
36 self.log.append((self.label, "on_agent_end"))
37
38 async def on_handoff(self, *_: Any, **__: Any) -> None:
39 self.log.append((self.label, "on_handoff"))
40
41 async def on_tool_start(self, *_: Any, **__: Any) -> None:
42 self.log.append((self.label, "on_tool_start"))
43
44 async def on_tool_end(self, *_: Any, **__: Any) -> None:
45 self.log.append((self.label, "on_tool_end"))
46
47
48class ComposeHooksTests(unittest.TestCase):

Calls

no outgoing calls