fix: live trace streaming, final-output capture, and root-span duration#2
Merged
Merged
Conversation
…ration - Defer the root span to the Stop hook so a running turn leaves no completed root in ClickHouse — the backend keeps the live SSE stream open instead of treating the trace as done on the first hook (no more manual refresh). The "Codex Turn" title is preserved during the live window via traceroot.span.path. - Capture the turn's final output from the agent_message event (Codex writes it before the terminal task_complete, which lands just after the Stop hook fires), so live runs no longer show empty output; task_complete still refines it. - Compute the root span end from the latest step/tool activity so aborted or live-snapshot turns span their children instead of rendering a 0ms bar. - Fix the README install steps (codex plugin add + features.hooks). Verified against prod and with unit tests (72 pass). Rebuilt dist bundle. Refs traceroot-ai/traceroot#1401 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/tracing/src/spans.ts">
<violation number="1" location="plugins/tracing/src/spans.ts:91">
P2: Root end time still ignores nested subagent spans. Parent trace roots can render too short whenever a child rollout outlives the parent turn's own steps/tools.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| // render as a 0ms bar. Cover the turn's own steps and tool calls (including | ||
| // wait_agent, which ends when a spawned subagent finishes) so the root always | ||
| // spans its children — and grows correctly across live hooks. | ||
| let rootEnd = turn.endTime; |
There was a problem hiding this comment.
P2: Root end time still ignores nested subagent spans. Parent trace roots can render too short whenever a child rollout outlives the parent turn's own steps/tools.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/tracing/src/spans.ts, line 91:
<comment>Root end time still ignores nested subagent spans. Parent trace roots can render too short whenever a child rollout outlives the parent turn's own steps/tools.</comment>
<file context>
@@ -71,14 +82,31 @@ export function planTurnSpans(sessionMeta: SessionMeta, turn: Turn, ctx: EmitCtx
+ // render as a 0ms bar. Cover the turn's own steps and tool calls (including
+ // wait_agent, which ends when a spawned subagent finishes) so the root always
+ // spans its children — and grows correctly across live hooks.
+ let rootEnd = turn.endTime;
+ for (const step of turn.steps) {
+ if (step.endTime > rootEnd) rootEnd = step.endTime;
</file context>
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.
One wave of fixes for the Codex tracing plugin, all surfaced during prod e2e testing.
What this fixes
agent_messageevent, which Codex writes before the terminaltask_complete(which lands just after the Stop hook fires). Live runs previously showed empty output;task_completestill refines it when present.codex plugin marketplace add+codex plugin add, andfeatures.hooks.Verification
pnpm typecheckclean, 72 unit tests pass,distbundle rebuilt (drift guard in sync).Screenshots
Notes
dist/index.mjsdirectly; merging updates it.Tracked by traceroot-ai/traceroot#1401
Summary by cubic
Fixes live trace streaming, final output capture, and root span duration in the Codex tracing plugin so traces update live without refresh and show accurate data. Improves reliability and correctness in production.
Stopto keep the SSE stream open; addedtraceroot.span.pathso the trace stays titled "Codex Turn" while live.agent_message;task_completestill refines when present.codex plugin marketplace add+codex plugin add, and enablingfeatures.hooks.Written for commit dc94e00. Summary will update on new commits.