feat(ai): admin view-transcript UI for crew/agent runs (AI-045)#340
Merged
Conversation
Makes the multi-agent reasoning chain inspectable. Read-only over the
existing Phase 6 agent_run — no schema change, no new table.
- Backend: GET /admin/ai-quality/agent-runs (list, filter by agent,
newest-first, omits heavy StepsJson/Output, Goal truncated) +
/agent-runs/{id} (detail, raw StepsJson). Mirrors GetTraces/GetTrace;
StepsJson passed through raw, parsed client-side.
- Frontend: Transcripts tab on AiQualityPage (list+modal, modeled on
TracesTab/TraceModal). Parses the step tree; critic step special-cased
(score chips + severity-colored issues), default-expanded. Defensive —
malformed/non-JSON steps fall back to raw, never throw.
- Casing contract is load-bearing (mismatch = blank transcript):
DbAgentRunWriter uses default STJ → mixed Pascal/camel. Frontend reads
each key exactly; CrewTranscriptJsonContractTests locks it with
negative asserts that fail if anyone adds web/camelCase options.
407 unit + admin tsc/build green. Per-description deep-link = fast-follow.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI-045 — Admin "view transcript" UI (Phase 7)
Makes the multi-agent reasoning chain inspectable. Every crew run (
crew.autopublish/crew.seo) and single-agent run (studybuddy) already persists anagent_runrow with a nested-step transcript (researcher→drafter→critic→editor); this surfaces it in the admin app. No schema change, no new table — read-only over the existing Phase 6agent_run.Backend (2 read endpoints, mirror
GetTraces/GetTrace)GET /admin/ai-quality/agent-runs?agent=&limit=&offset=— list, newest-first,agentfilter = exact-or-prefix (crew.narrows to all crew runs), clamp 1–100. List projection omits the heavyStepsJson+Outputand truncatesGoalto 120 chars (guarded).GET /admin/ai-quality/agent-runs/{id}— detail with full rawStepsJson+Output, 404 on unknown.StepsJsonpassed through raw, parsed client-side (same pattern asTraceDetailDto) — no brittle second server-side schema.Frontend (new
Transcriptstab on AiQualityPage)Modeled on
TracesTab/TraceModal: filterable list (All /crew.autopublish/crew.seo/studybuddy) + pager → click row → modal. The modal parsesstepsJsoninto the step tree — eachsub_agentis a collapsible{stage} · {agentName}panel with per-step usage; the critic is special-cased + default-expanded, rendering its JSON verdict as score chips (factual_accuracy/tone/length/banned_phrases) + a severity-colored issue list (blocker red / major amber / minor gray). Defensive throughout — malformed/empty/non-JSON steps fall back to raw, never throw.The casing contract is load-bearing (a mismatch = blank transcript)
DbAgentRunWriterserializesrun.Stepswith default STJ options (a directJsonSerializer.Serialize, unaffected by the HTTP pipeline's web-defaults), so the stored shape is mixed: top-levelAgentSteprecords → PascalCase (Index/Kind/Payload/At), thesub_agentpayload anon-object → camelCase (stage/agentName/status/usage/steps), the nestedAgentUsagerecord → PascalCase, innerllm_responsepayloadnew { text }→ camelCase. The frontend reads each exactly.CrewTranscriptJsonContractTests(pure, no DB) serializes a real 4-stagecrew.autopublishrun through the same factory+options and asserts every key the UI depends on, with negative asserts so it fails loudly if anyone ever puts camelCase/web options on the writer. (QA-added; adversarial review confirmed the contract correct end-to-end, 0 P1/P2.)Tests
CrewTranscriptJsonContractTests(5, pure) — the write↔read casing contract.AdminAgentRunsEndpointTests(integration, live-server — same fixture as the rest of the suite, run by CI's docker job).dotnet test tests/TextStack.UnitTests→ 407 pass; StudyBuddy set-equality green.dotnet format --verify-no-changes→ clean.pnpm -C apps/admin exec tsc --noEmit+build→ clean.Notes
Per-description deep-link from the AutoPublish/SEO pages (by the runIds their
crew-generateendpoints already return) is a deliberate fast-follow; this PR is the self-contained AI-quality tab. Admin-only (/admin/*auth) —Goalcan carry user passages / book source, acceptable for the owner's audit surface. UI is build-verified; browser-check needs an admin session (owner-side).🤖 Generated with Claude Code