Repository navigation
Conversation
…interpreter errors out of span status An InvokeAgent completion stream that the caller does not iterate left its AGENT span open. A FinalizationRegistry, matching the model stream path, ends it best-effort on GC as UNSET with fi.stream.consumed=false. The holdings carry only span state, and finalize disarms the registration. Code-interpreter execution errors set status ERROR with error.type=CodeInterpreterExecutionError and no status message; the error text stays in output.value, where the hide settings apply.
Move failureTrace failureReason text into output.value on agent_failure spans so hideOutputs applies, leaving span status as ERROR without a message and keeping failureCode in error.type.
…C, and update changelog Format finite numeric failureCode values in error.type on agent_failure spans, close open step spans before ending the AGENT span on GC (adding fi.stream.partial=true when events were read), add stream error and real-GC tests, and update CHANGELOG.md.
This branch has not been deployed
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.
What does this PR do?
@traceai/bedrock,observeAgentCompletionregisters aFinalizationRegistrytoken whose holdings carry only{ span, ended, read, steps }(no reference to the stream, wrapper, iterator, trace builder, or callbacks) and disarms the registration insidefinalize. AnInvokeAgent/InvokeInlineAgentcompletion stream dropped before it ends, withoutreturn(), ends any open step spans first, then ends theAGENTspan best-effort on GC with statusUNSETandfi.stream.consumed=false, plusfi.stream.partial=truewhen some events were read; no timer runs and nothing is read ahead.codeInterpreterInvocationOutput.executionError) and agent failures (failureTrace.failureReason) place their text inoutput.value(wherehideOutputsapplies), setting span status toERRORwith no status message and setting a stableerror.type(CodeInterpreterExecutionError, or the numeric/stringfailureCode, falling back toAgentFailure).typescript/packages/traceai_bedrock/CHANGELOG.mdwith an[Unreleased]entry covering both changes.Why?
An
InvokeAgentcompletion stream returned to a caller that did not finish iterating it left itsAGENTspan (and any open step spans) open indefinitely. In addition, placingexecutionErrorandfailureReasondirectly in spanstatus.messagebypassedhideOutputsmasking, and numericfailureCodevalues from the AWS SDK fell back toAgentFailure.How was it tested?
New
src/__tests__/agent-stream-finalization.test.ts: verifiesFinalizationRegistryregistration with minimal{ ended, read, span, steps }holdings, GC finalization closing open step spans before ending the root span asUNSET(fi.stream.consumed=false, plusfi.stream.partial=truewhen partly iterated) without timers, unregistration when consumed/closed/errored, and a real--expose-gccollection check.Updated
src/__tests__/agent-runtime.test.ts: verifies code-interpreterexecutionError,failureTracefailureReason+ numeric/stringfailureCode, and agent stream errors under visible outputs andhideOutputs: true.Full
@traceai/bedrockbuild and Jest test suite: 12/12 suites, 111/111 tests pass with 0 new failures.Unit tests added / updated (
jest)Integration tests pass (or N/A — no gateway behavior changed)
Build / typecheck pass
Package
CHANGELOG.mdupdatedChecklist
docs/VOCABULARY.mdNotes for reviewers
Targets
dev.