-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
There are 3 separate tables tracking agent activity, with overlapping fields and inconsistent data:
- `sessions` (session logs) — date, branch, title, summary, model, duration, cost, prUrl, checksYaml, learnings, recommendations
- `agent_sessions` (live tracking) — branch, task, sessionType, issueNumber, checklistMd, status, startedAt, completedAt
- `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
- 3 separate tables with overlapping fields
- 200 agent_sessions but only 80 session logs
- Agent Sessions dashboard uses fragile branch-name join
- Issue Consolidate 3 agent-tracking dashboards (E912, E913, E925) into 1 #1491 covers dashboard consolidation (related but distinct)
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