Skip to content

AI observability: $ai_generation capture over the ORB's review-pipeline AI calls (spike-first) #8296

Description

@JSONbored

Part of epic #8286 (Phase 3 — Depth). Spike-first, mirroring JSONbored/metagraphed#7763 — but loopover's AI surface is much larger than metagraphed's, so the payoff is too: per-provider/per-model cost, latency, failure, and rate-limit visibility over the review pipeline's real AI spend.

Current state

The ORB's AI calls flow through src/selfhost/ai.ts (provider attempts, rate limits, close-breaker engagement — the ai subsystem in the existing Sentry taxonomy), feeding advisory routing and per-reviewer AI votes. Cost/latency visibility today is logs + whatever Sentry catches on failure; there is no per-model spend/latency analytics at all.

Scope

  • Spike first: verify raw $ai_generation capture shape against a real PostHog project (event properties: model, provider, latency, token counts, cost where derivable, error/rate-limit outcome) — metagraphed's spike validates the Workers path; ours validates posthog-node from the self-host server.
  • Wire capture at the src/selfhost/ai.ts chokepoint (attempt-level: one event per provider attempt, including failed/rate-limited attempts — the retry/breaker behavior is exactly what needs visibility).
  • Prompt/response content is never captured. Metadata only (the existing PAYLOAD_KEY scrub treats prompts as payload — same rule here; $ai_generation's optional content fields stay empty by policy).
  • Dashboard: spend/latency/failure by provider+model+effort, wired into the insights sub-issue's home.
  • Tests: capture fires per attempt with metadata-only properties; unconfigured no-op.

Boundaries

  • Miner-side AMS AI calls are out of scope for the first pass (different package, different client) — noted for a follow-up once the ORB pattern is proven.

Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:priorityMaintainer-selected Gittensor priority — scores a 1.5x multiplier.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions