Skip to content

trace: group related runs and show persisted parent-child lineage #2900

Description

@alectimison-maker

Summary

The trace recorder now persists session identity and parent-run metadata, and the Traces page can display per-run statistics and step-level trajectory details. Related runs are still presented as a flat list, so users cannot follow a browser run into a cloud execution or replay.

This issue proposes the next focused Traces improvement: group related runs by session and render their persisted parent-child relationships.

User-visible outcome

  • Runs belonging to one session appear together.
  • Parent and child runs are shown in an expandable hierarchy.
  • Selecting a node opens the existing run timeline, statistics, trajectory table, compare action, and export action.
  • Missing or legacy relationships remain usable as standalone roots.

Proposed design

Lineage model

Use persisted run records only:

  • Session identity remains the existing conversation/session identifier.
  • runId identifies one recorded execution.
  • parentRunId identifies the run that launched a derived execution.
  • parentSessionId remains metadata for cross-session relationships.
  • Build the hierarchy with a pure function over records; do not depend on live agent state.

The tree builder should:

  • attach children by parentRunId;
  • sort siblings deterministically by startedAt then runId;
  • treat missing parents as visible roots with an orphan marker;
  • guard against duplicate IDs and cycles;
  • tolerate legacy records with missing lineage fields.

Future telemetry export identity

To keep the model usable outside the UI, propose:

  • one logical session maps to one OTLP trace;
  • each run maps to one span in that trace;
  • a derived run uses the parent run span as parentSpanId;
  • step rows are represented as span events initially; promote them to child spans only if stable step identity and timing are available;
  • when session or parent metadata is missing, keep the current deterministic hash fallback.

This issue asks maintainers to confirm this mapping; it does not change the exporter yet.

Scope

In scope:

  • Session grouping and lineage navigation in Chrome and Firefox.
  • A pure lineage-tree helper with unit tests.
  • UI integration without changing event payloads or adding a new persistence table.
  • Regression coverage for the current timeline, statistics, trajectory, compare, export, and refresh behavior.

Out of scope:

  • Changing the recorder event schema.
  • Redesigning session statistics.
  • Implementing the OTLP mapping.
  • Loading unbounded session history in one request.

Compatibility and privacy

  • Existing records without lineage metadata remain readable.
  • IDs only; no message content should be copied into lineage nodes.
  • Unknown event kinds and existing export behavior remain unchanged.
  • Large sessions should use a bounded or paged query, or clearly indicate incomplete loading.

Acceptance criteria

  • Runs with the same session identity are grouped without replaying their event streams.
  • Parent-child links are derived from persisted runId and parentRunId values.
  • Orphans, duplicate IDs, cycles, and legacy records do not break rendering.
  • Selecting any node preserves the existing timeline, statistics, trajectory, compare, export, and refresh workflows.
  • Chrome and Firefox behavior is covered by equivalent tests.
  • The proposed session/run/step identity mapping is documented in the implementation or follow-up export issue before OTLP changes begin.

References

Maintainer questions

  1. Is the proposed mapping of session to trace, run to span, and step to event the desired export contract?
  2. Should step-level spans remain deferred until stable step identifiers and timing semantics are available?
  3. Is an expandable hierarchy the preferred Traces interaction, or should the first version use a compact grouped list with parent links?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions