mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(cost): worker crash incremenental case (#3885)
This commit is contained in:
committed by
GitHub
parent
42fb434354
commit
2ede12aa0e
@@ -391,10 +391,12 @@ describe('LoggingSession completion retries', () => {
|
||||
|
||||
await session.onBlockComplete('block-2', 'Transform', 'function', {
|
||||
endedAt: '2025-01-01T00:00:01.000Z',
|
||||
output: { value: true },
|
||||
cost: { total: 1, input: 1, output: 0 },
|
||||
tokens: { input: 1, output: 0, total: 1 },
|
||||
model: 'test-model',
|
||||
output: {
|
||||
value: true,
|
||||
cost: { total: 1, input: 1, output: 0 },
|
||||
tokens: { input: 1, output: 0, total: 1 },
|
||||
model: 'test-model',
|
||||
},
|
||||
})
|
||||
|
||||
const completionPromise = session.safeComplete({ finalOutput: { ok: true } })
|
||||
|
||||
@@ -294,11 +294,16 @@ export class LoggingSession {
|
||||
})
|
||||
)
|
||||
|
||||
if (!output?.cost || typeof output.cost.total !== 'number' || output.cost.total <= 0) {
|
||||
const blockOutput = output?.output
|
||||
if (
|
||||
!blockOutput?.cost ||
|
||||
typeof blockOutput.cost.total !== 'number' ||
|
||||
blockOutput.cost.total <= 0
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const { cost, tokens, model } = output
|
||||
const { cost, tokens, model } = blockOutput
|
||||
|
||||
this.accumulatedCost.total += cost.total || 0
|
||||
this.accumulatedCost.input += cost.input || 0
|
||||
|
||||
Reference in New Issue
Block a user