Skip to content

Commit 4d9964b

Browse files
committed
fix(litellm): merge only native tool defaults with router models
Only merges supportsNativeTools and defaultToolProtocol from litellmDefaultModelInfo, not prices or other model-specific info that could be incorrect for different models.
1 parent 0fb1c89 commit 4d9964b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ describe("useSelectedModel", () => {
616616
expect(result.current.info?.supportsNativeTools).toBe(true)
617617
})
618618

619-
it("should use model info from routerModels when model exists", () => {
619+
it("should merge only native tool defaults with routerModels when model exists", () => {
620620
const customModelInfo: ModelInfo = {
621621
maxTokens: 16384,
622622
contextWindow: 128000,
@@ -650,9 +650,15 @@ describe("useSelectedModel", () => {
650650

651651
expect(result.current.provider).toBe("litellm")
652652
expect(result.current.id).toBe("custom-model")
653-
// Should use the model info from routerModels, not the fallback
654-
expect(result.current.info).toEqual(customModelInfo)
653+
// Should only merge native tool defaults, not prices or other model-specific info
654+
// Router model values override the defaults
655+
const nativeToolDefaults = {
656+
supportsNativeTools: litellmDefaultModelInfo.supportsNativeTools,
657+
defaultToolProtocol: litellmDefaultModelInfo.defaultToolProtocol,
658+
}
659+
expect(result.current.info).toEqual({ ...nativeToolDefaults, ...customModelInfo })
655660
expect(result.current.info?.supportsNativeTools).toBe(true)
661+
expect(result.current.info?.defaultToolProtocol).toBe("native")
656662
})
657663
})
658664
})

webview-ui/src/components/ui/hooks/useSelectedModel.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ function getSelectedModel({
166166
}
167167
case "litellm": {
168168
const id = getValidatedModelId(apiConfiguration.litellmModelId, routerModels.litellm, defaultModelId)
169-
const info = routerModels.litellm?.[id] ?? litellmDefaultModelInfo
169+
const routerInfo = routerModels.litellm?.[id]
170+
// Only merge native tool call defaults, not prices or other model-specific info
171+
const nativeToolDefaults = {
172+
supportsNativeTools: litellmDefaultModelInfo.supportsNativeTools,
173+
defaultToolProtocol: litellmDefaultModelInfo.defaultToolProtocol,
174+
}
175+
const info = routerInfo ? { ...nativeToolDefaults, ...routerInfo } : litellmDefaultModelInfo
170176
return { id, info }
171177
}
172178
case "xai": {

0 commit comments

Comments
 (0)