Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions apps/sim/lib/logs/execution/logging-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } })
Expand Down
9 changes: 7 additions & 2 deletions apps/sim/lib/logs/execution/logging-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading