Skip to content

Commit 9fff8cb

Browse files
committed
remove for bedrock since they handle on their own
1 parent b0fbf36 commit 9fff8cb

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

.cursor/commands/council.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Based on the given area of interest, please:
2+
3+
1. Dig around the codebase in terms of that given area of interest, gather general information such as keywords and architecture overview.
4+
2. Spawn off n=10 (unless specified otherwise) task agents to dig deeper into the codebase in terms of that given area of interest, some of them should be out of the box for variance.
5+
3. Once the task agents are done, use the information to do what the user wants.
6+
7+
If user is in plan mode, use the information to create the plan.

apps/sim/providers/anthropic/index.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,18 @@ export const anthropicProvider: ProviderConfig = {
302302
const providerStartTime = Date.now()
303303
const providerStartTimeISO = new Date(providerStartTime).toISOString()
304304

305+
const nonStreamingMaxTokens =
306+
Number.parseInt(String(request.maxTokens)) ||
307+
getMaxOutputTokensForModel(request.model, false)
308+
const intermediatePayload = { ...payload, max_tokens: nonStreamingMaxTokens }
309+
305310
try {
306311
const initialCallTime = Date.now()
307-
const originalToolChoice = payload.tool_choice
312+
const originalToolChoice = intermediatePayload.tool_choice
308313
const forcedTools = preparedTools?.forcedTools || []
309314
let usedForcedTools: string[] = []
310315

311-
let currentResponse = await anthropic.messages.create(payload)
316+
let currentResponse = await anthropic.messages.create(intermediatePayload)
312317
const firstResponseTime = Date.now() - initialCallTime
313318

314319
let content = ''
@@ -491,7 +496,7 @@ export const anthropicProvider: ProviderConfig = {
491496
toolsTime += thisToolsTime
492497

493498
const nextPayload = {
494-
...payload,
499+
...intermediatePayload,
495500
messages: currentMessages,
496501
}
497502

@@ -674,13 +679,17 @@ export const anthropicProvider: ProviderConfig = {
674679
const providerStartTime = Date.now()
675680
const providerStartTimeISO = new Date(providerStartTime).toISOString()
676681

682+
const toolLoopMaxTokens =
683+
Number.parseInt(String(request.maxTokens)) || getMaxOutputTokensForModel(request.model, false)
684+
const toolLoopPayload = { ...payload, max_tokens: toolLoopMaxTokens }
685+
677686
try {
678687
const initialCallTime = Date.now()
679-
const originalToolChoice = payload.tool_choice
688+
const originalToolChoice = toolLoopPayload.tool_choice
680689
const forcedTools = preparedTools?.forcedTools || []
681690
let usedForcedTools: string[] = []
682691

683-
let currentResponse = await anthropic.messages.create(payload)
692+
let currentResponse = await anthropic.messages.create(toolLoopPayload)
684693
const firstResponseTime = Date.now() - initialCallTime
685694

686695
let content = ''
@@ -867,7 +876,7 @@ export const anthropicProvider: ProviderConfig = {
867876
toolsTime += thisToolsTime
868877

869878
const nextPayload = {
870-
...payload,
879+
...toolLoopPayload,
871880
messages: currentMessages,
872881
}
873882

apps/sim/providers/bedrock/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ export const bedrockProvider: ProviderConfig = {
268268
getMaxOutputTokensForModel(request.model, request.stream ?? false),
269269
}
270270

271+
const toolLoopInferenceConfig = {
272+
...inferenceConfig,
273+
maxTokens:
274+
Number.parseInt(String(request.maxTokens)) ||
275+
getMaxOutputTokensForModel(request.model, false),
276+
}
277+
271278
const shouldStreamToolCalls = request.streamToolCalls ?? false
272279

273280
if (request.stream && (!bedrockTools || bedrockTools.length === 0)) {
@@ -374,7 +381,7 @@ export const bedrockProvider: ProviderConfig = {
374381
modelId: bedrockModelId,
375382
messages,
376383
system: systemPromptWithSchema.length > 0 ? systemPromptWithSchema : undefined,
377-
inferenceConfig,
384+
inferenceConfig: toolLoopInferenceConfig,
378385
toolConfig,
379386
})
380387

@@ -620,7 +627,7 @@ export const bedrockProvider: ProviderConfig = {
620627
modelId: bedrockModelId,
621628
messages: currentMessages,
622629
system: systemPromptWithSchema.length > 0 ? systemPromptWithSchema : undefined,
623-
inferenceConfig,
630+
inferenceConfig: toolLoopInferenceConfig,
624631
toolConfig: bedrockTools?.length
625632
? { tools: bedrockTools, toolChoice: nextToolChoice }
626633
: undefined,
@@ -687,7 +694,7 @@ export const bedrockProvider: ProviderConfig = {
687694
modelId: bedrockModelId,
688695
messages: currentMessages,
689696
system: systemPromptWithSchema.length > 0 ? systemPromptWithSchema : undefined,
690-
inferenceConfig,
697+
inferenceConfig: toolLoopInferenceConfig,
691698
toolConfig: {
692699
tools: [structuredOutputTool],
693700
toolChoice: { tool: { name: structuredOutputToolName } },

0 commit comments

Comments
 (0)