@@ -15,20 +15,14 @@ import {
1515 attachLargeFileRemoteUrls ,
1616 uploadLargeFilesToProvider ,
1717} from '@/providers/file-attachments.server'
18- import {
19- getReasoningEffortValuesForModel ,
20- getThinkingLevelsForModel ,
21- getVerbosityValuesForModel ,
22- isKnownModelId ,
23- } from '@/providers/models'
18+ import { isKnownModelId } from '@/providers/models'
2419import { getProviderExecutor } from '@/providers/registry'
2520import {
2621 type ProviderRuntimeContext ,
2722 runWithProviderRuntimeContext ,
2823} from '@/providers/runtime-context'
2924import type { ProviderId , ProviderRequest , ProviderResponse } from '@/providers/types'
3025import {
31- describeModelLevel ,
3226 generateStructuredOutputInstructions ,
3327 sumToolCosts ,
3428 supportsPromptCaching ,
@@ -59,60 +53,6 @@ function normalizeModelLevel(value: string | undefined): string | undefined {
5953 return normalized || undefined
6054}
6155
62- const MODEL_LEVEL_SENTINELS = new Set ( [ 'auto' , 'none' ] )
63-
64- type ModelLevelField = 'reasoningEffort' | 'verbosity' | 'thinkingLevel'
65-
66- /**
67- * Clears a level whose resolved model does not accept the field at all.
68- *
69- * Dropping is the safe default — a provider that has no such parameter rejects the whole
70- * request — but the discard is reported because the model can be bound to a variable or block
71- * reference and is therefore only known at execution time. Without this, a run whose reference
72- * resolved to a model that does not take the field would quietly fall back to that model's
73- * default while the caller believed the level applied.
74- */
75- function dropUnsupportedLevel (
76- field : ModelLevelField ,
77- model : string ,
78- value : string | undefined
79- ) : undefined {
80- if ( value ) {
81- logger . warn ( 'Model does not support this level; dropping it from the request' , {
82- field,
83- model,
84- value : describeModelLevel ( value ) ,
85- } )
86- }
87- return undefined
88- }
89-
90- /**
91- * Logs a level that the model accepts as a field but does not list as a value.
92- *
93- * Deliberately does not drop the value. Sim's per-model level lists exist to populate the
94- * pickers and can lag a provider that has started accepting a new level, so rejecting on them
95- * would refuse values the API would have taken. Forwarding instead surfaces the provider's own
96- * error, which names the field and the values it accepts — the loud failure an eval sweeping
97- * levels needs, where silently substituting the model default would corrupt the results.
98- */
99- function warnOnUnrecognizedLevel (
100- field : ModelLevelField ,
101- model : string | undefined ,
102- value : string | undefined ,
103- declaredValues : string [ ] | null
104- ) : void {
105- if ( ! model || ! value || MODEL_LEVEL_SENTINELS . has ( value ) ) return
106- if ( ! declaredValues || declaredValues . includes ( value ) ) return
107-
108- logger . warn ( 'Model level is not one this model declares; forwarding to the provider' , {
109- field,
110- model,
111- value : describeModelLevel ( value ) ,
112- declaredValues,
113- } )
114- }
115-
11656function sanitizeRequest ( request : ProviderRequest ) : ProviderRequest {
11757 const sanitizedRequest = { ...request }
11858 const model = sanitizedRequest . model
@@ -126,61 +66,31 @@ function sanitizeRequest(request: ProviderRequest): ProviderRequest {
12666 }
12767
12868 /**
129- * A model absent from the catalogue is unknown, not known-incapable. Since the model can be
130- * bound to a reference, that is exactly how a newly released model arrives before Sim has
131- * catalogued it — so its levels are forwarded and the provider decides, rather than being
132- * discarded on the strength of a list that has not caught up. Models the catalogue does
133- * know, and every dynamic-provider id, keep the protective drop.
69+ * A model absent from the catalogue is unknown, not known-incapable. The model field is an
70+ * editable combobox, so a model newer than `models.ts` reaches this point routed by pattern
71+ * and executing normally — discarding its levels on the strength of a list that has not
72+ * caught up loses a setting the provider would have honoured. Those levels are forwarded and
73+ * the provider decides. Models the catalogue does know, and every dynamic-provider id, keep
74+ * the protective drop.
13475 */
13576 const isCatalogued = Boolean ( model ) && isKnownModelId ( model )
13677
13778 if ( model && isCatalogued && ! supportsReasoningEffort ( model ) ) {
138- sanitizedRequest . reasoningEffort = dropUnsupportedLevel (
139- 'reasoningEffort' ,
140- model ,
141- sanitizedRequest . reasoningEffort
142- )
79+ sanitizedRequest . reasoningEffort = undefined
14380 }
14481
14582 if ( model && isCatalogued && ! supportsVerbosity ( model ) ) {
146- sanitizedRequest . verbosity = dropUnsupportedLevel (
147- 'verbosity' ,
148- model ,
149- sanitizedRequest . verbosity
150- )
83+ sanitizedRequest . verbosity = undefined
15184 }
15285
15386 if ( model && isCatalogued && ! supportsThinking ( model ) ) {
154- sanitizedRequest . thinkingLevel = dropUnsupportedLevel (
155- 'thinkingLevel' ,
156- model ,
157- sanitizedRequest . thinkingLevel
158- )
87+ sanitizedRequest . thinkingLevel = undefined
15988 }
16089
16190 if ( model && ! supportsPromptCaching ( model ) ) {
16291 sanitizedRequest . promptCaching = undefined
16392 }
16493
165- warnOnUnrecognizedLevel (
166- 'reasoningEffort' ,
167- model ,
168- sanitizedRequest . reasoningEffort ,
169- model ? getReasoningEffortValuesForModel ( model ) : null
170- )
171- warnOnUnrecognizedLevel (
172- 'verbosity' ,
173- model ,
174- sanitizedRequest . verbosity ,
175- model ? getVerbosityValuesForModel ( model ) : null
176- )
177- warnOnUnrecognizedLevel (
178- 'thinkingLevel' ,
179- model ,
180- sanitizedRequest . thinkingLevel ,
181- model ? getThinkingLevelsForModel ( model ) : null
182- )
183-
18494 return sanitizedRequest
18595}
18696
0 commit comments