Skip to content

Commit e8eca22

Browse files
fix(codex): send image attachments by path
Remove the unproven 413 compact-and-retry behavior because compaction is asynchronous. Keep passing Codex image attachments as local file paths so turn/start no longer scales with image size.
1 parent 58906da commit e8eca22

3 files changed

Lines changed: 1 addition & 88 deletions

File tree

‎apps/server/src/provider/Layers/CodexCollabRuntime.integration.test.ts‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -654,51 +654,6 @@ describe("CodexSessionRuntime collab integration", () => {
654654
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
655655
);
656656

657-
it.live("compacts and retries a turn/start that fails with HTTP 413", () =>
658-
Effect.gen(function* () {
659-
const script = {
660-
rootThreadId: ROOT,
661-
recordRequests: true,
662-
recordTurnStartRequests: true,
663-
turnStart413BeforeSuccess: true,
664-
notifications: [],
665-
};
666-
// @effect-diagnostics-next-line preferSchemaOverJson:off
667-
NodeFS.writeFileSync(scriptPath, JSON.stringify(script), "utf8");
668-
const requestsPath = `${scriptPath}.requests`;
669-
NodeFS.rmSync(requestsPath, { force: true });
670-
yield* Effect.addFinalizer(() =>
671-
Effect.sync(() => {
672-
NodeFS.rmSync(scriptPath, { force: true });
673-
NodeFS.rmSync(requestsPath, { force: true });
674-
}),
675-
);
676-
677-
const runtime = yield* makeCodexSessionRuntime({
678-
threadId: ThreadId.make("thread-codex-413-retry"),
679-
binaryPath: peerPath,
680-
cwd: NodeOS.tmpdir(),
681-
runtimeMode: "full-access",
682-
environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath },
683-
});
684-
685-
yield* runtime.start();
686-
const result = yield* runtime.sendTurn({ input: "continue" });
687-
assert.ok(result.turnId);
688-
689-
const requests = NodeFS.readFileSync(requestsPath, "utf8")
690-
.trim()
691-
.split("\n")
692-
.map((line) => JSON.parse(line) as { method: string });
693-
assert.deepEqual(
694-
requests.map((request) => request.method),
695-
["turn/start", "thread/compact/start", "turn/start"],
696-
);
697-
698-
yield* runtime.close;
699-
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
700-
);
701-
702657
const elicitationCases = [
703658
{
704659
decision: "accept",

‎apps/server/src/provider/Layers/CodexSessionRuntime.ts‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,21 +2363,7 @@ export const makeCodexSessionRuntime = (
23632363
hasConfiguredMcpServer(options.appServerArgs) &&
23642364
(options.browserToolsAvailable ?? true),
23652365
});
2366-
const rawResponse = yield* client.raw.request("turn/start", params).pipe(
2367-
// The provider rejects oversized serialized turn payloads with HTTP
2368-
// 413 before any model call happens. Compaction shrinks the rollout
2369-
// history on the CLI side, so a single retry after it completes can
2370-
// recover what would otherwise be a dead turn.
2371-
Effect.catchIf(
2372-
(cause) =>
2373-
cause._tag === "CodexAppServerRequestError" && cause.errorMessage.includes("413"),
2374-
() =>
2375-
Effect.gen(function* () {
2376-
yield* client.request("thread/compact/start", { threadId: providerThreadId });
2377-
return yield* client.raw.request("turn/start", params);
2378-
}),
2379-
),
2380-
);
2366+
const rawResponse = yield* client.raw.request("turn/start", params);
23812367
const response = yield* decodeV2TurnStartResponse(rawResponse).pipe(
23822368
Effect.mapError((error) =>
23832369
CodexErrors.CodexAppServerProtocolParseError.fromSchemaError(

‎apps/server/src/provider/testFixtures/codexCollabMockPeer.mjs‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ rl.on("line", (line) => {
6161
write({ id, result: { account: { type: "apiKey" }, requiresOpenaiAuth: false } });
6262
return;
6363
}
64-
if (method === "thread/compact/start") {
65-
if (script.recordRequests) {
66-
NodeFS.appendFileSync(
67-
`${process.env.T3_CODEX_COLLAB_SCRIPT}.requests`,
68-
`${JSON.stringify({ method, params: message.params })}\n`,
69-
);
70-
}
71-
write({ id, result: {} });
72-
return;
73-
}
7464
if (method === "skills/list" || method === "model/list") {
7565
write({ id, result: { data: [] } });
7666
return;
@@ -128,24 +118,6 @@ rl.on("line", (line) => {
128118
return;
129119
}
130120
if (method === "turn/start") {
131-
if (script.recordTurnStartRequests) {
132-
NodeFS.appendFileSync(
133-
`${process.env.T3_CODEX_COLLAB_SCRIPT}.requests`,
134-
`${JSON.stringify({ method, params: message.params })}\n`,
135-
);
136-
}
137-
if (script.turnStart413BeforeSuccess) {
138-
script.turnStart413BeforeSuccess = false;
139-
write({
140-
id,
141-
error: {
142-
code: -32000,
143-
message:
144-
"unexpected status 413 Payload Too Large from http://127.0.0.1:8317/v1/responses",
145-
},
146-
});
147-
return;
148-
}
149121
const turnId = script.turnIds?.[turnStartCount];
150122
const turn = turnId
151123
? { ...fixture.responses.turnStart.turn, id: turnId }

0 commit comments

Comments
 (0)