Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.
This repository was archived by the owner on May 24, 2026. It is now read-only.

Add Session Hooks support (PreToolUse, PostToolUse, UserPromptSubmitted, etc.) #680

@PureWeen

Description

@PureWeen

Summary

The SDK provides 6 hook types that allow customizing session behavior at key lifecycle points. PolyPilot does not use any of them.

SDK Hooks

Hook Input Output Purpose
OnPreToolUse ToolName, ToolArgs, Cwd PermissionDecision, ModifiedArgs, AdditionalContext Block/modify tool calls before execution
OnPostToolUse ToolName, ToolArgs, ToolResult ModifiedResult, AdditionalContext Filter/transform tool output after execution
OnUserPromptSubmitted Prompt, Cwd ModifiedPrompt, AdditionalContext Rewrite prompts, inject context
OnSessionStart Cwd, Source, InitialPrompt AdditionalContext, ModifiedConfig Custom initialization
OnSessionEnd Reason, FinalMessage, Error CleanupActions, SessionSummary Custom cleanup
OnErrorOccurred Error, ErrorContext, Recoverable ErrorHandling, RetryCount Custom error recovery

Hook Events

  • HookStartEvent — hook invocation began (includes HookType, Input)
  • HookEndEvent — hook invocation completed (includes Output, Success, Error)

Proposed Implementation

  1. Hook configuration UI per session or per group (multi-agent preset)
  2. PreToolUse: Configurable tool approval policies (e.g., "always block rm -rf", "require approval for write operations")
  3. PostToolUse: Output filtering (e.g., redact secrets, collapse verbose output)
  4. UserPromptSubmitted: Auto-inject context like repo conventions, current task, or team decisions
  5. Hook activity log: Show when hooks fire and what they modified (via HookStart/HookEnd events)

Value

Power-user feature for customizing agent behavior. Enterprise users especially want tool approval policies and output filtering.

Priority: 🔴 HIGH

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions