(messages: list)
| 216 | |
| 217 | # Stop hook: print summary when loop is about to exit |
| 218 | def 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 | |
| 225 | register_hook("UserPromptSubmit", context_inject_hook) |
| 226 | register_hook("PreToolUse", permission_hook) |