LAM-2006: read agent outputs from separate trace_outputs_v0 view#2120
Draft
dinmukhamedm wants to merge 8 commits into
Draft
LAM-2006: read agent outputs from separate trace_outputs_v0 view#2120dinmukhamedm wants to merge 8 commits into
dinmukhamedm wants to merge 8 commits into
Conversation
Drop agent_output from the default trace schema (traces_v0 / traces_agg_v0 and everything that read it there) — the dict-resolving join was too expensive inside the hot traces view. Outputs now live in the dedicated trace_outputs_v0 view over the trace_agent_output RMT (migration 54), returning the winning span's full output-message array (one raw message JSON per element). - query engine: register trace_outputs in the validator TableRegistry, dedupe the schema-prompt entry, add the frontend tableSchemas entry and MCP joins hint; drop agent_output from the traces column allowlist / schema / editor autocomplete - shared extraction (lib/traces/agent-output.ts): per message part keep non-empty thinking/reasoning, non-empty text, and tool calls as name(payload); unknown parts are stringified rather than dropped (pinned by tests/test-agent-output-extraction.test.ts) - getAgentOutputsBatch (lib/actions/traces/outputs.ts) reads the view via the query engine and falls back to the legacy last-LLM-span preview for traces without a trace_agent_output row; consumed by getTrace/getSharedTrace (trace view transcript Output row) and the batched POST /traces/output route driving session + debugger views - traces table: drop the Output column/filter (agent_output is no longer on the trace row) Co-Authored-By: Claude Fable 5 <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.
Summary
Ports the agent-IO work on this branch to the split read-path:
agent_outputis removed from the default trace schema (traces_v0/traces_agg_v0) — the dict-resolving output join was too expensive inside the hot traces view (why is a separate investigation) — and is now read from the dedicatedtrace_outputs_v0view, which returns the winning LLM span's entire output-message array (one raw message JSON per element, hashes resolved throughdeduped_content_dict).Changes
ClickHouse (migration 55)
traces_agg_v0without thetrace_agent_outputjoin and repointstraces_v0attraces_agg; both exposeagent_inputonly.trace_outputs_v0(created in migration 54) is project-parameterized only, not time-parameterized.Query engine / SQL surface
trace_outputsregistered as an allowlisted table (validator.rsTableRegistry,schema.rsprompt, frontendtableSchemas, MCP joins hinttrace_outputs.trace_id = traces.id);agent_outputremoved from thetracesallowlist and editor schema. Validator test added for the rewrite.Shared extraction (
frontend/lib/traces/agent-output.ts)extractAgentOutputpulls the valuable bits out of each output message: non-emptythinking/reasoning, non-emptytext(or GenAIcontent), and tool calls rendered asname(payload)(message-leveltool_calls, Anthropictool_use, AI SDKtool-call, OpenAI Responses items, etc.). Deliberately permissive — unknown parts are stringified rather than dropped, so it degrades to extracting more instead of nothing. Pinned bytests/test-agent-output-extraction.test.ts(16 cases).Read path
getAgentOutputsBatch(frontend/lib/actions/traces/outputs.ts) readstrace_outputsvia the query engine, extracts text with the shared helper, and falls back to the legacy last-main-agent-LLM-span preview for traces without atrace_agent_outputrow.getTrace/getSharedTraceresolveagentOutputin parallel with the trace row; the transcript renders it as a trailingOutputItemrow.POST /api/projects/:id/traces/outputroute (store-level batching/debounce/dedupe, keyagentOutputs).agent_outputno longer exists on the trace row).Testing
cargo test --bin app-server query_engine— 112 passed.pnpm testextraction suite — 16/16 passed;tsc --noEmitclean (two pre-existing unrelated test failures also fail ondev).trace_agent_outputrow from realdeduped_contenthashes, and verified in the browser that (1) the trace-view transcript shows the extracted Output row, (2) the session view's collapsed trace card populates output viaPOST /traces/output, (3)SELECT agent_output FROM tracesis now rejected whileSELECT ... FROM trace_outputsand thetraces ⋈ trace_outputsjoin work through the query engine. No console errors.🤖 Generated with Claude Code