Skip to content

Commit 8f30225

Browse files
committed
test(workflow): cover oversized structured results
1 parent 4b0802f commit 8f30225

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

src/workflow-engine.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,50 @@ import { createStubBudget, WORKFLOW_LIMITS } from "./workflow-types.js";
413413
await rm(dir, { recursive: true, force: true });
414414
}
415415

416+
// ---------------------------------------------------------------------------
417+
// oversized structured results remain intact without persisting invalid JSON
418+
// ---------------------------------------------------------------------------
419+
{
420+
const dir = await mkdtemp(join(tmpdir(), "wf-structured-size-"));
421+
const store = new WorkflowStore(dir);
422+
const run = store.createRun({
423+
name: "structured-size",
424+
source: "inline",
425+
scriptPath: "inline",
426+
scriptHash: "h",
427+
workspaceRoot: dir,
428+
});
429+
const big = "x".repeat(WORKFLOW_LIMITS.structuredJsonBytes + 1);
430+
const api = createWorkflowApi({
431+
runId: run.id,
432+
journal: store,
433+
meta: { name: "structured-size", description: "d" },
434+
args: undefined,
435+
concurrency: 1,
436+
signal: new AbortController().signal,
437+
workspaceRoot: dir,
438+
enabledProviders: ["codex"],
439+
runProvider: async () => ({
440+
finalResponse: JSON.stringify({ big }),
441+
structured: { big },
442+
}),
443+
});
444+
445+
assert.deepEqual(
446+
await api.agent("large structured", {
447+
schema: {
448+
type: "object",
449+
properties: { big: { type: "string" } },
450+
required: ["big"],
451+
},
452+
}),
453+
{ big },
454+
);
455+
assert.equal(store.getAgentCall(run.id, 0)?.structuredJson, undefined);
456+
store.close();
457+
await rm(dir, { recursive: true, force: true });
458+
}
459+
416460
// ---------------------------------------------------------------------------
417461
// executeWorkflow end-to-end with sandbox + nest depth
418462
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)