Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(trajectory): restore ask-user resume facts

alan_cheng5edd1d389a0b
diff --git a/jiuwenswarm/channels/web/frontend/src/features/trajectory/client/TrajectoryTable.tsx b/jiuwenswarm/channels/web/frontend/src/features/trajectory/client/TrajectoryTable.tsx
index 30c31f1dfa..9deda5ef15 100644
--- a/jiuwenswarm/channels/web/frontend/src/features/trajectory/client/TrajectoryTable.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/features/trajectory/client/TrajectoryTable.tsx
@@ -324,11 +324,13 @@ function totalTime(metrics: AssistantMetricDetail): string {
function ttft(metrics: AssistantMetricDetail): string {
if (!metrics.timingRecorded) return 'Not recorded'
if (metrics.stepStartTime === null) return 'Step start unavailable'
+ if (metrics.streaming === false) return 'Not applicable (non-stream)'
if (metrics.firstTokenTime === null) return 'First token unavailable'
return formatDurationMs(Math.max(0, metrics.firstTokenTime - metrics.stepStartTime))
}
function generationTime(metrics: AssistantMetricDetail): string {
+ if (metrics.streaming === false) return 'Not separately recorded'
if (!metrics.timingRecorded || metrics.firstTokenTime === null) return 'First token unavailable'
if (metrics.completedTime === null) return 'Pending'
return formatDurationMs(Math.max(0, metrics.completedTime - metrics.firstTokenTime))
@@ -337,6 +339,7 @@ function generationTime(metrics: AssistantMetricDetail): string {
function throughput(metrics: AssistantMetricDetail): string {
if (!metrics.usageProvided) return 'Usage unavailable'
if (metrics.outputTokens === null) return 'Output tokens unavailable'
+ if (metrics.streaming === false) return 'Not separately recorded'
if (!metrics.timingRecorded || metrics.firstTokenTime === null) return 'First token unavailable'
if (metrics.completedTime === null) return 'Pending'
const generationSeconds = (metrics.completedTime - metrics.firstTokenTime) / 1_000
diff --git a/jiuwenswarm/channels/web/frontend/src/features/trajectory/projector/otel-trajectory-projector.ts b/jiuwenswarm/channels/web/frontend/src/features/trajectory/projector/otel-trajectory-projector.ts
index e8a6d4500c..60df8b3c80 100644
--- a/jiuwenswarm/channels/web/frontend/src/features/trajectory/projector/otel-trajectory-projector.ts
+++ b/jiuwenswarm/channels/web/frontend/src/features/trajectory/projector/otel-trajectory-projector.ts
@@ -651,7 +651,6 @@ function isRoutedAskUserResult(
&& conversationId !== undefined
&& subjectId !== undefined
&& attributes.requestId !== undefined
- && positiveSafeInteger(attributes.turnNumber) !== undefined
&& (mainSubject || subagentSubject)
&& sameRootOwner
}
@@ -763,6 +762,7 @@ function assistantCell(span: ProjectedSpan): TrajectoryCell {
outputBlocks: blocks.filter(block => block.type === 'text' || block.type === 'reasoning'),
assistantMetrics: {
timingRecorded: true,
+ streaming: span.attributes.requestStream ?? null,
stepStartTime: start,
firstTokenTime: firstChunkSeconds === undefined ? null : start + firstChunkSeconds * 1_000,
completedTime: span.endTimeUnixNano === undefined
diff --git a/jiuwenswarm/channels/web/frontend/src/features/trajectory/trajectory/record.ts b/jiuwenswarm/channels/web/frontend/src/features/trajectory/trajectory/record.ts
index c3d00cd2f8..b3ea2b1d87 100644
--- a/jiuwenswarm/channels/web/frontend/src/features/trajectory/trajectory/record.ts
+++ b/jiuwenswarm/channels/web/frontend/src/features/trajectory/trajectory/record.ts
@@ -22,6 +22,8 @@ export type TrajectoryCellKind =
/** Recorded inputs needed to derive assistant TTFT and decode throughput. */
export interface AssistantMetricDetail {
timingRecorded: boolean
+ /** Whether the provider response exposed token-level streaming timing. */
+ streaming?: boolean | null
stepStartTime: number | null
firstTokenTime: number | null
completedTime: number | null
diff --git a/jiuwenswarm/channels/web/frontend/tests/trajectoryProjector.test.mjs b/jiuwenswarm/channels/web/frontend/tests/trajectoryProjector.test.mjs
index 1c7e280b22..400b10db4e 100644
--- a/jiuwenswarm/channels/web/frontend/tests/trajectoryProjector.test.mjs
+++ b/jiuwenswarm/channels/web/frontend/tests/trajectoryProjector.test.mjs
@@ -258,7 +258,7 @@ test('ownerless ask_user result remains one routed TOOL while other ownerless to
setStringAttribute(askUser, 'openjiuwen.request.id', 'resume-request');
const turn = askUser.attributes.find(attribute => attribute.key === 'openjiuwen.turn.number');
assert.ok(turn);
- turn.value = { intValue: '2' };
+ askUser.attributes = askUser.attributes.filter(attribute => attribute !== turn);
setStringAttribute(routedRoot, 'session.id', 'session-ask-user');
setStringAttribute(routedRoot, 'gen_ai.conversation.id', 'session-ask-user');
setStringAttribute(routedRoot, 'openjiuwen.execution.subject.id', 'main');