mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
fix(core): pass through Copilot Responses settings (#52182)
This commit is contained in:
@@ -149,7 +149,6 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
||||
responseFormat,
|
||||
}: LanguageModelV3CallOptions) {
|
||||
const warnings: SharedV3Warning[] = []
|
||||
const modelConfig = getResponsesModelConfig(this.modelId)
|
||||
|
||||
if (topK != null) {
|
||||
warnings.push({ type: "unsupported", feature: "topK" })
|
||||
@@ -186,7 +185,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
||||
|
||||
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
||||
prompt,
|
||||
systemMessageMode: modelConfig.systemMessageMode,
|
||||
systemMessageMode: "system",
|
||||
fileIdPrefixes: this.config.fileIdPrefixes,
|
||||
store,
|
||||
})
|
||||
@@ -286,84 +285,18 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
||||
safety_identifier: openaiOptions?.safetyIdentifier,
|
||||
top_logprobs: topLogprobs,
|
||||
|
||||
// model-specific settings:
|
||||
...(modelConfig.isReasoningModel &&
|
||||
(openaiOptions?.reasoningEffort != null || openaiOptions?.reasoningSummary != null) && {
|
||||
reasoning: {
|
||||
...(openaiOptions?.reasoningEffort != null && {
|
||||
effort: openaiOptions.reasoningEffort,
|
||||
}),
|
||||
...(openaiOptions?.reasoningSummary != null && {
|
||||
summary: openaiOptions.reasoningSummary,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
...(modelConfig.requiredAutoTruncation && {
|
||||
truncation: "auto",
|
||||
...((openaiOptions?.reasoningEffort != null || openaiOptions?.reasoningSummary != null) && {
|
||||
reasoning: {
|
||||
...(openaiOptions?.reasoningEffort != null && {
|
||||
effort: openaiOptions.reasoningEffort,
|
||||
}),
|
||||
...(openaiOptions?.reasoningSummary != null && {
|
||||
summary: openaiOptions.reasoningSummary,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
||||
if (modelConfig.isReasoningModel) {
|
||||
// remove unsupported settings for reasoning models
|
||||
// see https://platform.openai.com/docs/guides/reasoning#limitations
|
||||
if (baseArgs.temperature != null) {
|
||||
baseArgs.temperature = undefined
|
||||
warnings.push({
|
||||
type: "unsupported",
|
||||
feature: "temperature",
|
||||
details: "temperature is not supported for reasoning models",
|
||||
})
|
||||
}
|
||||
|
||||
if (baseArgs.top_p != null) {
|
||||
baseArgs.top_p = undefined
|
||||
warnings.push({
|
||||
type: "unsupported",
|
||||
feature: "topP",
|
||||
details: "topP is not supported for reasoning models",
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (openaiOptions?.reasoningEffort != null) {
|
||||
warnings.push({
|
||||
type: "unsupported",
|
||||
feature: "reasoningEffort",
|
||||
details: "reasoningEffort is not supported for non-reasoning models",
|
||||
})
|
||||
}
|
||||
|
||||
if (openaiOptions?.reasoningSummary != null) {
|
||||
warnings.push({
|
||||
type: "unsupported",
|
||||
feature: "reasoningSummary",
|
||||
details: "reasoningSummary is not supported for non-reasoning models",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Validate flex processing support
|
||||
if (openaiOptions?.serviceTier === "flex" && !modelConfig.supportsFlexProcessing) {
|
||||
warnings.push({
|
||||
type: "unsupported",
|
||||
feature: "serviceTier",
|
||||
details: "flex processing is only available for o3, o4-mini, and gpt-5 models",
|
||||
})
|
||||
// Remove from args if not supported
|
||||
baseArgs.service_tier = undefined
|
||||
}
|
||||
|
||||
// Validate priority processing support
|
||||
if (openaiOptions?.serviceTier === "priority" && !modelConfig.supportsPriorityProcessing) {
|
||||
warnings.push({
|
||||
type: "unsupported",
|
||||
feature: "serviceTier",
|
||||
details:
|
||||
"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported",
|
||||
})
|
||||
// Remove from args if not supported
|
||||
baseArgs.service_tier = undefined
|
||||
}
|
||||
|
||||
return {
|
||||
getHostedToolName,
|
||||
args: {
|
||||
@@ -1658,69 +1591,6 @@ function isErrorChunk(chunk: z.infer<typeof openaiResponsesChunkSchema>): chunk
|
||||
return chunk.type === "error"
|
||||
}
|
||||
|
||||
type ResponsesModelConfig = {
|
||||
isReasoningModel: boolean
|
||||
systemMessageMode: "remove" | "system" | "developer"
|
||||
requiredAutoTruncation: boolean
|
||||
supportsFlexProcessing: boolean
|
||||
supportsPriorityProcessing: boolean
|
||||
}
|
||||
|
||||
function getResponsesModelConfig(modelId: string): ResponsesModelConfig {
|
||||
const supportsFlexProcessing =
|
||||
modelId.startsWith("o3") ||
|
||||
modelId.startsWith("o4-mini") ||
|
||||
(modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat"))
|
||||
const supportsPriorityProcessing =
|
||||
modelId.startsWith("gpt-4") ||
|
||||
modelId.startsWith("gpt-5-mini") ||
|
||||
(modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat")) ||
|
||||
modelId.startsWith("o3") ||
|
||||
modelId.startsWith("o4-mini")
|
||||
const defaults = {
|
||||
requiredAutoTruncation: false,
|
||||
systemMessageMode: "system" as const,
|
||||
supportsFlexProcessing,
|
||||
supportsPriorityProcessing,
|
||||
}
|
||||
|
||||
// gpt-5-chat models are non-reasoning
|
||||
if (modelId.startsWith("gpt-5-chat")) {
|
||||
return {
|
||||
...defaults,
|
||||
isReasoningModel: false,
|
||||
}
|
||||
}
|
||||
|
||||
// o series reasoning models:
|
||||
if (
|
||||
modelId.startsWith("o") ||
|
||||
modelId.startsWith("gpt-5") ||
|
||||
modelId.startsWith("codex-") ||
|
||||
modelId.startsWith("computer-use")
|
||||
) {
|
||||
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
||||
return {
|
||||
...defaults,
|
||||
isReasoningModel: true,
|
||||
systemMessageMode: "remove",
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...defaults,
|
||||
isReasoningModel: true,
|
||||
systemMessageMode: "developer",
|
||||
}
|
||||
}
|
||||
|
||||
// gpt models:
|
||||
return {
|
||||
...defaults,
|
||||
isReasoningModel: false,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO AI SDK 6: use optional here instead of nullish
|
||||
const openaiResponsesProviderOptionsSchema = z.object({
|
||||
include: z
|
||||
|
||||
Reference in New Issue
Block a user