Skip to content

Commit 23e1a15

Browse files
waleedlatif1claude
andcommitted
fix(traces): prevent condition blocks from rendering source agent's timeSegments
Condition blocks spread their source block's entire output into their own output. When the source is an agent, this leaked providerTiming/timeSegments into the condition's output, causing buildTraceSpans to create "Initial response" as a child of the condition span instead of the agent span. Two fixes: - Skip timeSegment child creation for condition block types in buildTraceSpans - Filter execution metadata (providerTiming, tokens, toolCalls, model, cost) from condition handler's filterSourceOutput Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 68d207d commit 23e1a15

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

apps/sim/executor/handlers/condition/condition-handler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export class ConditionBlockHandler implements BlockHandler {
166166
if (!output || typeof output !== 'object') {
167167
return output
168168
}
169-
const { _pauseMetadata, error, ...rest } = output
169+
const { _pauseMetadata, error, providerTiming, tokens, toolCalls, model, cost, ...rest } =
170+
output
170171
return rest
171172
}
172173

apps/sim/lib/logs/execution/trace-spans/trace-spans.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { createLogger } from '@sim/logger'
22
import type { ToolCall, TraceSpan } from '@/lib/logs/types'
3-
import { isWorkflowBlockType, stripCustomToolPrefix } from '@/executor/constants'
3+
import {
4+
isConditionBlockType,
5+
isWorkflowBlockType,
6+
stripCustomToolPrefix,
7+
} from '@/executor/constants'
48
import type { ExecutionResult } from '@/executor/types'
59
import { stripCloneSuffixes } from '@/executor/utils/subflow-utils'
610

@@ -230,6 +234,7 @@ export function buildTraceSpans(result: ExecutionResult): {
230234

231235
if (
232236
!isWorkflowBlockType(log.blockType) &&
237+
!isConditionBlockType(log.blockType) &&
233238
log.output?.providerTiming?.timeSegments &&
234239
Array.isArray(log.output.providerTiming.timeSegments)
235240
) {

0 commit comments

Comments
 (0)