fix(codex): keep configured developer instructions when Paseo adds instructions (#10792)

Codex uses a thread's developerInstructions in place of the
developer_instructions in its config. Paseo now reads the configured
value through config/read and sends it ahead of the agent, daemon, and
plugin instructions on thread/start, thread/resume, and rewind forks.

Closes #10644
This commit is contained in:
Mohamed Boudra
2026-11-25 20:00:15 +07:00
committed by GitHub
parent 5c97cd5903
commit 732b936fb6
2 changed files with 47 additions and 7 deletions
@@ -1470,6 +1470,31 @@ describe("Codex app-server provider", () => {
}
});
test.each(["thread/start", "thread/resume"] as const)(
"%s appends plugin instructions to the developer instructions configured in Codex",
async (method) => {
const appServer = createFakeCodexAppServer({
"config/read": () => ({ config: { developer_instructions: "Configured role" } }),
});
const provider = createProviderWithFakeAppServer(appServer);
const config = { pluginAppendSystemPrompt: ["Plugin instructions"] };
const session =
method === "thread/start"
? await provider.createSession(createConfig(config))
: await provider.resumeSession({ sessionId: "saved-thread" }, config);
try {
await session.startTurn("hello");
await appServer.waitForTurnStart();
expect(
appServer.requests().find((request) => request.method === method)?.params,
).toMatchObject({ developerInstructions: "Configured role\n\nPlugin instructions" });
appServer.assertNoErrors();
} finally {
await session.close();
}
},
);
test("reopen injects current instructions once, including an explicit empty snapshot", async () => {
const handlers = {
initialize: () => ({ userAgent: "codex/0.165.0" }),
@@ -57,7 +57,7 @@ import path from "node:path";
import { isDeepStrictEqual } from "node:util";
import { z } from "zod";
import { renderPromptAttachmentAsText } from "../prompt-attachments.js";
import { composeAgentSystemPrompt } from "../system-prompt.js";
import { composeAgentSystemPrompt, composeSystemPromptParts } from "../system-prompt.js";
import { CodexInstructionSnapshot } from "./codex/instruction-snapshot.js";
import { CodexAsyncQuestions, codexAsyncQuestionToTimeline } from "./codex/async-questions.js";
import {
@@ -3797,6 +3797,7 @@ export class CodexAppServerAgentSession implements AgentSession {
private resolvedWorkspaceWrite: NonNullable<
CodexProviderOptions["sandbox_workspace_write"]
> | null = null;
private configuredDeveloperInstructions: string | undefined;
private resolvedSandboxPolicy: Record<string, unknown> | null = null;
private currentThreadId: string | null = null;
// Codex writes a new thread's rollout at its first turn. Until then the thread exists only
@@ -4062,7 +4063,7 @@ export class CodexAppServerAgentSession implements AgentSession {
this.speedModels =
CodexModelListResponseSchema.parse(await client.request("model/list", {})).data ?? [];
this.normalizeSpeed();
await this.loadResolvedWorkspaceWrite();
await this.loadResolvedConfig();
await this.loadCollaborationModes();
await this.loadSkills();
@@ -4093,7 +4094,7 @@ export class CodexAppServerAgentSession implements AgentSession {
}
}
private async loadResolvedWorkspaceWrite(): Promise<void> {
private async loadResolvedConfig(): Promise<void> {
if (!this.client) return;
try {
const response = toObjectRecord(
@@ -4101,11 +4102,25 @@ export class CodexAppServerAgentSession implements AgentSession {
);
const config = toObjectRecord(response?.config);
this.resolvedWorkspaceWrite = readSandboxWorkspaceWrite(config?.sandbox_workspace_write);
this.configuredDeveloperInstructions =
typeof config?.developer_instructions === "string"
? config.developer_instructions
: undefined;
} catch (error) {
this.logger.debug({ error }, "Failed to read resolved Codex workspace-write config");
this.logger.debug({ error }, "Failed to read resolved Codex config");
}
}
/**
* Codex uses a thread's developerInstructions in place of the developer_instructions in its
* config, so Paseo's instructions carry the configured ones ahead of them.
*/
private threadDeveloperInstructions(): string | undefined {
const paseoInstructions = composeAgentSystemPrompt(this.config);
if (!paseoInstructions) return undefined;
return composeSystemPromptParts(this.configuredDeveloperInstructions, paseoInstructions);
}
private rememberResolvedSandboxPolicy(response: unknown): void {
const sandbox = toObjectRecord(toObjectRecord(response)?.sandbox);
this.resolvedSandboxPolicy = sandbox ?? null;
@@ -4561,7 +4576,7 @@ export class CodexAppServerAgentSession implements AgentSession {
// the unnamespaced key emitted by earlier Paseo versions.
params.modelProvider = this.deps.customCodexConfig.model_provider;
}
const developerInstructions = composeAgentSystemPrompt(this.config);
const developerInstructions = this.threadDeveloperInstructions();
if (developerInstructions) {
params.developerInstructions = developerInstructions;
}
@@ -5526,7 +5541,7 @@ export class CodexAppServerAgentSession implements AgentSession {
model: this.config.model ?? null,
serviceTier: this.serviceTier,
config: this.buildCodexInnerConfig(),
developerInstructions: composeAgentSystemPrompt(this.config),
developerInstructions: this.threadDeveloperInstructions(),
userMessageTurns: this.codexUserMessageTurns(),
threadRollbackAvailable: this.threadRollbackAvailable,
setThreadId: async (threadId) => {
@@ -6082,7 +6097,7 @@ export class CodexAppServerAgentSession implements AgentSession {
const approvalPolicy = this.hasWorkflowModeOverride ? preset.approvalPolicy : undefined;
const sandbox = this.hasWorkflowModeOverride ? preset.sandbox : undefined;
const innerConfig = this.buildCodexInnerConfig();
const developerInstructions = composeAgentSystemPrompt(this.config);
const developerInstructions = this.threadDeveloperInstructions();
const params: Record<string, unknown> = {
model,
cwd: this.config.cwd ?? null,