Skip to content
24 changes: 24 additions & 0 deletions src/provider/codex-responses-adapter.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, test } from "bun:test";
import type { ConversationTurn, LastCycleSource } from "@intx/types/runtime";
import { PRODUCT_NAME } from "../branding.js";
import {
createCodexResponsesAdapter,
isResponsesStreamTerminal,
Expand Down Expand Up @@ -60,6 +61,29 @@ describe("createCodexResponsesAdapter", () => {
const adapter = createCodexResponsesAdapter(source);
expect(adapter.isStreamTerminal).toBe(isResponsesStreamTerminal);
});

test("bridge message points at Codex tool proxies instead of neutralizing them", () => {
const adapter = createCodexResponsesAdapter(source);
const turns: ConversationTurn[] = [
{ role: "user", timestamp: 0, content: [{ type: "text", text: "hi" }] },
];

const request = adapter.buildRequest(turns, "gpt-5.1-codex", {
systemPrompt: "operating prompt body",
});
const body = JSON.parse(request.body) as {
input: { role?: string; content?: { text?: string }[] }[];
};
const bridgeText = body.input[0]?.content?.[0]?.text ?? "";

expect(bridgeText).toContain(`${PRODUCT_NAME} is the harness, not the Codex CLI.`);
expect(bridgeText).toContain("apply_patch, update_plan, shell");
expect(bridgeText).toContain("proxy onto");
expect(bridgeText).toContain("prefer whichever name appears in the current tool list");
expect(bridgeText).toContain("operating prompt body");
expect(bridgeText).not.toContain("DO NOT EXIST");
expect(bridgeText).not.toContain("Ignore every tool reference");
});
});

describe("createCodexResponsesAdapter usage parsing", () => {
Expand Down
7 changes: 4 additions & 3 deletions src/provider/codex-responses-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ function optionString(options: InferenceOptions, key: string): string | undefine

// `instructions` is pinned to the official Codex prompt (the backend rejects
// anything else), so Corbits Code's operating prompt rides as a leading developer
// message that also neutralizes the Codex prompt's references to tools that do
// not exist here. The function tools sent with the request are authoritative.
// message that also reconciles the Codex prompt's tool references with the
// proxies actually wired up here. The function tools sent with the request are
// authoritative for names/schemas; this text only resolves which dialect to speak.
function bridgeMessage(systemPrompt: string): ResponsesInputItem {
const text = `<${ENVIRONMENT_TAG_NAME} priority="0">
You are NOT running in the Codex CLI. You are running in ${PRODUCT_NAME}, a different harness. The base instructions above describe Codex CLI tools (apply_patch, update_plan, shell) that DO NOT EXIST here. Ignore every tool reference in the base instructions and use ONLY the function tools provided in this request. The following are your authoritative operating instructions:
${PRODUCT_NAME} is the harness, not the Codex CLI. The Codex tools named above (apply_patch, update_plan, shell) proxy onto ${PRODUCT_NAME}'s native tools with the same permissions — prefer whichever name appears in the current tool list. These operating instructions are authoritative where they differ from the base instructions:

${systemPrompt}
</${ENVIRONMENT_TAG_NAME}>`;
Expand Down
Loading