Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CodexDeveloperInstructions.test.ts

81 lines3.3 KB

1import * as NodeAssert from "node:assert/strict";
2​
3import { describe, it } from "vite-plus/test";
4​
5import {
6 buildCodexAdditionalContext,
7 CODEX_ADDITIONAL_CONTEXT_VALUE_MAX_BYTES,
8} from "./CodexDeveloperInstructions.ts";
9​
10describe("buildCodexAdditionalContext", () => {
11 describe.each([
12 { model: "custom-model", modelName: "Custom 🦊 Model", reasoningEffort: "xhigh" },
13 ])("with runtime $model", (runtime) => {
14 it.each([undefined, { browser: true, device: true }])(
15 "keeps every entry within Codex's per-entry cap with tools %j",
16 (availability) => {
17 const context = buildCodexAdditionalContext(runtime, availability);
18​
19 for (const [key, entry] of Object.entries(context)) {
20 // Codex counts ceil(UTF-8 bytes / 4) tokens, excluding keys and wrappers.
21 const bytes = Buffer.byteLength(entry.value, "utf8");
22 const limit = CODEX_ADDITIONAL_CONTEXT_VALUE_MAX_BYTES;
23 NodeAssert.ok(
24 bytes <= limit,
25 `${key}: ${bytes} UTF-8 bytes exceeds Codex's ${limit}-byte per-entry cap by ${bytes - limit} bytes; split the instructions into separate entries to avoid silent truncation`,
26 );
27 }
28 },
29 );
30 });
31});
32​
33describe("Codex runtime context", () => {
34 it("describes Markdown media support in the runtime context in both modes", () => {
35 {
36 const instructions = runtimeInstructions({
37 model: "gpt-5.3-codex",
38 reasoningEffort: "high",
39 });
40 NodeAssert.match(
41 instructions,
42 /<runtime_info>.*embed images, video, and audio.*Markdown image syntax with absolute file paths.*Link any other file.*absolute path.*files viewer.*<\/runtime_info>/,
43 );
44 }
45 });
46​
47 it("flattens multiline metadata into single-line runtime info", () => {
48 const instructions = runtimeInstructions({
49 model: "gpt\n5.3\ncodex",
50 reasoningEffort: " high\neffort ",
51 });
52​
53 NodeAssert.match(instructions, /as gpt 5\.3 codex with high effort reasoning effort/);
54 NodeAssert.doesNotMatch(instructions, /<runtime_info>[^<]*\n/);
55 });
56});
57​
58describe("Codex orchestration context", () => {
59 it("routes subagents native first, delegate_task for the rest", () => {
60 const orchestration = Object.entries(buildCodexAdditionalContext({ model: "gpt-6.1-sol" }))
61 .filter(([key]) => key.startsWith("t3_code_orchestration_"))
62 .map(([, entry]) => entry.value)
63 .join("\n");
64​
65 NodeAssert.ok(orchestration.includes("use your native tool when the child uses your provider"));
66 NodeAssert.ok(orchestration.includes("`run_in_background:false`"));
67 NodeAssert.ok(orchestration.includes("A native type running another provider's model"));
68 NodeAssert.ok(
69 orchestration.includes("Every new delegate review or re-check is a new `delegate_task`"),
70 );
71 NodeAssert.ok(orchestration.includes("never a `t3_thread_send`"));
72 NodeAssert.ok(!orchestration.includes("inheritedOptions"));
73 NodeAssert.ok(!orchestration.includes("Prefer native"));
74 // The ACP terminal fallback is ACP-only; Codex agents never need it.
75 NodeAssert.ok(!orchestration.includes("acp-mcp-call"));
76 });
77});
78​
79function runtimeInstructions(runtime: Parameters<typeof buildCodexAdditionalContext>[0]) {
80 return buildCodexAdditionalContext(runtime).t3_code_runtime!.value;