Skip to content

Commit 3c5f04a

Browse files
Lellansinclaude
andcommitted
fix: strip context size suffix from model name before API requests
The [70k]/[1m] suffix is only for local threshold calculation and must not be sent to the model provider as part of the model name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent eb2d403 commit 3c5f04a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/session.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ type ChatCompletionDebugOptions = {
7676

7777
const CONTEXT_SIZE_SUFFIX_RE = /\[(\d+(?:\.\d+)?)(k|m)\]$/i;
7878

79+
export function stripModelContextSizeSuffix(model: string): string {
80+
return model.replace(CONTEXT_SIZE_SUFFIX_RE, "").trimEnd();
81+
}
82+
7983
function parseContextSizeSuffix(model: string): number | undefined {
8084
const match = CONTEXT_SIZE_SUFFIX_RE.exec(model);
8185
if (!match) {
@@ -776,7 +780,7 @@ ${agentInstructions}
776780
const response = await this.createChatCompletionStream(
777781
client,
778782
{
779-
model,
783+
model: stripModelContextSizeSuffix(model),
780784
temperature: 0.1,
781785
messages: [
782786
{ role: "system", content: systemPrompt },
@@ -1371,7 +1375,7 @@ ${agentInstructions}
13711375
const response = await this.createChatCompletionStream(
13721376
client,
13731377
{
1374-
model,
1378+
model: stripModelContextSizeSuffix(model),
13751379
...(temperature !== undefined ? { temperature } : {}),
13761380
messages,
13771381
tools: getTools(this.getPromptToolOptions(), this.mcpToolDefinitions),
@@ -1546,7 +1550,7 @@ ${agentInstructions}
15461550
const response = await this.createChatCompletionStream(
15471551
client,
15481552
{
1549-
model,
1553+
model: stripModelContextSizeSuffix(model),
15501554
...(temperature !== undefined ? { temperature } : {}),
15511555
messages: [{ role: "user", content: compactPrompt }],
15521556
...thinkingOptions,

0 commit comments

Comments
 (0)