-
Notifications
You must be signed in to change notification settings - Fork 345
Closed
Description
Problem
Currently, hooks receive different context depending on which hook type they are:
MESSAGE_POST_PROCESS: Receiveslog,workspace,managerTOOL_POST_EXECUTE: Only receivestool_nameandtool_use
This inconsistency makes it difficult to implement awareness tools that need access to conversation state.
Current Implementation
# In ToolUse.execute()
def execute(...):
# ...
result = tool_func(...)
run_hook(
hook_name="TOOL_POST_EXECUTE",
tool_name=tool.name,
tool_use=self,
)Desired Implementation
All hooks should receive the same baseline context:
def execute(self, log, workspace, manager):
# ...
result = tool_func(...)
run_hook(
hook_name="TOOL_POST_EXECUTE",
log=log,
workspace=workspace,
manager=manager,
tool_name=tool.name,
tool_use=self,
)Use Case
The token-awareness and time-awareness tools need to show budget/time information after each tool execution (similar to how Anthropic shows token usage after tool results). Currently, they can only use MESSAGE_POST_PROCESS because TOOL_POST_EXECUTE doesn't have access to log (needed for token calculation) or workspace (needed for tracking state).
Impact
- Makes hook system more consistent and predictable
- Enables awareness tools to provide feedback after individual tool executions
- Reduces coupling between hook types and their capabilities
Related
- PR feat: add token & time awareness tools/hooks #665: Token and time awareness tools (currently using MESSAGE_POST_PROCESS as workaround)
Metadata
Metadata
Assignees
Labels
No labels