summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/http.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/http.test.ts')
-rw-r--r--packages/cli/src/http.test.ts74
1 files changed, 73 insertions, 1 deletions
diff --git a/packages/cli/src/http.test.ts b/packages/cli/src/http.test.ts
index becfdbb..180ea98 100644
--- a/packages/cli/src/http.test.ts
+++ b/packages/cli/src/http.test.ts
@@ -1,4 +1,4 @@
-import type { AgentEvent } from "@dispatch/transport-contract";
+import type { AgentEvent, ChatRequest } from "@dispatch/transport-contract";
import { describe, expect, it } from "vitest";
import { fetchModels, streamChat } from "./http.js";
@@ -135,6 +135,78 @@ describe("streamChat", () => {
),
).rejects.toThrow("no body");
});
+
+ it("includes reasoningEffort in request body when set", async () => {
+ let capturedBody: string | undefined;
+ const doneEvent: AgentEvent = {
+ type: "done",
+ conversationId: "c",
+ turnId: "t",
+ reason: "completed",
+ };
+ const fakeFetch = async (
+ _url: string | URL | Request,
+ init?: RequestInit,
+ ): Promise<Response> => {
+ capturedBody = init?.body as string;
+ const encoder = new TextEncoder();
+ const stream = new ReadableStream<Uint8Array>({
+ pull(controller) {
+ controller.enqueue(encoder.encode(`${JSON.stringify(doneEvent)}\n`));
+ controller.close();
+ },
+ });
+ return new Response(stream, { status: 200 });
+ };
+
+ await streamChat(
+ { fetchImpl: fakeFetch as unknown as typeof fetch },
+ {
+ server: "http://localhost:24203",
+ request: { message: "hi", reasoningEffort: "xhigh" },
+ },
+ );
+
+ expect(capturedBody).toBeDefined();
+ const parsed = JSON.parse(capturedBody as string) as ChatRequest;
+ expect(parsed.reasoningEffort).toBe("xhigh");
+ });
+
+ it("omits reasoningEffort from request body when not set", async () => {
+ let capturedBody: string | undefined;
+ const doneEvent: AgentEvent = {
+ type: "done",
+ conversationId: "c",
+ turnId: "t",
+ reason: "completed",
+ };
+ const fakeFetch = async (
+ _url: string | URL | Request,
+ init?: RequestInit,
+ ): Promise<Response> => {
+ capturedBody = init?.body as string;
+ const encoder = new TextEncoder();
+ const stream = new ReadableStream<Uint8Array>({
+ pull(controller) {
+ controller.enqueue(encoder.encode(`${JSON.stringify(doneEvent)}\n`));
+ controller.close();
+ },
+ });
+ return new Response(stream, { status: 200 });
+ };
+
+ await streamChat(
+ { fetchImpl: fakeFetch as unknown as typeof fetch },
+ {
+ server: "http://localhost:24203",
+ request: { message: "hi" },
+ },
+ );
+
+ expect(capturedBody).toBeDefined();
+ const parsed = JSON.parse(capturedBody as string) as ChatRequest;
+ expect(parsed).not.toHaveProperty("reasoningEffort");
+ });
});
describe("fetchModels", () => {