Skip to content

Commit 3a24274

Browse files
committed
fix(providers): Sakana streaming usage + filtered-tools stream guard
- Pass stream_options: { include_usage: true } on both streaming calls so token/cost data is captured (the shared OpenAI-compatible stream helper only fills usage from chunk usage, which the API omits without the flag). - Include !hasActiveTools in the early-stream guard so requests whose tools are all filtered out (e.g. usageControl 'none') still take the fast streaming path instead of the tool-loop path. Mirrors LiteLLM.
1 parent 8d4acba commit 3a24274

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

apps/sim/providers/sakana/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ export const sakanaProvider: ProviderConfig = {
130130
payload.response_format = responseFormatPayload
131131
}
132132

133-
if (request.stream && (!tools || tools.length === 0)) {
133+
if (request.stream && (!tools || tools.length === 0 || !hasActiveTools)) {
134134
logger.info('Using streaming response for Sakana request (no tools)')
135135

136136
const streamResponse = await sakana.chat.completions.create(
137137
{
138138
...payload,
139139
stream: true,
140+
stream_options: { include_usage: true },
140141
},
141142
request.abortSignal ? { signal: request.abortSignal } : undefined
142143
)
@@ -452,6 +453,7 @@ export const sakanaProvider: ProviderConfig = {
452453
messages: currentMessages,
453454
tool_choice: 'none',
454455
stream: true,
456+
stream_options: { include_usage: true },
455457
}
456458
if (deferResponseFormat && responseFormatPayload) {
457459
streamingPayload.response_format = responseFormatPayload

0 commit comments

Comments
 (0)