Skip to content

feat: agent-reported structured reports via MCP + dashboard display #918

Description

@vybe

Summary

Give agents a structured way to report telemetry and arbitrary domain reports back to Trinity via an MCP tool. Persist them in SQLite and surface them on a dashboard so users can see what each agent is producing without reading chat transcripts.

Context

Today agents only emit unstructured text (chat, logs) and a fixed set of metrics (cost, context, tool counts). Anything domain-specific — leads found, emails sent, deals progressed, KPI snapshots, weekly summaries — is buried in chat history. We need a generic "agent report" primitive that's typed enough to display but flexible enough to fit any agent.

Proposed Shape

MCP tool (new):

report(report_type: str, title: str, payload: dict, schema_version?: int, period_start?: str, period_end?: str)
  • report_type namespaced (e.g. recon.weekly_summary, prospector.leads_found, ops.daily_health, custom.*)
  • payload arbitrary JSON
  • Resolves agent + user from MCP auth context (no spoofing)

Storage: new agent_reports table (id, agent_name, user_id, report_type, title, payload JSON, schema_version, period_start/end, created_at). Index on (agent_name, created_at DESC) and (report_type, created_at DESC).

Backend: routers/reports.py — list/get/delete with the standard owner/sharing/admin gate. WebSocket agent_report broadcast for live updates.

Frontend: a "Reports" tab on AgentDetail + a fleet-wide Reports view on the dashboard. Generic renderer that knows a handful of payload shapes (table, KPI tiles, markdown, timeline) chosen by report_type prefix or a display_hint field.

Example report types

  • prospector.weekly_leads → table of leads with score
  • recon.competitor_changes → timeline of detected changes
  • ops.fleet_health → KPI tiles (uptime, errors, cost)
  • kb-agent.coherence → markdown summary + counters
  • chief-of-staff.daily_brief → markdown
  • custom.* → free-form, rendered as JSON viewer

Acceptance Criteria

  • agent_reports table + schema migration
  • MCP tool report (and matching backend endpoint) with auth-context resolution
  • GET /api/agents/{name}/reports and GET /api/reports (fleet-wide, access-controlled)
  • WebSocket agent_report broadcast
  • AgentDetail "Reports" tab with generic + typed renderers
  • Dashboard fleet Reports view with filters (agent, type, time range)
  • Retention sweep in cleanup_service (default 90d, configurable)

Technical Notes

  • Follows the three-surface rule: backend router, MCP tool, frontend store/view
  • No agent-server endpoint needed — reports flow agent → MCP → backend
  • Per-user scoping: same access model as agent_activities / chat_messages
  • Consider audit-log entry on report write (low priority; reports themselves are the audit)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions