From 7d79cd5e4e9343b8756743a628ff4d4b005de01c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:46:33 +0000 Subject: [PATCH] Test per-call model selection for call.text and call.json Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/workflow.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/workflow.test.ts b/src/workflow.test.ts index 3630483..5d7beaa 100644 --- a/src/workflow.test.ts +++ b/src/workflow.test.ts @@ -217,6 +217,28 @@ describe("dynamic-workflow parity", () => { expect(seen).toEqual([[1, 1, 0], [2, 2, 1], [3, 3, 2]]); }); + it("passes a per-call model to the engine for call.text and call.json — maps to { model: \"sonnet\" }", async () => { + const models: (string | undefined)[] = []; + configureAgent((agentOptions: { model?: string }) => ({ + ask: async (prompt: string) => { + models.push(agentOptions.model); + return prompt.includes("json") ? '{"ok":true}' : '"text"'; + }, + close: async () => {}, + })); + + const definition = workflow({ + meta: { name: "models", description: "per-call model selection" }, + body: async ({ call }) => ({ + text: await call.text("Reply with text.", { model: "claude-haiku-4-5" }), + json: await call.json("Reply with json.", s.object({ ok: s.boolean }), { model: "claude-sonnet-4-5" }), + }), + }); + + await expect(runWorkflow(definition)).resolves.toEqual({ text: "text", json: { ok: true } }); + expect(models).toEqual(["claude-haiku-4-5", "claude-sonnet-4-5"]); + }); + it("records a per-call phase override", async () => { const worker = fakeAgent("echo", (value) => value); const events: WorkflowEvent[] = [];