-
-
Notifications
You must be signed in to change notification settings - Fork 55.7k
Description
Issue Description
While exploring the plugin hook system, I noticed that several hooks are defined in the type system and documented as available, but don't appear to have integration points in the actual execution flow.
Current Hook Status
✅ Working (4/12 hooks)
before_agent_start- Called insrc/agents/pi-embedded-runner/run/attempt.tsagent_end- Called insrc/agents/pi-embedded-runner/run/attempt.tsmessage_received- Called insrc/auto-reply/reply/dispatch-from-config.tstool_result_persist- Called insrc/agents/session-tool-result-guard-wrapper.ts
❓ Possibly Missing Integration (8/12 hooks)
before_tool_call- Has types and runner function, but no call sites foundafter_tool_call- Has types and runner function, but no call sites foundmessage_sending- Has types and runner function, but no call sites foundmessage_sent- Has types and runner function, but no call sites foundbefore_compaction- Has types and runner function, but no call sites foundafter_compaction- Has types and runner function, but no call sites foundsession_start- Has types and runner function, but no call sites foundsession_end- Has types and runner function, but no call sites foundgateway_start- Has types and runner function, but no call sites foundgateway_stop- Has types and runner function, but no call sites found
Technical Details
All hooks have complete infrastructure:
- Type definitions in
src/plugins/types.ts(lines 295-301) - Runner functions in
src/plugins/hooks.ts - Exported in hook runner interface
The missing piece appears to be the actual calls to the runner functions in the execution flow.
Verification Steps
I searched for hook calls in the codebase:
Working hooks found:
grep -r "\.runBeforeAgentStart\|\.runAgentEnd\|\.runMessageReceived\|\.runToolResultPersist" src/ --include="*.ts"Returns multiple call sites.
Other hooks not found:
grep -r "\.runBeforeToolCall\|\.runAfterToolCall\|\.runMessageSending\|\.runMessageSent\|\.runBeforeCompaction\|\.runAfterCompaction\|\.runSessionStart\|\.runSessionEnd\|\.runGatewayStart\|\.runGatewayStop" src/ --include="*.ts"Returns no results.
Impact
Plugin developers can register handlers for these hooks, but the handlers may never execute since the runner functions aren't called in the execution flow.
Possible Solution
The infrastructure exists - it might just need the missing hookRunner.runXXX() calls added to the appropriate execution points:
- Tool hooks: Could be added to tool execution handlers
- Message hooks: Could be added to message dispatch flows
- Compaction hooks: Could be added to compaction workflows
- Session/gateway hooks: Could be added to lifecycle management
Let me know if this analysis is helpful or if I'm missing something about how these hooks are supposed to work!