Store settings on the thread instead of turn (#4579)

It's much more common to keep the same settings for the entire
conversation, we can add per-turn overrides later.
This commit is contained in:
pakrym-oai
2025-10-01 17:31:13 -07:00
committed by GitHub
parent e899ae7d8a
commit c07fb71186
8 changed files with 56 additions and 32 deletions

View File

@@ -5,7 +5,8 @@ jest.mock("node:child_process", () => {
return { ...actual, spawn: jest.fn(actual.spawn) };
});
const actualChildProcess = jest.requireActual<typeof import("node:child_process")>("node:child_process");
const actualChildProcess =
jest.requireActual<typeof import("node:child_process")>("node:child_process");
const spawnMock = child_process.spawn as jest.MockedFunction<typeof actualChildProcess.spawn>;
export function codexExecSpy(): { args: string[][]; restore: () => void } {

View File

@@ -109,9 +109,7 @@ describe("Codex", () => {
const thread = client.startThread();
await thread.run("first input");
await thread.run("second input", {
model: "gpt-test-1",
});
await thread.run("second input");
// Check second request continues the same thread
expect(requests.length).toBeGreaterThanOrEqual(2);
@@ -119,7 +117,7 @@ describe("Codex", () => {
expect(secondRequest).toBeDefined();
const payload = secondRequest!.json;
expect(payload.model).toBe("gpt-test-1");
expect(payload.input.at(-1)!.content![0]!.text).toBe("second input");
const assistantEntry = payload.input.find(
(entry: { role: string }) => entry.role === "assistant",
);
@@ -197,11 +195,11 @@ describe("Codex", () => {
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await thread.run("apply options", {
const thread = client.startThread({
model: "gpt-test-1",
sandboxMode: "workspace-write",
});
await thread.run("apply options");
const payload = requests[0];
expect(payload).toBeDefined();
@@ -240,11 +238,11 @@ describe("Codex", () => {
apiKey: "test",
});
const thread = client.startThread();
await thread.run("use custom working directory", {
const thread = client.startThread({
workingDirectory,
skipGitRepoCheck: true,
});
await thread.run("use custom working directory");
const commandArgs = spawnArgs[0];
expectPair(commandArgs, ["--cd", workingDirectory]);
@@ -274,12 +272,12 @@ describe("Codex", () => {
apiKey: "test",
});
const thread = client.startThread();
await expect(
thread.run("use custom working directory", {
workingDirectory,
}),
).rejects.toThrow(/Not inside a trusted directory/);
const thread = client.startThread({
workingDirectory,
});
await expect(thread.run("use custom working directory")).rejects.toThrow(
/Not inside a trusted directory/,
);
} finally {
await close();
}