MCPcopy
hub / github.com/shareAI-lab/learn-claude-code / summary_hook

Function summary_hook

s04_hooks/code.py:218–223  ·  view source on GitHub ↗
(messages: list)

Source from the content-addressed store, hash-verified

216
217# Stop hook: print summary when loop is about to exit
218def summary_hook(messages: list):
219 tool_count = sum(1 for m in messages
220 for b in (m.get("content") if isinstance(m.get("content"), list) else [])
221 if isinstance(b, dict) and b.get("type") == "tool_result")
222 print(f"\033[90m[HOOK] Stop: session used {tool_count} tool calls\033[0m")
223 return None
224
225register_hook("UserPromptSubmit", context_inject_hook)
226register_hook("PreToolUse", permission_hook)

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected