@@ -880,10 +880,6 @@ describe('/api/v1/chat/completions POST endpoint', () => {
880880 codebuffModel : openCodeZenModels . opencode_minimax_m2_7 ,
881881 upstreamModel : 'minimax-m2.7' ,
882882 } ,
883- {
884- codebuffModel : 'opencode/qwen3-coder' ,
885- upstreamModel : 'qwen3-coder' ,
886- } ,
887883 {
888884 codebuffModel : 'moonshotai/kimi-k2.6' ,
889885 upstreamModel : 'kimi-k2.6' ,
@@ -991,6 +987,59 @@ describe('/api/v1/chat/completions POST endpoint', () => {
991987 FETCH_PATH_TEST_TIMEOUT_MS ,
992988 )
993989
990+ it (
991+ 'rejects unsupported OpenCode Zen-prefixed models without calling the provider' ,
992+ async ( ) => {
993+ const fetchViaOpenCodeZen = mock (
994+ async ( url : string | URL | Request ) => {
995+ if ( String ( url ) . startsWith ( 'https://api.ipinfo.io/lookup/' ) ) {
996+ return Response . json ( { } )
997+ }
998+
999+ throw new Error ( 'OpenCode Zen provider should not be called' )
1000+ } ,
1001+ ) as unknown as typeof globalThis . fetch
1002+
1003+ const req = new NextRequest (
1004+ 'http://localhost:3000/api/v1/chat/completions' ,
1005+ {
1006+ method : 'POST' ,
1007+ headers : {
1008+ Authorization : 'Bearer test-api-key-123' ,
1009+ } ,
1010+ body : JSON . stringify ( {
1011+ model : 'opencode/qwen3-coder' ,
1012+ messages : [ { role : 'user' , content : 'hello' } ] ,
1013+ stream : false ,
1014+ codebuff_metadata : {
1015+ run_id : 'run-123' ,
1016+ client_id : 'test-client-id-123' ,
1017+ } ,
1018+ } ) ,
1019+ } ,
1020+ )
1021+
1022+ const response = await postChatCompletions ( {
1023+ req,
1024+ getUserInfoFromApiKey : mockGetUserInfoFromApiKey ,
1025+ logger : mockLogger ,
1026+ trackEvent : mockTrackEvent ,
1027+ getUserUsageData : mockGetUserUsageData ,
1028+ getAgentRunFromId : mockGetAgentRunFromId ,
1029+ fetch : fetchViaOpenCodeZen ,
1030+ insertMessageBigquery : mockInsertMessageBigquery ,
1031+ loggerWithContext : mockLoggerWithContext ,
1032+ } )
1033+
1034+ const body = await response . json ( )
1035+ expect ( response . status ) . toBe ( 400 )
1036+ expect ( body . error . code ) . toBe ( 'unsupported_model' )
1037+ expect ( body . error . message ) . toContain ( 'opencode/qwen3-coder' )
1038+ expect ( fetchViaOpenCodeZen ) . toHaveBeenCalledTimes ( 0 )
1039+ } ,
1040+ FETCH_PATH_TEST_TIMEOUT_MS ,
1041+ )
1042+
9941043 it ( 'rejects the DeepSeek V4 free agent when it requests another free model' , async ( ) => {
9951044 const req = new NextRequest (
9961045 'http://localhost:3000/api/v1/chat/completions' ,
0 commit comments