feat: add step-level timing (startedAtMs / completedAtMs) #489

Closed
opened 2026-05-25 03:11:37 +00:00 by xiaoju · 0 comments
Owner

What

Add startedAtMs and completedAtMs timestamps to StepNode, enabling step-level duration tracking.

Current state

  • CAS node has a single timestamp (write time = completion time)
  • Agent detail has durationMs (agent execution only, excludes moderator + overhead)
  • No way to know how long a step took end-to-end

Proposed fields

// Added to StepRecord (workflow-protocol/types.ts)
startedAtMs: number;   // Date.now() before agent spawn
completedAtMs: number; // Date.now() after agent returns

Required fields — no backward compat, delete old data.

Changes required

1. Protocol (workflow-protocol/types.ts)

  • StepRecord: add startedAtMs: number and completedAtMs: number (required)
  • StepEntry: add durationMs: number (computed: completedAt - startedAt)

2. JSON Schema (cli-workflow/src/schemas.ts)

  • StepNode schema: add two required integer properties

3. Engine (workflow-agent-kit/src/run.ts)

  • Record Date.now() before agent execution
  • Record Date.now() after agent returns
  • Pass both to writeStepNode

4. CLI display

Command Change
step list Show durationMs per step
step read Add duration to header
thread read formatStepHeader shows duration
thread show --json Include timing fields in JSON output
thread show (human) Optional: total thread wall time

5. Dashboard (workflow-dashboard/src/pages/detail.tsx)

  • Show duration per step in the step list

6. Breaking change

  • Fields are required, not optional
  • Old CAS data without these fields is invalid — delete and re-run
  • No migration, no fallback
## What Add `startedAtMs` and `completedAtMs` timestamps to StepNode, enabling step-level duration tracking. ### Current state - CAS node has a single `timestamp` (write time = completion time) - Agent detail has `durationMs` (agent execution only, excludes moderator + overhead) - No way to know how long a **step** took end-to-end ### Proposed fields ```ts // Added to StepRecord (workflow-protocol/types.ts) startedAtMs: number; // Date.now() before agent spawn completedAtMs: number; // Date.now() after agent returns ``` **Required fields** — no backward compat, delete old data. ## Changes required ### 1. Protocol (workflow-protocol/types.ts) - `StepRecord`: add `startedAtMs: number` and `completedAtMs: number` (required) - `StepEntry`: add `durationMs: number` (computed: completedAt - startedAt) ### 2. JSON Schema (cli-workflow/src/schemas.ts) - StepNode schema: add two required integer properties ### 3. Engine (workflow-agent-kit/src/run.ts) - Record `Date.now()` before agent execution - Record `Date.now()` after agent returns - Pass both to `writeStepNode` ### 4. CLI display | Command | Change | |---------|--------| | step list | Show durationMs per step | | step read | Add duration to header | | thread read | formatStepHeader shows duration | | thread show --json | Include timing fields in JSON output | | thread show (human) | Optional: total thread wall time | ### 5. Dashboard (workflow-dashboard/src/pages/detail.tsx) - Show duration per step in the step list ### 6. Breaking change - Fields are required, not optional - Old CAS data without these fields is invalid — delete and re-run - No migration, no fallback
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#489