Skip to content

More hook lifecycle events (subagent_start/stop, pre_compact, post_tool_failure) #29

Description

@aakashrajput

Why

Hooks v2 currently covers before/after message and tool events. Power users automating around the CLI need more lifecycle events, matching what other agent CLIs expose.

What

Add these hook events (same JSON-on-stdin protocol as existing hooks):

  • subagent_start / subagent_stop — when delegate_task spawns/finishes a subagent (payload: persona, prompt summary, background flag, result status)
  • pre_compact — before compaction runs (payload: trigger auto|manual, estimated tokens); non-blocking
    (Note: session_start/session_end are tracked separately in Add session_start/session_end hook events #9 — this issue covers the remaining events; coordinate if you take both.)
  • post_tool_failure — when a tool execution errors (payload: tool name, error) — distinct from the existing after-tool event

Only before_tool stays blocking; all new events are fire-and-forget.

Where to start

  • Hook dispatch lives in src/screens/repl.ts — follow the existing event pattern
  • Subagent lifecycle: src/tools/index.ts (delegate_task) / src/tools/background.ts
  • Compaction trigger: src/agent/compaction.ts call sites

Acceptance criteria

  • Events fire with documented payloads; docs section updated
  • Existing hooks unaffected; typecheck + tests green

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions