Repository navigation
fix(py): Dev UI traces show why generate failed, where it started, and interrupted tools - #63
Merged
Merged
Conversation
huangjeff5
force-pushed
the
fix/py-trace-failed-interrupted-spans
branch
2 times, most recently
from
November 10, 2026 07:32
04080dd to
3be2f3d
Compare
huangjeff5
changed the base branch from
main
to
fix/py-trace-generate-per-turn-spans
November 10, 2026 07:32
huangjeff5
force-pushed
the
fix/py-trace-failed-interrupted-spans
branch
from
November 10, 2026 19:17
3be2f3d to
9e94739
Compare
huangjeff5
force-pushed
the
fix/py-trace-failed-interrupted-spans
branch
from
November 10, 2026 19:41
9e94739 to
f84f188
Compare
Base automatically changed from
fix/py-trace-generate-per-turn-spans
to
main
November 10, 2026 19:49
huangjeff5
force-pushed
the
fix/py-trace-failed-interrupted-spans
branch
3 times, most recently
from
November 10, 2026 23:07
9a6c934 to
76b308b
Compare
huangjeff5
force-pushed
the
fix/py-trace-failed-interrupted-spans
branch
from
November 11, 2026 17:57
a6c87b3 to
9dd726c
Compare
apascal07
reviewed
Nov 11, 2026
apascal07
approved these changes
Nov 11, 2026
mark_failure_source now walks __cause__ only (raise ... from e, GenkitError(cause=e)). A new error raised inside except without from claims the parent span, same as JS cause and Go %w.
…nterrupted-spans # Conflicts: # packages/genkit/src/genkit/_ai/_agents/_runtime.py
This was referenced Nov 15, 2026
Merged
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.
When a tool, model, or loop cap fails inside
ai.generate(), the failedgenerate(and enclosing prompt) span in the Dev UI now shows the failure text instead of a blank red row, marks only the span where the failure started, and renders interrupted tools as interrupted instead of green successes.Changes
generateand prompt spans carry the root-cause message: Previously, agenerateor named prompt call returningfinish_reason='failed'marked its spanerrorwith no text, leaving the trace row red and blank. Genkit now writes the unredacted message (e.g.'allergen service offline') to the span's status.response.error.messagestays'internal error': traces are for the developer debugging the run,response.erroris for the caller.genkit:isFailureSource: Previously, the Dev UI poster never setgenkit:isFailureSourceorgenkit:isRoot, so the Traces tab could not point at where an error started. The first failing span now claimsgenkit:isFailureSource = true: the raisingmodel/toolspan (followed through__cause__), or the innermostgenerateturn whenmax_turnsor tool lookup fails with no child span. Enclosing spans turn red without re-claiming it.from/cause=to, one a child already claimed. Implicit__context__(a new error raised insideexceptwithoutfrom) no longer counts, matching JScauseand Go%w.Interruptclosed its span assuccess, and a bareInterrupt()wrote nogenkit:metadata:interruptat all. The tool span now recordsgenkit:state = 'error'(status.code = 2, no message) plusgenkit:metadata:interrupt(truewhen bare, else the metadata JSON). The Dev UI renders that as "Interrupted"; parentgenerateand flow spans stay green.API changes
genkit.telemetry.SpanContext.set_stateaccepts*, message: str | None = None: Genkit now callsspan.set_state(state, message=...)so failedgenerateand prompt spans forward the failure text (DirectSpanContextwritesgenkit:errorandstatus.message;GenAiSpanContextsetsStatusCode.ERRORwith the description). TodaySpanContextis only implemented by core andgenkit-otel(both updated here); any future customSpanContextimplementation must accept themessagekeyword argument.Breaking changes
None.
Cross-SDK
Python now writes the existing Dev UI trace attributes shared with JS and Go:
genkit:isRoot,genkit:isFailureSource, andgenkit:metadata:interrupt. One difference: on a bareInterrupt(), JS omitsgenkit:metadata:interruptand the Dev UI keys off aToolInterruptErrorexception event. Python's poster does not emit exception events, so it writesgenkit:metadata:interrupt = "true"instead and the Dev UI still renders "Interrupted". No changes needed in JS, Go, Dart, orgenkit-tools.