@@ -56,10 +56,7 @@ describe("vision-sidecar custom-model override (#349/#344)", () => {
5656 // vision sidecar could run. The image augmentation must come from the REGISTRY-enriched clone,
5757 // so we deliberately do NOT set noVisionModels on the persisted provider — opencode-go's
5858 // registry entry classifies glm-5.2 as text-only, and enrichment must supply it.
59- const originalFetch = globalThis . fetch ;
60- globalThis . fetch = ( ( ) => { throw new Error ( "fetch should not be called" ) ; } ) as typeof fetch ;
61- try {
62- const models = await gatherRoutedModels ( {
59+ const models = await gatherRoutedModels ( {
6360 port : 10100 ,
6461 defaultProvider : "opencode-go" ,
6562 providers : {
@@ -74,20 +71,14 @@ describe("vision-sidecar custom-model override (#349/#344)", () => {
7471 customModels : [
7572 { id : "cm-1" , provider : "opencode-go" , modelId : "glm-5.2" , displayName : "GLM 5.2" , addedAt : "2026-01-01T00:00:00.000Z" } ,
7673 ] ,
77- } ) ;
78- const custom = models . find ( m => m . provider === "opencode-go" && m . id === "glm-5.2" ) ;
79- expect ( custom ) . toBeDefined ( ) ;
80- expect ( custom ?. inputModalities ) . toEqual ( [ "text" , "image" ] ) ;
81- } finally {
82- globalThis . fetch = originalFetch ;
83- }
74+ } ) ;
75+ const custom = models . find ( m => m . provider === "opencode-go" && m . id === "glm-5.2" ) ;
76+ expect ( custom ) . toBeDefined ( ) ;
77+ expect ( custom ?. inputModalities ) . toEqual ( [ "text" , "image" ] ) ;
8478 } ) ;
8579
8680 test ( "a custom row NOT in noVisionModels keeps its declared modalities untouched" , async ( ) => {
87- const originalFetch = globalThis . fetch ;
88- globalThis . fetch = ( ( ) => { throw new Error ( "fetch should not be called" ) ; } ) as typeof fetch ;
89- try {
90- const models = await gatherRoutedModels ( {
81+ const models = await gatherRoutedModels ( {
9182 port : 10100 ,
9283 defaultProvider : "opencode-go" ,
9384 providers : {
@@ -103,22 +94,13 @@ describe("vision-sidecar custom-model override (#349/#344)", () => {
10394 customModels : [
10495 { id : "cm-2" , provider : "opencode-go" , modelId : "kimi-text" , inputModalities : [ "text" ] , addedAt : "2026-01-01T00:00:00.000Z" } ,
10596 ] ,
106- } ) ;
107- const custom = models . find ( m => m . provider === "opencode-go" && m . id === "kimi-text" ) ;
108- expect ( custom ?. inputModalities ) . toEqual ( [ "text" ] ) ;
109- } finally {
110- globalThis . fetch = originalFetch ;
111- }
97+ } ) ;
98+ const custom = models . find ( m => m . provider === "opencode-go" && m . id === "kimi-text" ) ;
99+ expect ( custom ?. inputModalities ) . toEqual ( [ "text" ] ) ;
112100 } ) ;
113101
114- test ( "the image augmentation does NOT overwrite a custom row's explicit context/modalities/reasoning" , async ( ) => {
115- // The augmentation must be narrow: for a noVisionModels custom row we only ADD image; every
116- // other explicitly configured custom field (contextWindow, extra modalities) stays verbatim,
117- // and no registry reasoning metadata leaks onto the user override.
118- const originalFetch = globalThis . fetch ;
119- globalThis . fetch = ( ( ) => { throw new Error ( "fetch should not be called" ) ; } ) as typeof fetch ;
120- try {
121- const models = await gatherRoutedModels ( {
102+ test ( "the image augmentation preserves explicit custom fields and canonical provider reasoning" , async ( ) => {
103+ const models = await gatherRoutedModels ( {
122104 port : 10100 ,
123105 defaultProvider : "opencode-go" ,
124106 providers : {
@@ -133,17 +115,14 @@ describe("vision-sidecar custom-model override (#349/#344)", () => {
133115 customModels : [
134116 { id : "cm-3" , provider : "opencode-go" , modelId : "glm-5.2" , contextWindow : 2_000_000 , inputModalities : [ "text" , "video" ] , addedAt : "2026-01-01T00:00:00.000Z" } ,
135117 ] ,
136- } ) ;
137- const custom = models . find ( m => m . provider === "opencode-go" && m . id === "glm-5.2" ) ;
138- // image is appended to the user's declared modalities (not replaced), context is preserved,
139- // and no registry reasoning fields were injected onto the custom override.
140- expect ( custom ?. inputModalities ) . toEqual ( [ "text" , "video" , "image" ] ) ;
141- expect ( custom ?. contextWindow ) . toBe ( 2_000_000 ) ;
142- expect ( custom ?. reasoningEfforts ) . toBeUndefined ( ) ;
143- expect ( custom ?. defaultReasoningEffort ) . toBeUndefined ( ) ;
144- } finally {
145- globalThis . fetch = originalFetch ;
146- }
118+ } ) ;
119+ const custom = models . find ( m => m . provider === "opencode-go" && m . id === "glm-5.2" ) ;
120+ // image is appended to the user's declared modalities (not replaced), custom context is
121+ // preserved, and the registry-enriched provider supplies its canonical reasoning metadata.
122+ expect ( custom ?. inputModalities ) . toEqual ( [ "text" , "video" , "image" ] ) ;
123+ expect ( custom ?. contextWindow ) . toBe ( 2_000_000 ) ;
124+ expect ( custom ?. reasoningEfforts ) . toEqual ( [ "low" , "medium" , "high" , "xhigh" , "max" ] ) ;
125+ expect ( custom ?. defaultReasoningEffort ) . toBeUndefined ( ) ;
147126 } ) ;
148127} ) ;
149128
0 commit comments