From 399699469b2413fe469360880987492463a9bb2a Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Fri, 9 Jan 2026 16:43:11 -0600 Subject: [PATCH] workin --- packages/opencode/src/plugin/codex.ts | 35 +-------------------------- packages/opencode/src/session/llm.ts | 19 +++++++-------- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/packages/opencode/src/plugin/codex.ts b/packages/opencode/src/plugin/codex.ts index 9077c12966..223e4621c7 100644 --- a/packages/opencode/src/plugin/codex.ts +++ b/packages/opencode/src/plugin/codex.ts @@ -1,6 +1,5 @@ import type { Hooks, PluginInput } from "@opencode-ai/plugin" import { Log } from "../util/log" -import { Installation } from "../installation" import { OAUTH_DUMMY_KEY } from "../auth" const log = Log.create({ service: "plugin.codex" }) @@ -256,13 +255,6 @@ function waitForOAuthCallback(pkce: PkceCodes, state: string): Promise { return { auth: { @@ -331,20 +323,8 @@ export async function CodexAuthPlugin(input: PluginInput): Promise { } } - // Set required Codex headers + // Set authorization header with access token headers.set("authorization", `Bearer ${currentAuth.access}`) - headers.set("originator", "opencode") - headers.set("user-agent", getUserAgent()) - - // Extract session_id from request body if present - let body = init?.body - if (body && typeof body === "string") { - const parsed = JSON.parse(body) - // The session ID should be passed in the request - we'll extract it from context - // For now, generate a UUIDv7-like ID based on timestamp - const sessionId = parsed.metadata?.sessionID || generateSessionId() - headers.set("session_id", sessionId) - } // Rewrite URL to Codex endpoint let url: URL @@ -363,7 +343,6 @@ export async function CodexAuthPlugin(input: PluginInput): Promise { return fetch(url, { ...init, - body, headers, }) }, @@ -402,15 +381,3 @@ export async function CodexAuthPlugin(input: PluginInput): Promise { }, } } - -// Generate a UUIDv7-like session ID (timestamp-prefixed) -function generateSessionId(): string { - const timestamp = Date.now() - const timestampHex = timestamp.toString(16).padStart(12, "0") - const randomHex = Array.from(crypto.getRandomValues(new Uint8Array(10))) - .map((b) => b.toString(16).padStart(2, "0")) - .join("") - // UUIDv7 format: xxxxxxxx-xxxx-7xxx-yxxx-xxxxxxxxxxxx - // First 48 bits are timestamp, version is 7 - return `${timestampHex.slice(0, 8)}-${timestampHex.slice(8, 12)}-7${randomHex.slice(0, 3)}-${(0x80 | (parseInt(randomHex.slice(3, 4), 16) & 0x3f)).toString(16)}${randomHex.slice(4, 7)}-${randomHex.slice(7, 19)}` -} diff --git a/packages/opencode/src/session/llm.ts b/packages/opencode/src/session/llm.ts index ebf30c35ef..c5792c16de 100644 --- a/packages/opencode/src/session/llm.ts +++ b/packages/opencode/src/session/llm.ts @@ -101,6 +101,7 @@ export namespace LLM { ) if (isCodex) { options.instructions = SystemPrompt.instructions() + options.store = false } const params = await Plugin.trigger( @@ -122,16 +123,14 @@ export namespace LLM { }, ) - l.info("params", { - params, - }) - - const maxOutputTokens = ProviderTransform.maxOutputTokens( - input.model.api.npm, - params.options, - input.model.limit.output, - OUTPUT_TOKEN_MAX, - ) + const maxOutputTokens = isCodex + ? undefined + : ProviderTransform.maxOutputTokens( + input.model.api.npm, + params.options, + input.model.limit.output, + OUTPUT_TOKEN_MAX, + ) const tools = await resolveTools(input)