* Extract model information from tool call state
( history: ChatHistoryItemWithMessageId[], config: BrowserSerializedContinueConfig, toolCallState: ToolCallState, )
| 10 | * Extract model information from tool call state |
| 11 | */ |
| 12 | function extractModelInfo( |
| 13 | history: ChatHistoryItemWithMessageId[], |
| 14 | config: BrowserSerializedContinueConfig, |
| 15 | toolCallState: ToolCallState, |
| 16 | ): { |
| 17 | modelProvider: string; |
| 18 | modelName: string; |
| 19 | modelTitle: string; |
| 20 | } { |
| 21 | // Find the assistant message that contains this tool call |
| 22 | const assistantMessage = history.find( |
| 23 | (item) => |
| 24 | item.message.role === "assistant" && |
| 25 | item.message.toolCalls?.some((tc) => tc.id === toolCallState.toolCallId), |
| 26 | ); |
| 27 | |
| 28 | if ( |
| 29 | assistantMessage?.message.role === "assistant" && |
| 30 | "model" in assistantMessage.message && |
| 31 | assistantMessage.message.model |
| 32 | ) { |
| 33 | // Extract provider from model string (e.g., "anthropic::claude-3-5-sonnet" -> "anthropic") |
| 34 | const modelParts = String(assistantMessage.message.model).split("::"); |
| 35 | return { |
| 36 | modelProvider: modelParts[0] || "unknown", |
| 37 | modelName: modelParts[1] || String(assistantMessage.message.model), |
| 38 | modelTitle: modelParts[1] || String(assistantMessage.message.model), |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | // Fallback to config if not found in message |
| 43 | const chatModel = config?.selectedModelByRole?.chat; |
| 44 | |
| 45 | return { |
| 46 | modelProvider: chatModel?.provider || "unknown", |
| 47 | modelName: chatModel?.model || "unknown", |
| 48 | modelTitle: chatModel?.model || "unknown", |
| 49 | }; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Extract prompt and completion from tool call state |
no outgoing calls
no test coverage detected