mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 06:04:51 +00:00
refactor(ai): streamline codex prompt handling
This commit is contained in:
parent
b04ce9fe95
commit
858c6bae8a
6 changed files with 99 additions and 104 deletions
|
|
@ -7,7 +7,7 @@ describe("openai-codex include handling", () => {
|
|||
model: "gpt-5.1-codex",
|
||||
};
|
||||
|
||||
const transformed = await transformRequestBody(body, "CODEX_INSTRUCTIONS", { include: ["foo"] }, true);
|
||||
const transformed = await transformRequestBody(body, { include: ["foo"] });
|
||||
expect(transformed.include).toEqual(["foo", "reasoning.encrypted_content"]);
|
||||
});
|
||||
|
||||
|
|
@ -16,12 +16,9 @@ describe("openai-codex include handling", () => {
|
|||
model: "gpt-5.1-codex",
|
||||
};
|
||||
|
||||
const transformed = await transformRequestBody(
|
||||
body,
|
||||
"CODEX_INSTRUCTIONS",
|
||||
{ include: ["foo", "reasoning.encrypted_content"] },
|
||||
true,
|
||||
);
|
||||
const transformed = await transformRequestBody(body, {
|
||||
include: ["foo", "reasoning.encrypted_content"],
|
||||
});
|
||||
expect(transformed.include).toEqual(["foo", "reasoning.encrypted_content"]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { tmpdir } from "node:os";
|
|||
import { join } from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { getCodexInstructions } from "../src/providers/openai-codex/prompts/codex.js";
|
||||
import { CODEX_PI_BRIDGE } from "../src/providers/openai-codex/prompts/pi-codex-bridge.js";
|
||||
import {
|
||||
normalizeModel,
|
||||
type RequestBody,
|
||||
|
|
@ -19,7 +18,7 @@ const FALLBACK_PROMPT = readFileSync(
|
|||
);
|
||||
|
||||
describe("openai-codex request transformer", () => {
|
||||
it("filters item_reference, strips ids, and inserts bridge message", async () => {
|
||||
it("filters item_reference and strips ids", async () => {
|
||||
const body: RequestBody = {
|
||||
model: "gpt-5.1-codex",
|
||||
input: [
|
||||
|
|
@ -41,18 +40,19 @@ describe("openai-codex request transformer", () => {
|
|||
tools: [{ type: "function", name: "tool", description: "", parameters: {} }],
|
||||
};
|
||||
|
||||
const transformed = await transformRequestBody(body, "CODEX_INSTRUCTIONS", {}, true);
|
||||
const transformed = await transformRequestBody(body, {});
|
||||
|
||||
expect(transformed.store).toBe(false);
|
||||
expect(transformed.stream).toBe(true);
|
||||
expect(transformed.instructions).toBe("CODEX_INSTRUCTIONS");
|
||||
expect(transformed.include).toEqual(["reasoning.encrypted_content"]);
|
||||
|
||||
const input = transformed.input || [];
|
||||
expect(input.some((item) => item.type === "item_reference")).toBe(false);
|
||||
expect(input.some((item) => "id" in item)).toBe(false);
|
||||
expect(input[0]?.type).toBe("message");
|
||||
expect(input[0]?.content).toEqual([{ type: "input_text", text: CODEX_PI_BRIDGE }]);
|
||||
const first = input[0];
|
||||
expect(first?.type).toBe("message");
|
||||
expect(first?.role).toBe("developer");
|
||||
expect(first?.content).toEqual([{ type: "input_text", text: `${DEFAULT_PROMPT_PREFIX}...` }]);
|
||||
|
||||
const orphaned = input.find((item) => item.type === "message" && item.role === "assistant");
|
||||
expect(orphaned?.content).toMatch(/Previous tool result/);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue