pi-mono/packages/ai/test/openai-responses-message-id.test.ts
Lucas Meijer fdce48eb40
fix(ai): drop Codex models rejected for ChatGPT accounts (#11173)
The openai-codex provider authenticates with a ChatGPT account, and the
Codex backend rejects gpt-5.5 and gpt-5.3-codex-spark for those accounts
("not supported when using Codex with a ChatGPT account"). Remove them
from the catalog so model pickers stop offering models that always fail.

Codex e2e tests that used openai-codex/gpt-5.5 now use gpt-6.1-sol, the
openai-codex default. The context overflow test uses gpt-5.6-sol to keep
its prompt smaller.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 15:55:48 +02:00

48 lines
1.6 KiB
TypeScript

import type { ResponseOutputMessage } from "openai/resources/responses/responses.js";
import { describe, expect, it } from "vitest";
import { convertResponsesMessages } from "../src/api/openai-responses-shared.ts";
import { getModel, normalizeContext } from "../src/compat.ts";
import type { AssistantMessage, Usage } from "../src/types.ts";
const usage: Usage = {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
totalTokens: 0,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
};
describe("OpenAI Responses message ID conversion", () => {
it("generates unique fallback message IDs for multiple text blocks in one assistant turn", () => {
const model = getModel("openai-codex", "gpt-6.1-sol");
const assistant: AssistantMessage = {
role: "assistant",
content: [
{ type: "text", text: "first answer" },
{ type: "text", text: "visible answer" },
],
api: "anthropic-messages",
provider: "anthropic",
model: "claude-opus-4-8",
usage,
stopReason: "stop",
timestamp: Date.now() - 1000,
};
const context = normalizeContext({
systemPrompt: "You are concise.",
messages: [{ role: "user", content: "hello", timestamp: Date.now() - 2000 }, assistant],
});
const input = convertResponsesMessages(model, context, new Set(["openai", "openai-codex", "opencode"]));
const messageIds = input
.filter(
(item): item is ResponseOutputMessage =>
item.type === "message" && "id" in item && typeof item.id === "string",
)
.map((item) => item.id);
expect(messageIds).toEqual(["msg_pi_1", "msg_pi_1_1"]);
expect(new Set(messageIds).size).toBe(messageIds.length);
});
});