@@ -8,7 +8,7 @@ import ejs from "ejs";
88import type { ChatCompletionMessageParam , ChatCompletionContentPart } from "openai/resources/chat/completions" ;
99import { launchNotifyScript } from "./notify" ;
1010import { buildThinkingRequestOptions } from "./openai-thinking" ;
11- import { DEEPSEEK_V4_MODELS } from "./model-capabilities" ;
11+ import { DEEPSEEK_V4_MODELS , supportsMultimodal } from "./common /model-capabilities" ;
1212import { getCompactPrompt , getSystemPrompt , getTools , AGENT_DRIFT_GUARD_SKILL , type ToolDefinition } from "./prompt" ;
1313import { ToolExecutor , type CreateOpenAIClient } from "./tools/executor" ;
1414import { McpManager } from "./mcp/mcp-manager" ;
@@ -156,7 +156,7 @@ export type SkillInfo = {
156156type SessionManagerOptions = {
157157 projectRoot : string ;
158158 createOpenAIClient : CreateOpenAIClient ;
159- getResolvedSettings : ( ) => { webSearchTool ?: string ; mcpServers ?: Record < string , McpServerConfig > } ;
159+ getResolvedSettings : ( ) => { model : string ; webSearchTool ?: string ; mcpServers ?: Record < string , McpServerConfig > } ;
160160 renderMarkdown : ( text : string ) => string ;
161161 onAssistantMessage : ( message : SessionMessage , shouldConnect : boolean ) => void ;
162162 onSessionEntryUpdated ?: ( entry : SessionEntry ) => void ;
@@ -175,7 +175,11 @@ export type LlmStreamProgress = {
175175export class SessionManager {
176176 private readonly projectRoot : string ;
177177 private readonly createOpenAIClient : CreateOpenAIClient ;
178- private readonly getResolvedSettings : ( ) => { webSearchTool ?: string ; mcpServers ?: Record < string , McpServerConfig > } ;
178+ private readonly getResolvedSettings : ( ) => {
179+ model : string ;
180+ webSearchTool ?: string ;
181+ mcpServers ?: Record < string , McpServerConfig > ;
182+ } ;
179183 private readonly onAssistantMessage : ( message : SessionMessage , shouldConnect : boolean ) => void ;
180184 private readonly onSessionEntryUpdated ?: ( entry : SessionEntry ) => void ;
181185 private readonly onLlmStreamProgress ?: ( progress : LlmStreamProgress ) => void ;
@@ -1017,7 +1021,7 @@ ${skillMd}
10171021 await this . compactSession ( sessionId , sessionController . signal ) ;
10181022 }
10191023
1020- const messages = this . buildOpenAIMessages ( this . listSessionMessages ( sessionId ) , thinkingEnabled ) ;
1024+ const messages = this . buildOpenAIMessages ( this . listSessionMessages ( sessionId ) , thinkingEnabled , model ) ;
10211025 const thinkingOptions = buildThinkingRequestOptions ( thinkingEnabled , baseURL , reasoningEffort ) ;
10221026 const response = await this . createChatCompletionStream (
10231027 client ,
@@ -1208,8 +1212,9 @@ ${skillMd}
12081212 this . saveSessionMessages ( sessionId , sessionMessages ) ;
12091213 }
12101214
1211- private getPromptToolOptions ( ) : { webSearchEnabled : boolean } {
1215+ private getPromptToolOptions ( ) : { model : string ; webSearchEnabled : boolean } {
12121216 return {
1217+ model : this . getResolvedSettings ( ) . model ,
12131218 webSearchEnabled : true ,
12141219 } ;
12151220 }
@@ -1678,7 +1683,11 @@ ${skillMd}
16781683 return { waitingForUser } ;
16791684 }
16801685
1681- private buildOpenAIMessages ( messages : SessionMessage [ ] , thinkingEnabled : boolean ) : ChatCompletionMessageParam [ ] {
1686+ private buildOpenAIMessages (
1687+ messages : SessionMessage [ ] ,
1688+ thinkingEnabled : boolean ,
1689+ model : string
1690+ ) : ChatCompletionMessageParam [ ] {
16821691 const activeMessages = messages . filter ( ( message ) => ! message . compacted ) ;
16831692 const toolPairings = this . pairToolMessages ( activeMessages ) ;
16841693 const openAIMessages : ChatCompletionMessageParam [ ] = [ ] ;
@@ -1689,7 +1698,7 @@ ${skillMd}
16891698 continue ;
16901699 }
16911700
1692- openAIMessages . push ( this . sessionMessageToOpenAIMessage ( message , thinkingEnabled ) ) ;
1701+ openAIMessages . push ( this . sessionMessageToOpenAIMessage ( message , thinkingEnabled , model ) ) ;
16931702
16941703 const toolCalls = this . getAssistantToolCalls ( message ) ;
16951704 if ( toolCalls . length === 0 ) {
@@ -1704,7 +1713,9 @@ ${skillMd}
17041713
17051714 const pairedToolIndex = toolPairings . get ( this . buildToolPairingKey ( index , toolCallIndex ) ) ;
17061715 if ( pairedToolIndex != null ) {
1707- openAIMessages . push ( this . sessionMessageToOpenAIMessage ( activeMessages [ pairedToolIndex ] , thinkingEnabled ) ) ;
1716+ openAIMessages . push (
1717+ this . sessionMessageToOpenAIMessage ( activeMessages [ pairedToolIndex ] , thinkingEnabled , model )
1718+ ) ;
17081719 continue ;
17091720 }
17101721
@@ -1715,7 +1726,11 @@ ${skillMd}
17151726 return openAIMessages ;
17161727 }
17171728
1718- private sessionMessageToOpenAIMessage ( message : SessionMessage , thinkingEnabled : boolean ) : ChatCompletionMessageParam {
1729+ private sessionMessageToOpenAIMessage (
1730+ message : SessionMessage ,
1731+ thinkingEnabled : boolean ,
1732+ model : string
1733+ ) : ChatCompletionMessageParam {
17191734 const content = this . renderOpenAIMessageContent ( message ) ;
17201735 const base : ChatCompletionMessageParam = {
17211736 role : message . role ,
@@ -1748,7 +1763,7 @@ ${skillMd}
17481763 const params = Array . isArray ( message . contentParams ) ? message . contentParams : [ message . contentParams ] ;
17491764 for ( const param of params ) {
17501765 const part = param as ChatCompletionContentPart ;
1751- if ( part && part . type !== "image_url" ) {
1766+ if ( part && ( part . type !== "image_url" || supportsMultimodal ( model ) ) ) {
17521767 contentParts . push ( part ) ;
17531768 }
17541769 }
0 commit comments