GeezerVison is showing github.com — test(server): reproduce oversized /goal objective failures (#23019) · pingdotgg/t3code@714eeb3
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/orchestration-v2
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts +91Lines changed: 91 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { historyResponseItems } from "@t3tools/provider-core/server/handoffBudget"; | | 2 | +import { makeProviderFailure } from "@t3tools/provider-core/server/failure"; | 2 | 3 | import { | 3 | 4 | makeProviderTextDeltaCoalescer, | 4 | 5 | type ProviderTextDeltaUpdate, | @@ -5650,6 +5651,96 @@ describe("CodexAdapterV2 post-settle continuation", () => { | 5650 | 5651 | ), | 5651 | 5652 | ); | 5652 | 5653 |
| | 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 | + | 5653 | 5744 | it.effect("settles a run held for the next goal turn when Stop arrives in between", () => | 5654 | 5745 | Effect.gen(function* () { | 5655 | 5746 | const prompt = "Keep going"; | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/RunExecutionService.test.ts +30Lines changed: 30 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,6 +35,7 @@ import * as Layer from "effect/Layer"; | 35 | 35 | import * as Option from "effect/Option"; | 36 | 36 | import * as Ref from "effect/Ref"; | 37 | 37 | import * as Stream from "effect/Stream"; | | 38 | +import { CodexAppServerRequestError } from "effect-codex-app-server/errors"; | 38 | 39 |
| 39 | 40 | import * as ServerSettings from "../serverSettings.ts"; | 40 | 41 | import * as CheckpointService from "./CheckpointService.ts"; | @@ -2487,6 +2488,35 @@ it.effect("refreshes pull requests after a provider stream exits with an error", | 2487 | 2488 | }), | 2488 | 2489 | ); | 2489 | 2490 |
| | 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 | + | 2490 | 2520 | it.effect("fails the run when its event stream ends without a root terminal", () => | 2491 | 2521 | Effect.gen(function* () { | 2492 | 2522 | const { observed, finalEvents } = yield* captureRootRunTermination({ | |
|