diff --git a/src/app/api/conversations/[threadId]/runs/route.test.ts b/src/app/api/conversations/[threadId]/runs/route.test.ts index 2964cf2..8447564 100644 --- a/src/app/api/conversations/[threadId]/runs/route.test.ts +++ b/src/app/api/conversations/[threadId]/runs/route.test.ts @@ -342,4 +342,53 @@ describe("conversation run route", () => { ); expect(snapshotCreations).toHaveLength(1); }); + + it("forwards generation overrides into the run snapshot request", async () => { + const deployment = scopedDeployment(); + deployment.threadClient.threads.get.mockResolvedValue({ + thread_id: "thread-a", + metadata: { + workspace_scope_id: "00000000-0000-4000-8000-000000000010", + model_selection: { + primary: { provider_id: "zhipu-glm", model_key: "glm-5.2" }, + reasoning_effort: null, + temperature: 1.2, + top_p: 0.5, + }, + model_selection_revision: 3, + }, + }); + mocks.getActiveDeployment.mockResolvedValue(deployment); + + const request = new Request( + "http://localhost/api/conversations/thread-a/runs", + { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + input: { messages: [{ type: "human", content: "hello" }] }, + }), + } + ); + const response = await routes.POST( + request as unknown as NextRequest, + context + ); + expect(response.status).toBe(201); + + const snapshotCall = mocks.configApiFetch.mock.calls.find( + ([, path, options]) => + path === "/api/runtime-snapshots" && + (options as { method?: string })?.method === "POST" + ); + expect(snapshotCall).toBeDefined(); + const body = (snapshotCall![2] as { body: Record }).body; + expect(body).toMatchObject({ + primary: { provider_id: "zhipu-glm", model_key: "glm-5.2" }, + reasoning_effort: null, + temperature: 1.2, + top_p: 0.5, + model_selection_revision: 3, + }); + }); }); diff --git a/src/app/api/conversations/[threadId]/runs/route.ts b/src/app/api/conversations/[threadId]/runs/route.ts index bd76f3e..7fbffea 100644 --- a/src/app/api/conversations/[threadId]/runs/route.ts +++ b/src/app/api/conversations/[threadId]/runs/route.ts @@ -228,6 +228,14 @@ export async function POST(request: NextRequest, context: RouteContext) { selectionRef === "inherit" ? null : (selectionRef.reasoning_effort ?? null), + temperature: + selectionRef === "inherit" + ? null + : (selectionRef.temperature ?? null), + top_p: + selectionRef === "inherit" + ? null + : (selectionRef.top_p ?? null), }, } );