fix(trace): LLM_TTFT parent node pointing to wrong span + missing ERROR/CANCELLED status colors#40
Open
Dasooul03 wants to merge 1 commit into
Conversation
…OR/CANCELLED status colors - Add detach() to StreamCancellationHandle interface for span lifecycle control - Defer span detach in AbstractOpenAIStyleChatClient from finally block to returned handle - Call handle.detach() after awaitFirstPacket in RoutingLLMService, ensuring llm-first-packet (LLM_TTFT) node correctly nests under the provider stream node - Use try-finally per candidate to guarantee detach on both success and failover paths - Frontend: add error/cancelled mappings to STATUS_COLORS, statusLabel, and statusBadgeVariant - Add fallback ?? STATUS_COLORS.default in getStatusColors to prevent crash on unmapped statuses Co-Authored-By: Claude Opus 4.6 <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
llm-first-packet(LLM_TTFT) node having wrongparentNodeIdpointing tollm-stream-routinginstead of the specific provider stream nodeERROR/CANCELLEDstatusesProblem
Backend: LLM_TTFT parent node wrong
AbstractOpenAIStyleChatClient.doStreamChat()detached the span in afinallyblock, butRoutingLLMService.awaitFirstPacket()(annotated with@RagTraceNode("llm-first-packet")) executed after detach, causing the TTFT node to incorrectly point tollm-stream-routingas parent.Expected trace tree:
Actual trace tree (before fix):
Frontend: ERROR/CANCELLED statuses not mapped
STATUS_COLORSonly mappedsuccess/failed/running/default. In failover scenarios, provider nodes haveCANCELLEDorERRORstatus, causing the page to crash.Fix
Backend
StreamCancellationHandle: addeddefault void detach() {}for backward-compatible span lifecycle controlAbstractOpenAIStyleChatClient.doStreamChat(): no longer detaches infinally; instead returns a handle that carries the detach responsibilityRoutingLLMService.streamChat(): callshandle.detach()afterawaitFirstPacketcompletes, wrapped intry-finallyto guarantee detach on both success and failover pathsFrontend
STATUS_COLORS: addederror(red) andcancelled(gray) status mappingsgetStatusColors: added?? STATUS_COLORS.defaultfallback to prevent crashes on unmapped statusestraceUtils.ts: addederror/cancelledtostatusLabelandstatusBadgeVariantTest Plan
llm-first-packetparentNodeId points to the specific provider stream nodeCloses #35
🤖 Generated with Claude Code