Skip to content

Commit 782cdec

Browse files
committed
Retarget Codex developer bridge for proxy tools
1 parent d9b7a5b commit 782cdec

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/provider/codex-responses-adapter.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, test } from "bun:test";
22
import type { ConversationTurn, LastCycleSource } from "@intx/types/runtime";
3+
import { PRODUCT_NAME } from "../branding.js";
34
import {
45
createCodexResponsesAdapter,
56
isResponsesStreamTerminal,
@@ -58,6 +59,29 @@ describe("createCodexResponsesAdapter", () => {
5859
const adapter = createCodexResponsesAdapter(source);
5960
expect(adapter.isStreamTerminal).toBe(isResponsesStreamTerminal);
6061
});
62+
63+
test("bridge message points at Codex tool proxies instead of neutralizing them", () => {
64+
const adapter = createCodexResponsesAdapter(source);
65+
const turns: ConversationTurn[] = [
66+
{ role: "user", timestamp: 0, content: [{ type: "text", text: "hi" }] },
67+
];
68+
69+
const request = adapter.buildRequest(turns, "gpt-5.1-codex", {
70+
systemPrompt: "operating prompt body",
71+
});
72+
const body = JSON.parse(request.body) as {
73+
input: Array<{ role?: string; content?: Array<{ text?: string }> }>;
74+
};
75+
const bridgeText = body.input[0]?.content?.[0]?.text ?? "";
76+
77+
expect(bridgeText).toContain(`${PRODUCT_NAME} is the harness, not the Codex CLI.`);
78+
expect(bridgeText).toContain("apply_patch, update_plan, shell");
79+
expect(bridgeText).toContain("proxy onto");
80+
expect(bridgeText).toContain("prefer whichever name appears in the current tool list");
81+
expect(bridgeText).toContain("operating prompt body");
82+
expect(bridgeText).not.toContain("DO NOT EXIST");
83+
expect(bridgeText).not.toContain("Ignore every tool reference");
84+
});
6185
});
6286

6387
describe("createCodexResponsesAdapter usage parsing", () => {

src/provider/codex-responses-adapter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,12 @@ function optionString(options: InferenceOptions, key: string): string | undefine
249249

250250
// `instructions` is pinned to the official Codex prompt (the backend rejects
251251
// anything else), so Corbits Code's operating prompt rides as a leading developer
252-
// message that also neutralizes the Codex prompt's references to tools that do
253-
// not exist here. The function tools sent with the request are authoritative.
252+
// message that also reconciles the Codex prompt's tool references with the
253+
// proxies actually wired up here. The function tools sent with the request are
254+
// authoritative for names/schemas; this text only resolves which dialect to speak.
254255
function bridgeMessage(systemPrompt: string): ResponsesInputItem {
255256
const text = `<${ENVIRONMENT_TAG_NAME} priority="0">
256-
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:
257+
${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:
257258
258259
${systemPrompt}
259260
</${ENVIRONMENT_TAG_NAME}>`;

0 commit comments

Comments
 (0)