@@ -87,16 +87,29 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
8787 model : id ,
8888 max_tokens : maxTokens ?? ANTHROPIC_DEFAULT_MAX_TOKENS ,
8989 temperature,
90- thinking,
9190 // Cache the system prompt if caching is enabled.
9291 system : supportsPromptCache
9392 ? [ { text : systemPrompt , type : "text" as const , cache_control : { type : "ephemeral" } } ]
9493 : systemPrompt ,
9594 messages : supportsPromptCache ? addCacheBreakpoints ( messages ) : messages ,
9695 stream : true ,
9796 }
97+ // Only set thinking if defined to avoid adding an explicit undefined property
98+ if ( thinking ) {
99+ ; ( params as any ) . thinking = thinking
100+ }
98101
99- const stream = await this . client . messages . create ( params )
102+ // Enable 1M context beta when using [1m] variants
103+ const use1m = this . options . apiModelId ?. endsWith ( "[1m]" ) === true
104+
105+ let stream
106+ if ( use1m ) {
107+ stream = await this . client . messages . create ( params , {
108+ headers : { "anthropic-beta" : "context-1m-2025-08-07" } ,
109+ } )
110+ } else {
111+ stream = await this . client . messages . create ( params )
112+ }
100113
101114 for await ( const chunk of stream ) {
102115 switch ( chunk . type ) {
@@ -171,8 +184,10 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
171184 // The `:thinking` suffix indicates that the model is a "Hybrid"
172185 // reasoning model and that reasoning is required to be enabled.
173186 // The actual model ID honored by Anthropic's API does not have this
174- // suffix.
175- return { id : id . endsWith ( ":thinking" ) ? id . replace ( ":thinking" , "" ) : id , info, ...params }
187+ // suffix. Additionally, strip the optional [1m] suffix used to
188+ // denote the 1M context beta variant in Roo's model list.
189+ const normalizedId = id . replace ( ":thinking" , "" ) . replace ( "[1m]" , "" )
190+ return { id : normalizedId , info, ...params }
176191 }
177192
178193 async completePrompt ( prompt : string ) {
@@ -189,7 +204,6 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
189204 model : id ,
190205 max_tokens : maxTokens ,
191206 temperature,
192- thinking,
193207 messages : [
194208 {
195209 role : "user" ,
@@ -200,8 +214,17 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
200214 ] ,
201215 stream : false ,
202216 }
217+ // Only set thinking if defined to avoid adding an explicit undefined property
218+ if ( thinking ) {
219+ ; ( params as any ) . thinking = thinking
220+ }
221+
222+ // Enable 1M context beta when using [1m] variants
223+ const use1m = this . options . apiModelId ?. endsWith ( "[1m]" ) === true
203224
204- const response = await this . client . messages . create ( params )
225+ const response = use1m
226+ ? await this . client . messages . create ( params , { headers : { "anthropic-beta" : "context-1m-2025-08-07" } } )
227+ : await this . client . messages . create ( params )
205228 const content = response . content [ 0 ]
206229
207230 if ( content . type === "text" ) {
0 commit comments