Skip to content

Consolidate 3 session tracking systems into unified model #1668

@OAGr

Description

@OAGr

Problem

There are 3 separate tables tracking agent activity, with overlapping fields and inconsistent data:

  1. `sessions` (session logs) — date, branch, title, summary, model, duration, cost, prUrl, checksYaml, learnings, recommendations
  2. `agent_sessions` (live tracking) — branch, task, sessionType, issueNumber, checklistMd, status, startedAt, completedAt
  3. `active_agents` + `agent_session_events` (real-time coordination) — sessionId, branch, task, status, currentStep, heartbeat, events timeline

Fields like `branch`, `task/title`, `status`, `model`, and `issueNumber` are duplicated across systems. The Agent Sessions dashboard (E912) joins data from both `agent_sessions` and `sessions` tables by branch name — a fragile heuristic that can mismatch.

This creates maintenance overhead and inconsistent data (e.g., 200 agent_sessions but only 80 session logs — which 120 are missing?).

Proposed Fix

Consolidate into a single `agent_sessions` table that covers the full lifecycle:

  • Registration (what was started, when, on what branch/issue)
  • Live tracking (heartbeat, current step, events)
  • Completion (what was done, cost, duration, PR URL, learnings)

Use the `agent_session_events` table for the timeline (already exists), and retire the separate `sessions` table.

Evidence

Acceptance Criteria

  • Single table tracks full session lifecycle
  • No data duplication across tables
  • Dashboard uses direct FK relationships, not branch-name matching

From PR quality audit — systematic investigation of fix chains across 200 PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions