Skip to content

[Feature]: Enrich SubagentCapture with SDKTaskNotificationMessage data #354

@sjnims

Description

@sjnims

Parent Issue

Sub-issue of #344 (Leverage Additional SDK v0.2.25 Capabilities)
Follow-up to #348 (Phase 2a)

Feature Type

SDK integration (Agent SDK)

Problem or Need

SDKTaskNotificationMessage is currently captured as a generic SDKEventCapture in sdk_events[] on ExecutionResult (implemented in #348 Phase 1). This provides basic storage but loses the opportunity to correlate task notifications with existing SubagentCapture entries, which would enrich subagent lifecycle tracking for Stage 4 evaluation.

The SDKTaskNotificationMessage contains:

  • task_id — correlates with SubagentCapture.agentId
  • status"completed" | "failed" | "stopped"
  • output_file — path to task output
  • summary — LLM-generated summary of task result

Proposed Solution

Move SDKTaskNotificationMessage from generic capture to targeted SubagentCapture enrichment:

  1. Extend SubagentCapture in src/types/transcript.ts with optional fields:

    • taskStatus?: "completed" | "failed" | "stopped"
    • taskOutputFile?: string
    • taskSummary?: string
  2. Update SDKEventCollector.processMessage() in src/stages/3-execution/sdk-event-collector.ts:

    • Accept subagentCaptures: SubagentCapture[] as a third parameter
    • Handle isTaskNotificationMessage() with targeted enrichment (correlate task_idagentId)
    • Fall through to generic capture if no matching SubagentCapture is found
  3. Update callers in agent-executor.ts and session-batching.ts to pass subagentCaptures to processMessage()

  4. Add tests for correlation logic, including edge cases:

    • Task notification matching an existing SubagentCapture
    • Task notification with no matching SubagentCapture (falls to generic)
    • Overlap with SubagentStop hook data (complementary, not conflicting)

Files Affected

  • src/types/transcript.ts — Extend SubagentCapture
  • src/stages/3-execution/sdk-event-collector.ts — Add targeted enrichment
  • src/stages/3-execution/agent-executor.ts — Pass subagentCaptures to collector
  • src/stages/3-execution/session-batching.ts — Pass subagentCaptures to collector
  • tests/unit/stages/3-execution/sdk-event-collector.test.ts — New test cases

Risk Assessment

Low risk. Additive optional fields on SubagentCapture. The type guard isTaskNotificationMessage() already exists from #348. No state migration needed.

Priority Rationale

Medium value — enriches subagent tracking with completion status and summaries. Low effort given the foundation from #348.


🤖 Created with Claude Code

Metadata

Metadata

Assignees

Labels

component:typesTypeScript interfaces (src/types/)effort:small< 1 hourenhancementNew feature or requestpriority:mediumShould be addressedscope:agentsAgent triggering evaluationsdk: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