feat(util-genai): streaming Event Log → Trace conversion (TurnStreamSession)#58
Open
fangxiu-wf wants to merge 1 commit into
Open
feat(util-genai): streaming Event Log → Trace conversion (TurnStreamSession)#58fangxiu-wf wants to merge 1 commit into
fangxiu-wf wants to merge 1 commit into
Conversation
…ession) Add createTurnStreamSession/TurnStreamSession for incremental per-turn conversion: ENTRY/AGENT are opened on first push and kept open, each complete step converts and exports (then frees) its child spans as it finalizes, and ENTRY/AGENT close on end() with turn-level aggregates. Memory decouples from the number of steps in a turn (bounds the OOM risk on very long turns with thousands of ReAct steps). - graceSteps (default 2) look-back window tolerates bounded out-of-order emission; lateDroppedRecordCount + LATE_STEP_DROP warning make overflow observable; pendingRecordCount probe exposes buffered retention. - SPEC §2.5 documents the step-ordering expectation for streaming consumers (batch conversion remains order-independent). - Extract shared accumulateResponseUsage/usageFieldsFromAcc so batch buildInvokeAgentInvocation and the streaming session share one token aggregation; export parseInputMessages/parseOutputMessages. - Batch convertEventLogToTrace/convertTurn unchanged; streaming is an independent API validated by per-span equivalence tests. - bump 0.1.0-beta.11 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fangxiu-wf
force-pushed
the
feat/streaming-turn-conversion
branch
from
July 21, 2026 08:59
f910a5c to
bfcc26d
Compare
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
createTurnStreamSession/TurnStreamSession: incremental per-turn conversion where ENTRY/AGENT stay open and each complete step converts + exports (then frees) its child spans as it finalizes, closed atend()with turn-level aggregates. Memory decouples from the number of steps in a turn, bounding the OOM risk on very long turns (thousands of ReAct steps).graceSteps(default 2) look-back window tolerates bounded out-of-order emission;lateDroppedRecordCount+LATE_STEP_DROPwarning make overflow observable;pendingRecordCountprobe exposes buffered retention.accumulateResponseUsage/usageFieldsFromAccso batchbuildInvokeAgentInvocationand the streaming session use one token aggregation; exportparseInputMessages/parseOutputMessages.convertEventLogToTrace/convertTurnunchanged — streaming is an independent API.0.1.0-beta.11.Test plan
npm run buildpassesnpm testgreen — 222 tests (221 passed + 1 skipped; the skipped heap test runs underNODE_OPTIONS=--expose-gc)turn-stream.test.ts: incremental export, subagent nesting across fragmented pushes, grace-window tolerance of distance-1 cross-batch interleaving, late-drop counting/warning, parent_span_id linkage, trace_id resolution, strict mode, and per-span equivalence vsconvertEventLogToTrace(structure / AGENT tokens / LLM input.messages / startTime / warnings)turn-stream.memory.test.ts:pendingRecordCountbounded and independent of turn size (N=1000 vs 5000); heap bounded under production config (BatchSpanProcessor + async)🤖 Generated with Claude Code