Show Lens plugin sessions like native Claude Code sessions #233
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.57) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #233"
general
weight: 0.35
cursor[bot]
Summary
A session recorded by a LiteLLM Lens plugin (Claude Code, Codex, OpenCode) grouped correctly into one trace, but Lens did not present it like a session recorded through Claude Code's own telemetry, which is the reference here. The trace list showed a dash for Last Output and a generic agent icon, the Steps view listed
invoke_agent <agent>rows where the reference showsTurn 1/2/3 [prompt]rows with per-turn cost, and selecting a turn showed no reply.Scope recognition.
normalize/instrumentation/claude_code.rsaccepts the plugin scopeberriai.lens.claude-codenext to the two native scopes, so plugin spans getframework = claude-code.normalize/instrumentation/opencode.rsacceptsberriai.lens.opencode, so those spans getframework = opencode. Codex plugin spans already resolve toopenai-codexthrough theircodex-cliservice name.Turn rows.
traces/turns.tstreated a parentless agent span as a turn only forclaude-code; it now also does foropenai-codexandopencode.Last Output. It came only from
claude_code.assistant_responsechild spans, which a plugin does not send; a plugin records the reply on the turn span itself. Migration0033widens theReplyPreviewdefault to also cover a parentless agent span, readingcontentfrom an output object or from the last message of an output array.resolve/view.rsfalls back to the latest parentless agent span with a reply preview when no reply span exists under a turn.Turn details.
TurnPane.tsxshowed the agent's reply only from aclaude_code.assistant_responsechild; it now falls back to the turn span's own output. A nativeclaude_code.interactionturn is left as it was, since that span never has output.Design decisions
1. The fix is in Lens. The plugins are not changed to imitate the native span names.
2. The Last Output fallback is not specific to one agent: any trace whose parentless agent span carries its reply as
{content}or[{role, content}, ...]gets Last Output.3. A recorded
claude_code.assistant_responsestill wins over a reply on the turn, in Last Output and in the turn details, so native sessions resolve as before.4. Turn rows key on the framework, with no plugin-only marker, so they apply to any Claude Code, Codex or OpenCode trace that has parentless agent spans.
5. The worker's own turn rule in
resolve/view.rsstays Claude Code only. It feeds the lookup of native reply spans; plugins get Last Output from the fallback.6. No OpenCode logo is added. Lens has no asset for it, so OpenCode traces keep the generic icon.
7. The new column default applies to spans written after the migration. Plugin traces already stored keep a dash for Last Output.
User-facing changes
Plugin-recorded Claude Code sessions show Last Output in the trace list, the Claude logo and
claude-codeframework, numbered turn rows with the prompt and per-turn cost, and the reply in the turn details. Because their spans are now Claude Code spans, the Claude Code specific status and tool-failure handling inresolve/applies to them as well.Codex and OpenCode plugin sessions show Last Output, numbered turn rows with cost, and the reply in the turn details. OpenCode plugin traces are labelled with the
opencodeframework.OpenCode 1.x telemetry traces also gain numbered turn rows, since they already carry one parentless
opencode.turnagent span per prompt. Native Codex telemetry traces gain them too, from their parentlesssession_task.turnspans. Other traces with a reply on a parentless agent span gain a Last Output value where they showed a dash.Testing
cargo test -p litellm-traces --test normalize --test normalization_formats --test resolvepasses, andvitest run src/components/lens/tracespasses. New cases: a real Claude Code plugin export as a fixture (claude_code_plugin_session.json) normalizing to Claude Code spans, OpenCode plugin turn, model-call and tool spans normalizing to OpenCode, the last reply taken from turns that carry their own reply in either row order while a subagent's reply is ignored, a recorded reply winning over a reply on the turn, turn rows for the two added frameworks, and the turn details showing a reply recorded on the turn.Real runs on a local Lens built from this branch behind a local LiteLLM gateway.
Claude Code 2.1.330: the same four prompts (a three-turn session resumed twice with a failed read and a subagent, plus a separate one-turn session) through the plugin and through native telemetry. Both gave two traces, 3 turns, 8 priced model calls, 5 tool steps and 1 error for the long session. The plugin traces show Last Output, the logo and
Turn 1/2/3rows with cost, matching the native ones.OpenCode 2.3.2 with its plugin: one
opencode runfollowed by two--continueruns gave one trace withTurn 1/2/3 [prompt]rows, per-turn cost, Last Output and the failed read marked as an error.The migration applied on the existing local ClickHouse.
Not tested here: a Codex plugin trace on this branch (checked separately by the Codex plugin work), and a multi-node ClickHouse. Native Codex telemetry was checked in the same separate work: a real two-turn Codex 0.171.0 session has two parentless agent spans, one per prompt, and shows
Turn 1andTurn 2with the right prompts. Two OpenCode differences from the reference remain and are on the plugin side: the Thread view repeats earlier messages before each model call, and a subagent arrives as its own trace.<details>
<summary>Details</summary>
Link to Devin session: https://app.devin.ai/sessions/e12c28ee068b4097a18cb8f738454dd0
Open in Devin Desktop: https://app.devin.ai/desktop/session/e12c28ee068b4097a18cb8f738454dd0?variant=devin
Requested by: @kerry-berri
</details>
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->