Agent Observability & Event Streaming

t-197·Epic·
·
·
·Omni/Agent.hs
Created5 months ago·Updated5 months ago·pipeline runs →

Execution Summary

8/8
Tasks Completed
$0.00
Total Cost
0s
Total Time

Design

Edit

Add structured event logging and streaming for agent work sessions, enabling real-time observation in the web UI and future interactive chat.

Goals

  • Full visibility into agent reasoning and tool usage
  • Real-time streaming to web UI via SSE
  • Persistent event log for debugging and learning
  • Design supports future interactive chat

Architecture

Engine.hs                    Event Store              Web UI
    │                            │                      │
    ├─ onAssistantMessage ──────►│ INSERT event         │
    │                            │──── SSE push ───────►│ render
    ├─ onToolCall ──────────────►│ INSERT event         │
    │                            │──── SSE push ───────►│ render  
    ├─ onToolResult ────────────►│ INSERT event         │
    │                            │──── SSE push ───────►│ render

Schema

CREATE TABLE agent_events (
  id INTEGER PRIMARY KEY,
  task_id TEXT NOT NULL,
  session_id TEXT NOT NULL,
  timestamp DATETIME,
  event_type TEXT,  -- assistant, tool_call, tool_result, user, cost, error, complete
  content TEXT,     -- JSON payload
  FOREIGN KEY (task_id) REFERENCES tasks(id)
);

Event Types

data AgentEvent
  = EventAssistant Text
  | EventToolCall Text Value
  | EventToolResult Text Bool Text
  | EventUserMessage Text
  | EventCost Int Int
  | EventError Text
  | EventComplete

Child Tasks

  • t-197.1 - Define AgentEvent type and JSON serialization [Done]
  • t-197.2 - Add agent_events table and storage functions [Done]
  • t-197.3 - Integrate event logging into Engine.hs [Done]
  • t-197.5 - Add agent event viewer to task detail page [Done]
  • t-197.4 - Add SSE streaming endpoint for agent events [Done]
  • t-197.6 - Add jr task log CLI command [Done]
  • t-197.7 - Fix Agent Log scroll position reset on HTMX poll [Done]
  • t-197.8 - Fix cost reporting - parse actual cost from OpenRouter API response [Done]

Git Commits

79b1b062Fix cost reporting - parse actual cost from OpenRouter API response
Ben Sima5 months ago1 files
3945b6faFix cost reporting - parse actual cost from OpenRouter API response
Ben Sima5 months ago2 files
7df03171Fix Agent Log scroll position reset on HTMX poll
Ben Sima5 months ago1 files
1624e439Add jr task log CLI command
Ben Sima5 months ago2 files
f8eb55d3Add SSE streaming endpoint for agent events
Ben Sima5 months ago1 files
9fa7697cAdd agent observability: event logging and storage
Ben Sima5 months ago4 files

Timeline (1)

🔄[human]Open → Done5 months ago