Agent Observability & Event Streaming

t-197·Epic·
·
·
·Omni/Agent.hs
Created3 months ago·Updated3 months ago

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]

Timeline (1)

🔄[human]Open → Done3 months ago