@@ -1024,6 +1024,23 @@ export namespace Provider {
10241024 mergeProvider ( providerID , partial )
10251025 }
10261026
1027+ // Patterns to detect reasoning-capable Ollama models
1028+ const OLLAMA_REASONING_PATTERNS = [
1029+ / q w e n [ _ \- ] ? 3 / i, // qwen3, qwen-3, qwen_3
1030+ / p h i [ _ \- ] ? 4 / i, // phi4, phi-4
1031+ / g e m m a [ _ \- ] ? 3 / i, // gemma3, gemma-3
1032+ / l l a m a [ _ \- ] ? 3 / i, // llama3, llama-3
1033+ / r 1 $ / i, // deepseek-r1, etc.
1034+ / q w q / i, // QwQ
1035+ / d e e p s e e k / i, // DeepSeek family
1036+ / g p t - ? o s s / i, // GPT-OSS
1037+ ]
1038+
1039+ function isOllamaReasoningModel ( modelName : string , family ?: string , families ?: string [ ] ) : boolean {
1040+ const searchText = `${ modelName } ${ family ?? "" } ${ families ?. join ( " " ) ?? "" } `
1041+ return OLLAMA_REASONING_PATTERNS . some ( pattern => pattern . test ( searchText ) )
1042+ }
1043+
10271044 // Auto-detect Ollama if not already configured
10281045 const ollamaConfigured = providers [ "ollama" ] || configProviders . some ( ( [ id ] ) => id === "ollama" )
10291046 if ( ! ollamaConfigured ) {
@@ -1035,6 +1052,19 @@ export namespace Provider {
10351052 for ( const ollamaModel of ollama . models ) {
10361053 const { model, tag } = parseModelName ( ollamaModel . name )
10371054 const modelID = tag ? `${ model } :${ tag } ` : model
1055+
1056+ // Detect if this is a reasoning model based on patterns
1057+ const isReasoning = isOllamaReasoningModel (
1058+ model ,
1059+ ollamaModel . details ?. family ,
1060+ ollamaModel . details ?. families ,
1061+ )
1062+
1063+ // Check for config overrides - allow forcing reasoning on/off
1064+ const configModel = config . provider ?. ollama ?. models ?. [ modelID ]
1065+ const configForceReasoning = configModel ?. capabilities ?. reasoning // undefined = auto, true = force on, false = force off
1066+ const finalReasoning = configForceReasoning !== undefined ? configForceReasoning : isReasoning
1067+
10381068 ollamaModels [ modelID ] = {
10391069 id : modelID ,
10401070 providerID : ollamaProviderID ,
@@ -1048,18 +1078,25 @@ export namespace Provider {
10481078 status : "active" ,
10491079 capabilities : {
10501080 temperature : true ,
1051- reasoning : ollamaModel . details ?. family ?. includes ( "reasoning" ) ?? false ,
1081+ reasoning : finalReasoning ,
10521082 attachment : false ,
10531083 toolcall : true ,
10541084 input : { text : true , audio : false , image : false , video : false , pdf : false } ,
10551085 output : { text : true , audio : false , image : false , video : false , pdf : false } ,
1056- interleaved : false ,
1086+ interleaved : finalReasoning
1087+ ? configModel ?. capabilities ?. interleaved ?? { field : "reasoning_content" }
1088+ : false ,
10571089 } ,
10581090 cost : { input : 0 , output : 0 , cache : { read : 0 , write : 0 } } ,
1059- options : { } ,
1091+ options :
1092+ finalReasoning
1093+ ? { reasoningEffort : configModel ?. options ?. reasoningEffort ?? "medium" , ...configModel ?. options }
1094+ : { } ,
10601095 limit : {
1061- context : ollamaModel . details ?. parameter_size ? 128000 : 8192 ,
1062- output : 8192 ,
1096+ context :
1097+ configModel ?. limit ?. context ??
1098+ ( finalReasoning ? 200000 : ollamaModel . details ?. parameter_size ? 128000 : 8192 ) ,
1099+ output : configModel ?. limit ?. output ?? ( finalReasoning ? 32768 : 8192 ) ,
10631100 } ,
10641101 headers : { } ,
10651102 release_date : "" ,
0 commit comments