Skip to content

[Feature]: Add dedicated FilesPersistedCapture from SDKFilesPersistedEvent #355

@sjnims

Description

@sjnims

Parent Issue

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

Feature Type

SDK integration (Agent SDK)

Problem or Need

SDKFilesPersistedEvent is currently captured as a generic SDKEventCapture in sdk_events[] on ExecutionResult (implemented in #348 Phase 1). The raw payload is preserved but not structured for programmatic use. A dedicated capture type would improve checkpoint debugging and enable Stage 4 to reason about file persistence reliability.

The SDKFilesPersistedEvent contains:

  • files[]{ filename: string, file_id: string }[] — successfully persisted files
  • failed[]{ filename: string, error: string }[] — files that failed to persist
  • processed_at — ISO timestamp of persistence operation

Proposed Solution

Move SDKFilesPersistedEvent from generic capture to a dedicated type:

  1. Add FilesPersistedCapture in src/types/transcript.ts:

    export interface FilesPersistedCapture {
      files: { filename: string; file_id: string }[];
      failed: { filename: string; error: string }[];
      processed_at: string;
      timestamp: number;
    }
  2. Add optional field to ExecutionResult:

    • files_persisted_events?: FilesPersistedCapture[]
  3. Update SDKEventCollector in src/stages/3-execution/sdk-event-collector.ts:

    • Handle isFilesPersistedEvent() with targeted capture instead of generic
    • Store structured data in a separate array
  4. Wire through agent-executor.ts and session-batching.ts result building

  5. Add tests for the new capture path

Files Affected

  • src/types/transcript.ts — New FilesPersistedCapture interface, extend ExecutionResult
  • src/types/index.ts — Export new type
  • src/stages/3-execution/sdk-event-collector.ts — Targeted capture for files_persisted
  • src/stages/3-execution/agent-executor.ts — Wire through to result
  • src/stages/3-execution/session-batching.ts — Wire through to result
  • tests/unit/stages/3-execution/sdk-event-collector.test.ts — New test cases

Risk Assessment

Low risk. New optional field on ExecutionResult. No state migration needed. The type guard isFilesPersistedEvent() already exists from #348.

Priority Rationale

Low-medium value — primarily useful for debugging checkpoint issues. Low effort given the foundation from #348. Could be deferred until file checkpointing problems are encountered in practice.


🤖 Created with Claude Code

Metadata

Metadata

Assignees

Labels

component:typesTypeScript interfaces (src/types/)effort:small< 1 hourenhancementNew feature or requestpriority:lowNice to havesdk:agentClaude Agent SDK usage (Stage 3)stage:executionStage 3: Agent SDK execution with tool capturestatus:analyzedIssue has been analyzed by Claudetest:unitUnit test changes (tests/unit/)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions