Skip to content

Commit 714eeb3

Browse files
test(server): reproduce oversized /goal objective failures (#23019)
These tests reproduce issue 23019: an oversized Codex /goal objective reaches thread/goal/get (and could clear a current goal) before the provider rejects it, and the provider's input rejection is recorded as the generic "could not start this turn" startup failure. A 4000 character objective is still sent unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9179178 commit 714eeb3

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { historyResponseItems } from "@t3tools/provider-core/server/handoffBudget";
2+
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
23
import {
34
makeProviderTextDeltaCoalescer,
45
type ProviderTextDeltaUpdate,
@@ -5650,6 +5651,96 @@ describe("CodexAdapterV2 post-settle continuation", () => {
56505651
),
56515652
);
56525653

5654+
it.effect("rejects an oversized /goal objective before any goal request", () =>
5655+
Effect.gen(function* () {
5656+
const oversized = "x".repeat(4001);
5657+
const requests: string[] = [];
5658+
const harness = yield* makeCodexReplayHarness(
5659+
makeCodexReplayTranscript({ scenario: "goal-oversized", entries: sessionStart }),
5660+
() => Effect.void,
5661+
(method) =>
5662+
Effect.sync(() => {
5663+
requests.push(method);
5664+
}),
5665+
);
5666+
const start = yield* harness.runtime
5667+
.startTurn(yield* goalTurnInput(harness, `/goal ${oversized}`))
5668+
.pipe(Effect.result);
5669+
5670+
assert.deepEqual(
5671+
requests.filter((method) => method.startsWith("thread/goal/") || method === "turn/start"),
5672+
[],
5673+
);
5674+
assert.equal(start._tag, "Failure");
5675+
if (start._tag === "Failure") {
5676+
const { message } = makeProviderFailure({ cause: start.failure });
5677+
assert.match(message, /4,?001/u);
5678+
assert.match(message, /4,?000/u);
5679+
}
5680+
}).pipe(
5681+
Effect.scoped,
5682+
Effect.provide(
5683+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
5684+
),
5685+
),
5686+
);
5687+
5688+
it.effect("sends a /goal objective at the 4000 character limit unchanged", () =>
5689+
Effect.gen(function* () {
5690+
const atLimit = "y".repeat(4000);
5691+
const goal = (status: string) => ({ ...codexGoal(status, 0), objective: atLimit });
5692+
const transcript = makeCodexReplayTranscript({
5693+
scenario: "goal-at-limit",
5694+
entries: [
5695+
...sessionStart,
5696+
...request(3, "thread/goal/get", { threadId: nativeThreadId }, { goal: null }),
5697+
...request(
5698+
4,
5699+
"thread/goal/set",
5700+
{ threadId: nativeThreadId, objective: atLimit, status: "paused" },
5701+
{ goal: goal("paused") },
5702+
),
5703+
...withReplayRequestId(
5704+
codexReplayPreamble({
5705+
nativeThreadId,
5706+
nativeTurnId: "goal-turn-limit",
5707+
prompt: atLimit,
5708+
}).slice(5),
5709+
5,
5710+
),
5711+
...request(
5712+
6,
5713+
"thread/goal/set",
5714+
{ threadId: nativeThreadId, status: "active" },
5715+
{ goal: goal("active") },
5716+
),
5717+
notification("goal complete", "thread/goal/updated", {
5718+
threadId: nativeThreadId,
5719+
turnId: "goal-turn-limit",
5720+
goal: goal("complete"),
5721+
}),
5722+
notification("turn done", "turn/completed", {
5723+
threadId: nativeThreadId,
5724+
turn: makeCodexReplayTurn({ id: "goal-turn-limit", status: "completed" }),
5725+
}),
5726+
],
5727+
});
5728+
const harness = yield* makeCodexReplayHarness(transcript);
5729+
yield* harness.runtime.startTurn(yield* goalTurnInput(harness, `/goal ${atLimit}`));
5730+
yield* harness.firstTerminal;
5731+
5732+
assert.deepEqual(
5733+
harness.terminalEvents().map((event) => event.status),
5734+
["completed"],
5735+
);
5736+
}).pipe(
5737+
Effect.scoped,
5738+
Effect.provide(
5739+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
5740+
),
5741+
),
5742+
);
5743+
56535744
it.effect("settles a run held for the next goal turn when Stop arrives in between", () =>
56545745
Effect.gen(function* () {
56555746
const prompt = "Keep going";

‎apps/server/src/orchestration-v2/RunExecutionService.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import * as Layer from "effect/Layer";
3535
import * as Option from "effect/Option";
3636
import * as Ref from "effect/Ref";
3737
import * as Stream from "effect/Stream";
38+
import { CodexAppServerRequestError } from "effect-codex-app-server/errors";
3839

3940
import * as ServerSettings from "../serverSettings.ts";
4041
import * as CheckpointService from "./CheckpointService.ts";
@@ -2487,6 +2488,35 @@ it.effect("refreshes pull requests after a provider stream exits with an error",
24872488
}),
24882489
);
24892490

2491+
it.effect("records a provider's input rejection at turn start in the terminal error", () =>
2492+
Effect.gen(function* () {
2493+
const rejection = "goal objective must be at most 4000 characters";
2494+
const { written, observed } = yield* captureRootRunTermination({
2495+
key: "start-failure:input-rejected",
2496+
shouldFinalizeRun: () => Effect.succeed(true),
2497+
events: () => Stream.never,
2498+
afterStart: (closed) => Deferred.succeed(closed, undefined),
2499+
startTurn: (turnInput) =>
2500+
Effect.fail(
2501+
new ProviderAdapter.ProviderAdapterTurnStartError({
2502+
driver,
2503+
threadId: turnInput.threadId,
2504+
providerThreadId: turnInput.providerThread.id,
2505+
runId: turnInput.runId,
2506+
cause: new CodexAppServerRequestError({
2507+
code: -32600,
2508+
errorMessage: rejection,
2509+
method: "thread/goal/set",
2510+
}),
2511+
}),
2512+
),
2513+
});
2514+
assert.deepEqual(observed, ["run:failed", "pull-requests-refreshed"]);
2515+
const error = written.find((item) => item.type === "error");
2516+
assert.include(error?.failure.message ?? "", rejection);
2517+
}),
2518+
);
2519+
24902520
it.effect("fails the run when its event stream ends without a root terminal", () =>
24912521
Effect.gen(function* () {
24922522
const { observed, finalEvents } = yield* captureRootRunTermination({

0 commit comments

Comments
 (0)