Skip to content

Make TOOL_POST_EXECUTE hook consistent with other hooks #748

@TimeToBuildBob

Description

@TimeToBuildBob

Problem

Currently, hooks receive different context depending on which hook type they are:

  • MESSAGE_POST_PROCESS: Receives log, workspace, manager
  • TOOL_POST_EXECUTE: Only receives tool_name and tool_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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions