Skip to content

[enhancement] Add Session Hooks for Tool Execution Visibility #7

@github-actions

Description

@github-actions

Background

The Copilot SDK introduced Session Hooks (PR #269 by @friggeri) that allow applications to observe and control tool executions in real time. The hooks API provides:

  • onPreToolUse - Called before each tool execution with permission to allow/deny or modify arguments
  • onPostToolUse - Called after tool execution with access to results
  • onUserPromptSubmitted - Called when user submits a prompt

This capability is now available in the Node.js SDK and was documented in v0.1.23+ releases.

Proposal

Integrate Session Hooks into Planeteer's execution flow to provide visibility into agent activity:

  1. Add hooks to src/services/copilot.ts - Configure onPreToolUse and onPostToolUse handlers when creating sessions
  2. Log tool usage during execution - Track which tools agents call during task execution (e.g., file operations, git commands, bash commands)
  3. Display tool activity in Execute screen - Show real-time tool execution summary in the execution UI (e.g., "git commit", "npm install", "file edits: 3 files")
  4. Emit hook events - Expose hook data through an EventEmitter or callback pattern so the Execute screen can subscribe
  5. Optional: Add tool execution log to plan persistence - Save tool execution history in .planeteer/(plan-id).json for post-execution review

Benefit

  • Transparency - Users see exactly what agents are doing under the hood
  • Trust building - Real-time visibility into tool usage increases confidence in agent actions
  • Debugging - Tool execution logs help diagnose issues when tasks fail
  • Audit trail - Persisted logs provide accountability for agent actions

Acceptance Criteria

  • onPreToolUse and onPostToolUse hooks configured in src/services/copilot.ts
  • Tool execution events logged to console or debug output during execution
  • Execute screen displays real-time tool usage summary (e.g., "Running: npm test", "Edited: 2 files")
  • Tool execution log optionally persisted in plan JSON (at minimum, in-memory during execution)
  • Manual testing confirms tool visibility for common operations (git, file edits, bash commands)

AI generated by Weekly Enhancement Suggestions

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions