From dc02a7520fbe5a500fc08772a48e92af68b9753d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 24 Mar 2026 00:38:48 +0000 Subject: [PATCH] test: stabilize moonshot and minimax live probes --- src/agents/minimax.live.test.ts | 28 ++++++++++++++++++++-------- src/agents/moonshot.live.test.ts | 18 +++++++++++++++++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/agents/minimax.live.test.ts b/src/agents/minimax.live.test.ts index f5697bba205..30c982a791a 100644 --- a/src/agents/minimax.live.test.ts +++ b/src/agents/minimax.live.test.ts @@ -13,6 +13,20 @@ const LIVE = isLiveTestEnabled(["MINIMAX_LIVE_TEST"]); const describeLive = LIVE && MINIMAX_KEY ? describe : describe.skip; +async function runMinimaxTextProbe(model: Model<"anthropic-messages">, maxTokens: number) { + const res = await completeSimple( + model, + { + messages: createSingleUserPromptMessage(), + }, + { apiKey: MINIMAX_KEY, maxTokens }, + ); + return { + res, + text: extractNonEmptyAssistantText(res.content), + }; +} + describeLive("minimax live", () => { it("returns assistant text", async () => { const model: Model<"anthropic-messages"> = { @@ -28,14 +42,12 @@ describeLive("minimax live", () => { contextWindow: 200000, maxTokens: 8192, }; - const res = await completeSimple( - model, - { - messages: createSingleUserPromptMessage(), - }, - { apiKey: MINIMAX_KEY, maxTokens: 64 }, - ); - const text = extractNonEmptyAssistantText(res.content); + let { res, text } = await runMinimaxTextProbe(model, 128); + // MiniMax can spend a small token budget in hidden thinking before it emits + // the visible answer. Give this smoke probe one larger retry. + if (text.length === 0 && res.stopReason === "length") { + ({ text } = await runMinimaxTextProbe(model, 256)); + } expect(text.length).toBeGreaterThan(0); }, 20000); }); diff --git a/src/agents/moonshot.live.test.ts b/src/agents/moonshot.live.test.ts index efa76f82638..e8b1639f00b 100644 --- a/src/agents/moonshot.live.test.ts +++ b/src/agents/moonshot.live.test.ts @@ -13,6 +13,16 @@ const LIVE = isLiveTestEnabled(["MOONSHOT_LIVE_TEST"]); const describeLive = LIVE && MOONSHOT_KEY ? describe : describe.skip; +function forceMoonshotInstantMode(payload: unknown): void { + if (!payload || typeof payload !== "object") { + return; + } + // Moonshot's official API exposes instant mode via thinking.type=disabled. + // Without this, tiny smoke probes can spend the full token budget in hidden + // reasoning_content and never emit visible assistant text. + (payload as Record).thinking = { type: "disabled" }; +} + describeLive("moonshot live", () => { it("returns assistant text", async () => { const model: Model<"openai-completions"> = { @@ -33,7 +43,13 @@ describeLive("moonshot live", () => { { messages: createSingleUserPromptMessage(), }, - { apiKey: MOONSHOT_KEY, maxTokens: 64 }, + { + apiKey: MOONSHOT_KEY, + maxTokens: 64, + onPayload: (payload) => { + forceMoonshotInstantMode(payload); + }, + }, ); const text = extractNonEmptyAssistantText(res.content);