Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion packages/types/src/__tests__/openai-models.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
import { openAiCodexModels } from "../providers/openai-codex.js"
import { openAiCodexDefaultModelId, openAiCodexModels } from "../providers/openai-codex.js"
import { openAiNativeDefaultModelId, openAiNativeModels } from "../providers/openai.js"

describe("OpenAI native models", () => {
it("describes GPT-6.1 Sol pricing and required reasoning without changing defaults", () => {
expect(openAiNativeDefaultModelId).toBe("gpt-5.6-sol")
expect(openAiCodexDefaultModelId).toBe("gpt-5.6-sol")
expect(openAiNativeModels["gpt-6.1-sol"]).toMatchObject({
maxTokens: 128_000,
contextWindow: 1_050_000,
includedTools: ["apply_patch"],
excludedTools: ["apply_diff", "write_to_file"],
supportsImages: true,
supportsPromptCache: true,
supportsReasoningEffort: ["low", "medium", "high", "xhigh", "max"],
requiredReasoningEffort: true,
reasoningEffort: "medium",
supportsTemperature: false,
supportsVerbosity: true,
inputPrice: 2,
outputPrice: 10,
cacheWritesPrice: 2.5,
cacheReadsPrice: 0.1,
longContextPricing: {
thresholdTokens: 272_000,
inputPriceMultiplier: 2,
outputPriceMultiplier: 1.5,
cacheWritesPriceMultiplier: 2,
cacheReadsPriceMultiplier: 2,
appliesToServiceTiers: ["default", "flex", "priority"],
},
})
expect(openAiNativeModels["gpt-6.1-sol"].tiers).toEqual([
{
name: "flex",
contextWindow: 1_050_000,
inputPrice: 1,
outputPrice: 5,
cacheWritesPrice: 1.25,
cacheReadsPrice: 0.05,
},
{
name: "priority",
contextWindow: 1_050_000,
inputPrice: 4,
outputPrice: 20,
cacheWritesPrice: 5,
cacheReadsPrice: 0.2,
},
])
expect(openAiCodexModels["gpt-6.1-sol"]).toMatchObject({
maxTokens: 128_000,
contextWindow: 872_000,
includedTools: ["apply_patch"],
excludedTools: ["apply_diff", "write_to_file"],
supportsImages: true,
supportsPromptCache: true,
supportsReasoningEffort: ["low", "medium", "high", "xhigh", "max"],
requiredReasoningEffort: true,
reasoningEffort: "low",
supportsTemperature: false,
inputPrice: 0,
outputPrice: 0,
})
})

it("describes GPT-6 Astra without changing the provider default", () => {
expect(openAiNativeDefaultModelId).toBe("gpt-5.6-sol")
expect(openAiNativeModels["gpt-6-astra"]).toMatchObject({
Expand Down
19 changes: 19 additions & 0 deletions packages/types/src/providers/openai-codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ export const openAiCodexDefaultModelId: OpenAiCodexModelId = "gpt-5.6-sol"
* Costs are 0 as they are covered by the subscription.
*/
export const openAiCodexModels = {
// https://github.com/openai/codex/blob/main/codex-rs/models-manager/models.json
"gpt-6.1-sol": {
maxTokens: 128000,
// Use Codex's supported maximum rather than its 272K default compaction budget.
contextWindow: 872000,
includedTools: ["apply_patch"],
excludedTools: ["apply_diff", "write_to_file"],
supportsImages: true,
supportsPromptCache: true,
supportsReasoningEffort: ["low", "medium", "high", "xhigh", "max"],
requiredReasoningEffort: true,
reasoningEffort: "low",
inputPrice: 0,
outputPrice: 0,
supportsVerbosity: true,
supportsTemperature: false,
description:
"GPT-6.1 Sol: Near-Astra performance for complex coding and professional work via ChatGPT subscription",
},
"gpt-6-astra": {
maxTokens: 128000,
contextWindow: 872000,
Expand Down
45 changes: 45 additions & 0 deletions packages/types/src/providers/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,51 @@ export const OPENAI_API_PROTOCOL = "openai"
export const openAiNativeDefaultModelId: OpenAiNativeModelId = "gpt-5.6-sol"

export const openAiNativeModels = {
// https://developers.openai.com/api/docs/models/gpt-6.1-sol
"gpt-6.1-sol": {
maxTokens: 128000,
contextWindow: 1_050_000,
includedTools: ["apply_patch"],
excludedTools: ["apply_diff", "write_to_file"],
supportsImages: true,
supportsPromptCache: true,
supportsReasoningEffort: ["low", "medium", "high", "xhigh", "max"],
requiredReasoningEffort: true,
reasoningEffort: "medium",
inputPrice: 2.0,
outputPrice: 10.0,
cacheWritesPrice: 2.5,
cacheReadsPrice: 0.1,
longContextPricing: {
thresholdTokens: 272_000,
inputPriceMultiplier: 2,
outputPriceMultiplier: 1.5,
cacheWritesPriceMultiplier: 2,
cacheReadsPriceMultiplier: 2,
appliesToServiceTiers: ["default", "flex", "priority"],
},
supportsVerbosity: true,
supportsTemperature: false,
tiers: [
{
name: "flex",
contextWindow: 1_050_000,
inputPrice: 1.0,
outputPrice: 5.0,
cacheWritesPrice: 1.25,
cacheReadsPrice: 0.05,
},
{
name: "priority",
contextWindow: 1_050_000,
inputPrice: 4.0,
outputPrice: 20.0,
cacheWritesPrice: 5.0,
cacheReadsPrice: 0.2,
},
],
description: "GPT-6.1 Sol: Near-Astra performance for complex coding and professional work at a lower cost",
},
"gpt-6-astra": {
maxTokens: 128000,
contextWindow: 1_050_000,
Expand Down
116 changes: 116 additions & 0 deletions src/api/providers/__tests__/openai-sol-6.1.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
vitest.mock("@roo-code/telemetry", () => ({
TelemetryService: { instance: { captureException: vitest.fn() } },
}))

import type { ApiHandlerOptions } from "../../../shared/api"
import { openAiCodexOAuthManager } from "../../../integrations/openai-codex/oauth"
import { asyncStreamFrom, collectStream } from "../../../test-utils/stream"
import { OpenAiNativeHandler } from "../openai-native"
import { OpenAiCodexHandler } from "../openai-codex"

const reasoningCases: { options: ApiHandlerOptions; native: string; codex: string }[] = [
{ options: {}, native: "medium", codex: "low" },
{ options: { reasoningEffort: "none" }, native: "medium", codex: "low" },
{ options: { reasoningEffort: "minimal" }, native: "medium", codex: "low" },
{ options: { reasoningEffort: "disable" }, native: "medium", codex: "low" },
{ options: { enableReasoningEffort: false }, native: "medium", codex: "low" },
...(["low", "medium", "high", "xhigh", "max"] as const).map((effort) => ({
options: { reasoningEffort: effort },
native: effort,
codex: effort,
})),
]

describe("GPT-6.1 Sol requests", () => {
afterEach(() => vitest.restoreAllMocks())

it.each(reasoningCases)("uses supported reasoning for $options", ({ options, native, codex }) => {
const settings = { apiModelId: "gpt-6.1-sol", openAiNativeApiKey: "test-key", ...options }
const nativeHandler = new OpenAiNativeHandler(settings)
const codexHandler = new OpenAiCodexHandler(settings)
expect(nativeHandler.getModel().id).toBe("gpt-6.1-sol")
expect(codexHandler.getModel().id).toBe("gpt-6.1-sol")
expect(nativeHandler["getReasoningEffort"](nativeHandler.getModel())).toBe(native)
expect(codexHandler["getReasoningEffort"](codexHandler.getModel())).toBe(codex)
})

it("builds native Responses tool requests with verified pricing and no temperature", () => {
const handler = new OpenAiNativeHandler({
apiModelId: "gpt-6.1-sol",
openAiNativeApiKey: "test-key",
openAiNativeServiceTier: "priority",
modelTemperature: 0.7,
})
const model = handler.getModel()
const body = handler["buildRequestBody"](model, [], "System", "low", handler["getReasoningEffort"](model), {
taskId: "sol-task",
tools: [
{ type: "function", function: { name: "read_file", parameters: { type: "object", properties: {} } } },
],
})
expect(body).toMatchObject({
model: "gpt-6.1-sol",
max_output_tokens: 128_000,
reasoning: { effort: "medium" },
service_tier: "priority",
tools: [{ type: "function", name: "read_file", strict: true }],
})
expect(body).not.toHaveProperty("temperature")
expect(handler["applyServiceTierPricing"](model.info, "priority")).toMatchObject({
inputPrice: 4,
outputPrice: 20,
cacheReadsPrice: 0.2,
cacheWritesPrice: 5,
})
})

it("routes Codex tool requests through Responses Lite with Fast mode and required reasoning", async () => {
const handler = new OpenAiCodexHandler({
apiModelId: "gpt-6.1-sol",
reasoningEffort: "none",
openAiCodexServiceTier: "priority",
})
vitest.spyOn(openAiCodexOAuthManager, "getAccessToken").mockResolvedValue("test-token")
vitest.spyOn(openAiCodexOAuthManager, "getAccountId").mockResolvedValue("test-account")
const create = vitest.fn().mockResolvedValue(asyncStreamFrom([]))
Reflect.set(handler, "client", { responses: { create } })
await collectStream(
handler.createMessage("System", [{ role: "user", content: "Read the file" }], {
taskId: "sol-task",
tools: [
{
type: "function",
function: { name: "read_file", parameters: { type: "object", properties: {} } },
},
],
}),
)
expect(create).toHaveBeenCalledWith(
expect.objectContaining({
model: "gpt-6.1-sol",
service_tier: "priority",
prompt_cache_key: "sol-task",
reasoning: { effort: "low", summary: "auto", context: "all_turns" },
tool_choice: "auto",
parallel_tool_calls: false,
input: expect.arrayContaining([
expect.objectContaining({
type: "additional_tools",
tools: [expect.objectContaining({ type: "function", name: "read_file" })],
}),
]),
}),
expect.objectContaining({
headers: expect.objectContaining({
"x-openai-internal-codex-responses-lite": "true",
"session-id": "sol-task",
}),
}),
)
const body = create.mock.calls[0][0]
expect(body).not.toHaveProperty("instructions")
expect(body).not.toHaveProperty("tools")
expect(body).not.toHaveProperty("max_output_tokens")
expect(body).not.toHaveProperty("temperature")
})
})
2 changes: 1 addition & 1 deletion src/api/providers/openai-codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
const CODEX_API_BASE_URL = "https://chatgpt.com/backend-api/codex"
const LUNA_MODEL_ID = "gpt-5.6-luna"
const LUNA_CODEX_VERSION = "0.144.0"
const RESPONSES_LITE_MODEL_IDS = new Set<OpenAiCodexModelId>([LUNA_MODEL_ID, "gpt-6-astra"])
const RESPONSES_LITE_MODEL_IDS = new Set<OpenAiCodexModelId>([LUNA_MODEL_ID, "gpt-6-astra", "gpt-6.1-sol"])

Check warning on line 44 in src/api/providers/openai-codex.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

src/api/providers/openai-codex.ts:44: 3 mutation test gaps; example: Survived StringLiteral mutant (replacement: ""). See the job summary for the complete list and resolution guidance.

/**
* A refusal is streamed as text so the chat still shows why the model declined, but it is not part
Expand Down
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"cache": false
},
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"],
"inputs": ["src/**", "package.json", "tsconfig.json", "tsup.config.ts", "vite.config.ts"]
},
Expand Down
Loading