Skip to content

Commit 2ede12a

Browse files
fix(cost): worker crash incremenental case (#3885)
1 parent 42fb434 commit 2ede12a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

apps/sim/lib/logs/execution/logging-session.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,12 @@ describe('LoggingSession completion retries', () => {
391391

392392
await session.onBlockComplete('block-2', 'Transform', 'function', {
393393
endedAt: '2025-01-01T00:00:01.000Z',
394-
output: { value: true },
395-
cost: { total: 1, input: 1, output: 0 },
396-
tokens: { input: 1, output: 0, total: 1 },
397-
model: 'test-model',
394+
output: {
395+
value: true,
396+
cost: { total: 1, input: 1, output: 0 },
397+
tokens: { input: 1, output: 0, total: 1 },
398+
model: 'test-model',
399+
},
398400
})
399401

400402
const completionPromise = session.safeComplete({ finalOutput: { ok: true } })

apps/sim/lib/logs/execution/logging-session.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,16 @@ export class LoggingSession {
294294
})
295295
)
296296

297-
if (!output?.cost || typeof output.cost.total !== 'number' || output.cost.total <= 0) {
297+
const blockOutput = output?.output
298+
if (
299+
!blockOutput?.cost ||
300+
typeof blockOutput.cost.total !== 'number' ||
301+
blockOutput.cost.total <= 0
302+
) {
298303
return
299304
}
300305

301-
const { cost, tokens, model } = output
306+
const { cost, tokens, model } = blockOutput
302307

303308
this.accumulatedCost.total += cost.total || 0
304309
this.accumulatedCost.input += cost.input || 0

0 commit comments

Comments
 (0)