Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(mock): identify streamed interactive turns

Steven Enamakelac2d4ea6072f
diff --git a/scripts/mock-api/routes/llm.mjs b/scripts/mock-api/routes/llm.mjs
index d911621202..bab97c750d 100644
--- a/scripts/mock-api/routes/llm.mjs
+++ b/scripts/mock-api/routes/llm.mjs
@@ -18,20 +18,26 @@ import {
// Older harnesses advertised tools in the OpenAI request. Current harnesses
// render that same catalogue in the stable system prompt to preserve the
// provider's prompt-cache prefix, and deliberately omit the duplicate request
-// field. Ancillary completions that share the endpoint but carry neither form
-// of catalogue — thread-title/summary generation via `chat_with_system`, fired
-// fire-and-forget and racing the visible turn — must not drain the queue, or
-// scripted responses desynchronise and the turn falls through to the dynamic
-// fallback (tinyhumansai/openhuman#4517).
+// field. Interactive turns also stream a user message, unlike the ancillary
+// non-streaming completions (thread-title/summary generation via
+// `chat_with_system`) that race them. Those helpers must not drain the queue,
+// or scripted responses desynchronise and the turn falls through to the
+// dynamic fallback (tinyhumansai/openhuman#4517).
function isPrimaryTurn(parsedBody) {
if (Array.isArray(parsedBody?.tools) && parsedBody.tools.length > 0) return true;
- return (parsedBody?.messages ?? []).some(
+ const hasRenderedCatalogue = (parsedBody?.messages ?? []).some(
message =>
(message?.role === "system" || message?.role === "developer") &&
typeof message?.content === "string" &&
message.content.includes("## Tools")
);
+ if (hasRenderedCatalogue) return true;
+
+ return (
+ parsedBody?.stream === true &&
+ (parsedBody?.messages ?? []).some(message => message?.role === "user")
+ );
}
function requestRuleMatches(rule, ctx) {