feat(hooks): log agent_type/agent_id per hook fire for visibility (#606)

This commit is contained in:
AIOSAI
2026-06-02 22:02:22 -07:00
parent e63a4e9945
commit 87d131218e
2 changed files with 10 additions and 1 deletions
+6
View File
@@ -27,6 +27,12 @@ and this project uses [Calendar Versioning](https://calver.org/) in the format
the hook engine, not tied to Claude Code permission rules), conservative
(unparseable targets are blocked, not allowed), and skips `drone rm` itself.
This makes the safe-delete path discoverable at the moment of friction. (#630)
- **Hook engine logs `agent_type` / `agent_id` per fire** — the engine now
records which agent triggered each hook (e.g. `agent=main` vs `agent=Explore`)
in both `engine.jsonl` and the prax monitor stream. Previously the payload
flowed into handlers but was never logged, leaving no way to tell an internal
main-turn fire from a real sub-agent fire. Pure visibility; no behavior change.
Groundwork for #606. (#606)
### Changed
+4 -1
View File
@@ -139,9 +139,10 @@ def dispatch(event_type: str, stdin_data: str, config: dict) -> str:
result = _run_hook(command, stdin_data, timeout_s=hook_timeout)
logger.info(
"[HOOKS] %s.%s exit=%d out=%db %dms",
"[HOOKS] %s.%s agent=%s exit=%d out=%db %dms",
event_type,
hook_name,
parsed.get("agent_type", "") or "main",
result["exit_code"],
len(result["stdout"]),
result["elapsed_ms"],
@@ -151,6 +152,8 @@ def dispatch(event_type: str, stdin_data: str, config: dict) -> str:
"ts": time.time(),
"event": event_type,
"hook": hook_name,
"agent_type": parsed.get("agent_type", ""),
"agent_id": parsed.get("agent_id", ""),
"exit_code": result["exit_code"],
"elapsed_ms": result["elapsed_ms"],
"stdout_len": len(result["stdout"]),