Assistant Observability and Logging
The assistant module includes a robust observability stack for tracking performance, costs, tool health, and system audits.
Data Persistence
The observability system (in assistant/observability.go) uses a SQLite database with WAL (Write-Ahead Logging) for high-performance telemetry storage.
Key Metrics Tracked
- Request Logs: Every interaction includes model name, tokens (prompt/completion), cost, duration, and status.
- Tool Execution: Tracks average duration, success rates, and common error patterns for every tool.
- Provider Analytics: Compares latency and cost across different LLM providers (Anthropic, OpenAI, Ollama, etc.).
Logging Strategy
The system employs a dual logging strategy:
- JSONL Session Logs: Every step of the ReAct loop is logged in real-time to a
.jsonlfile in thechats/logs/directory. This allows for live debugging and auditing via Mission Control. - HTTP Request Logs: Standard HTTP telemetry is captured in
logs/http.logvia theLoggingMiddleware.
Mission Control Integration
The MissionControl dashboard (in assistant/missioncontrol.go) provides a real-time UI for these metrics:
- Real-time Reasoning: SSE-powered "Chain of Thought" logs.
- Tool Health Grid: Visualizes failing tools and sample error messages.
- Cost Monitoring: Real-time spending analysis per user and per provider.
Component Diagram: Observability Flow
graph TD
P[Planner] --> L[JSONL Session Logs]
P --> O[Observability DB]
O --> S[SQLite / WAL]
S --> MC[Mission Control Dashboard]
L --> MC
subgraph "Audit Layer"
P --> A[Architect Audit]
A --> SN[Sovereign/Infra Alerts]
end
Key Files & Functions
assistant/observability.go: CoreObservabilityDBimplementation and metric recording.assistant/session_logs.go: Logic for immediate, non-buffered JSONL log commitment.assistant/missioncontrol.go: SSE and WebSocket broadcasting of telemetry data.
Guidance for AI Agents
- Detailed Tool Responses: When a tool fails, provide descriptive error messages; these are captured in the health grid and help developers fix issues.
- Audit Awareness: Be aware that your reasoning (thoughts) and actions are logged and audited by the Architect agent for logic and security compliance.