Skip to content

Long-loop run history truncation drops container + early-iteration step logs (compactStepsForHistory) #3234

Description

@os-zhuang

Follow-up to #1505 (region step logs) — now that per-iteration / per-region body steps are recorded (engine) and surfaced (objectui#2667), a durable-history edge case remains.

The gap

AutomationEngine.compactStepsForHistory() bounds the persisted step log to the last MAX_PERSISTED_HISTORY_STEPS entries:

// packages/services/service-automation/src/engine.ts
private compactStepsForHistory(steps: StepLogEntry[]): StepLogEntry[] {
    return steps.slice(-MAX_PERSISTED_HISTORY_STEPS).map(...);
}

This keeps steps_json cheap under retention (#2585), but with the #1505 structured-region work a single loop can now emit many steps (iterations × body-steps). For a long loop the tail-slice can drop:

  • the loop/parallel/try_catch container step itself (it precedes all its body steps), and
  • the early iterations' body steps.

Impact

listRuns / getRun serve the durable row after a process restart or ring-buffer eviction (the in-memory log has full detail; durable history is the fallback). So post-restart, the Runs surface shows only the loop's last few iterations, and — because the container step was sliced off — the objectui FlowRunsPanel (#2667) can no longer attach those body steps to their container. Its buildStepTree degrades them safely to top-level rows (visible, so nothing vanishes), but the per-iteration grouping and early-iteration detail are lost exactly for the big loops where they matter most for debugging/audit.

Possible directions (to decide)

  • Retain region boundaries when compacting: always keep each container step + a per-iteration summary (e.g. first/last iteration, failed iterations), downsampling the middle.
  • Or keep the newest N per region rather than N globally, so early iterations of a still-relevant region survive.
  • Or raise/relax the cap for region-bearing runs while keeping a hard byte ceiling on steps_json (Automation run observability — follow-ups (retention, discoverable Runs surface, durable run detail) #2585).
  • Whichever: keep buildStepTree's orphan-degradation as the safety net.

Files

  • packages/services/service-automation/src/engine.tscompactStepsForHistory, MAX_PERSISTED_HISTORY_STEPS, recordTerminal persistence path.
  • Consumer: objectui FlowRunsPanel.tsx (buildStepTree).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions