Skip to content

[Feature]: Add SessionStart/SessionEnd hooks for lifecycle tracking #349

@sjnims

Description

@sjnims

Parent Issue

Sub-issue of #344 (Leverage Additional SDK v0.2.25 Capabilities)

Feature Type

SDK integration (Agent SDK)

Problem or Need

Session timing currently relies on manual Date.now() calls (agent-executor.ts:226, session-batching.ts:703). This doesn't distinguish between session startup time (subprocess spawn + plugin load + MCP initialization) and actual execution time. This gap makes it harder to diagnose performance issues in session batching.

Proposed Solution

Implement SDK v0.2.25 SessionStart and SessionEnd hooks to track session lifecycle events.

Benefits:

  • Accurate timing for session startup vs execution
  • Better diagnostics for session batching performance
  • Helps identify slow plugin/MCP initialization

Implementation approach:

  • Add SessionStart and SessionEnd hook types to hooks-factory.ts
  • Follow existing HookCallbackMatcher pattern
  • Capture timing data for diagnostics
  • Useful for session batching metrics

Files Affected

  • src/stages/3-execution/hooks-factory.ts — New hook types
  • src/stages/3-execution/sdk-client.ts — QueryOptions hooks, new input types
  • src/types/transcript.ts — New capture types

Risk Assessment

Low risk — Purely observational hooks. No changes to execution behavior.

Priority Rationale

Medium value for diagnostics. Primarily useful for session batching metrics and debugging.


🤖 Created with Claude Code

Metadata

Metadata

Assignees

Labels

component:typesTypeScript interfaces (src/types/)effort:medium1-4 hoursenhancementNew feature or requestperformancePerformance and efficiency improvementspriority:mediumShould be addressedscope:hooksHook evaluation (Phase 2)sdk:agentClaude Agent SDK usage (Stage 3)stage:executionStage 3: Agent SDK execution with tool capturestatus:analyzedIssue has been analyzed by Claude

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions