fix(core): stop replaying stale GitHub Copilot Responses item IDs (#34686)
This commit is contained in:
parent
c88ca972cf
commit
f1407e41c4
5 changed files with 310 additions and 26 deletions
|
|
@ -86,7 +86,7 @@ export async function convertToOpenAIResponsesInput({
|
|||
: {
|
||||
image_url: `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
||||
}),
|
||||
detail: part.providerOptions?.openai?.imageDetail,
|
||||
detail: part.providerOptions?.copilot?.imageDetail,
|
||||
}
|
||||
} else if (part.mediaType === "application/pdf") {
|
||||
if (part.data instanceof URL) {
|
||||
|
|
@ -127,7 +127,7 @@ export async function convertToOpenAIResponsesInput({
|
|||
input.push({
|
||||
role: "assistant",
|
||||
content: [{ type: "output_text", text: part.text }],
|
||||
id: (part.providerOptions?.openai?.itemId as string) ?? undefined,
|
||||
id: (part.providerOptions?.copilot?.itemId as string) ?? undefined,
|
||||
})
|
||||
break
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ export async function convertToOpenAIResponsesInput({
|
|||
input.push({
|
||||
type: "local_shell_call",
|
||||
call_id: part.toolCallId,
|
||||
id: (part.providerOptions?.openai?.itemId as string) ?? undefined,
|
||||
id: (part.providerOptions?.copilot?.itemId as string) ?? undefined,
|
||||
action: {
|
||||
type: "exec",
|
||||
command: parsedInput.action.command,
|
||||
|
|
@ -162,7 +162,7 @@ export async function convertToOpenAIResponsesInput({
|
|||
call_id: part.toolCallId,
|
||||
name: part.toolName,
|
||||
arguments: JSON.stringify(part.input),
|
||||
id: (part.providerOptions?.openai?.itemId as string) ?? undefined,
|
||||
id: (part.providerOptions?.copilot?.itemId as string) ?? undefined,
|
||||
})
|
||||
break
|
||||
}
|
||||
|
|
@ -275,7 +275,7 @@ export async function convertToOpenAIResponsesInput({
|
|||
const output = part.output
|
||||
|
||||
if (output.type === "execution-denied") {
|
||||
const approvalId = (output.providerOptions?.openai as { approvalId?: string } | undefined)?.approvalId
|
||||
const approvalId = (output.providerOptions?.copilot as { approvalId?: string } | undefined)?.approvalId
|
||||
|
||||
if (approvalId) {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
type: "reasoning" as const,
|
||||
text: summary.text,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: part.id,
|
||||
reasoningEncryptedContent: part.encrypted_content ?? null,
|
||||
},
|
||||
|
|
@ -563,7 +563,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
toolName: "local_shell",
|
||||
input: JSON.stringify({ action: part.action } satisfies z.infer<typeof localShellInputSchema>),
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: part.id,
|
||||
},
|
||||
},
|
||||
|
|
@ -574,7 +574,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
|
||||
case "message": {
|
||||
for (const contentPart of part.content) {
|
||||
if (options.providerOptions?.openai?.logprobs && contentPart.logprobs) {
|
||||
if (options.providerOptions?.copilot?.logprobs && contentPart.logprobs) {
|
||||
logprobs.push(contentPart.logprobs)
|
||||
}
|
||||
|
||||
|
|
@ -582,7 +582,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
type: "text",
|
||||
text: contentPart.text,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: part.id,
|
||||
},
|
||||
},
|
||||
|
|
@ -622,7 +622,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
toolName: part.name,
|
||||
input: part.arguments,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: part.id,
|
||||
},
|
||||
},
|
||||
|
|
@ -724,15 +724,15 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
}
|
||||
|
||||
const providerMetadata: SharedV3ProviderMetadata = {
|
||||
openai: { responseId: response.id },
|
||||
copilot: { responseId: response.id },
|
||||
}
|
||||
|
||||
if (logprobs.length > 0) {
|
||||
providerMetadata.openai.logprobs = logprobs
|
||||
providerMetadata.copilot.logprobs = logprobs
|
||||
}
|
||||
|
||||
if (typeof response.service_tier === "string") {
|
||||
providerMetadata.openai.serviceTier = response.service_tier
|
||||
providerMetadata.copilot.serviceTier = response.service_tier
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -954,7 +954,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
type: "text-start",
|
||||
id: value.item.id,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: value.item.id,
|
||||
},
|
||||
},
|
||||
|
|
@ -971,7 +971,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
type: "reasoning-start",
|
||||
id: `${value.item.id}:0`,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: value.item.id,
|
||||
reasoningEncryptedContent: value.item.encrypted_content ?? null,
|
||||
},
|
||||
|
|
@ -994,7 +994,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
toolName: value.item.name,
|
||||
input: value.item.arguments,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: value.item.id,
|
||||
},
|
||||
},
|
||||
|
|
@ -1103,7 +1103,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
},
|
||||
} satisfies z.infer<typeof localShellInputSchema>),
|
||||
providerMetadata: {
|
||||
openai: { itemId: value.item.id },
|
||||
copilot: { itemId: value.item.id },
|
||||
},
|
||||
})
|
||||
} else if (value.item.type === "message") {
|
||||
|
|
@ -1122,7 +1122,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
type: "reasoning-end",
|
||||
id: `${activeReasoningPart.canonicalId}:${summaryIndex}`,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: activeReasoningPart.canonicalId,
|
||||
reasoningEncryptedContent: value.item.encrypted_content ?? null,
|
||||
},
|
||||
|
|
@ -1209,7 +1209,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
type: "text-start",
|
||||
id: currentTextId,
|
||||
providerMetadata: {
|
||||
openai: { itemId: value.item_id },
|
||||
copilot: { itemId: value.item_id },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -1220,7 +1220,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
delta: value.delta,
|
||||
})
|
||||
|
||||
if (options.providerOptions?.openai?.logprobs && value.logprobs) {
|
||||
if (options.providerOptions?.copilot?.logprobs && value.logprobs) {
|
||||
logprobs.push(value.logprobs)
|
||||
}
|
||||
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
||||
|
|
@ -1235,7 +1235,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
type: "reasoning-start",
|
||||
id: `${activeItem.canonicalId}:${value.summary_index}`,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: activeItem.canonicalId,
|
||||
reasoningEncryptedContent: activeItem.encryptedContent ?? null,
|
||||
},
|
||||
|
|
@ -1252,7 +1252,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
id: `${activeItem.canonicalId}:${value.summary_index}`,
|
||||
delta: value.delta,
|
||||
providerMetadata: {
|
||||
openai: {
|
||||
copilot: {
|
||||
itemId: activeItem.canonicalId,
|
||||
},
|
||||
},
|
||||
|
|
@ -1306,17 +1306,17 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||
}
|
||||
|
||||
const providerMetadata: SharedV3ProviderMetadata = {
|
||||
openai: {
|
||||
copilot: {
|
||||
responseId,
|
||||
},
|
||||
}
|
||||
|
||||
if (logprobs.length > 0) {
|
||||
providerMetadata.openai.logprobs = logprobs
|
||||
providerMetadata.copilot.logprobs = logprobs
|
||||
}
|
||||
|
||||
if (serviceTier !== undefined) {
|
||||
providerMetadata.openai.serviceTier = serviceTier
|
||||
providerMetadata.copilot.serviceTier = serviceTier
|
||||
}
|
||||
|
||||
controller.enqueue({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue