Skip to content

Commit c6272d9

Browse files
fix(executor): early-return when no streamed content to make onFullContent symmetric
Previously, executionOutput.content was guarded by `if (fullContent)` but `onFullContent` fired regardless. The agent-handler implementor defensively bails on empty/whitespace content, but that's a callee contract, not enforced at the call site — future implementors could spuriously persist empty assistant turns to memory. Hoist the `!fullContent` check to a single early return, so both the output write and the callback share the same precondition. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bf2f9af commit c6272d9

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

apps/sim/executor/execution/block-executor.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -686,32 +686,34 @@ export class BlockExecutor {
686686
}
687687

688688
const fullContent = accumulated.join('')
689-
if (fullContent) {
690-
const executionOutput = streamingExec.execution?.output
691-
if (executionOutput && typeof executionOutput === 'object') {
692-
let parsedForFormat = false
693-
if (responseFormat) {
694-
try {
695-
const parsed = JSON.parse(fullContent.trim())
696-
streamingExec.execution.output = {
697-
...parsed,
698-
tokens: executionOutput.tokens,
699-
toolCalls: executionOutput.toolCalls,
700-
providerTiming: executionOutput.providerTiming,
701-
cost: executionOutput.cost,
702-
model: executionOutput.model,
703-
}
704-
parsedForFormat = true
705-
} catch (error) {
706-
this.execLogger.warn('Failed to parse streamed content for response format', {
707-
blockId,
708-
error,
709-
})
689+
if (!fullContent) {
690+
return
691+
}
692+
693+
const executionOutput = streamingExec.execution?.output
694+
if (executionOutput && typeof executionOutput === 'object') {
695+
let parsedForFormat = false
696+
if (responseFormat) {
697+
try {
698+
const parsed = JSON.parse(fullContent.trim())
699+
streamingExec.execution.output = {
700+
...parsed,
701+
tokens: executionOutput.tokens,
702+
toolCalls: executionOutput.toolCalls,
703+
providerTiming: executionOutput.providerTiming,
704+
cost: executionOutput.cost,
705+
model: executionOutput.model,
710706
}
707+
parsedForFormat = true
708+
} catch (error) {
709+
this.execLogger.warn('Failed to parse streamed content for response format', {
710+
blockId,
711+
error,
712+
})
711713
}
712-
if (!parsedForFormat) {
713-
executionOutput.content = fullContent
714-
}
714+
}
715+
if (!parsedForFormat) {
716+
executionOutput.content = fullContent
715717
}
716718
}
717719

0 commit comments

Comments
 (0)