diegosouzapw/OmniRoute · error · Error
Could not create HyperAgent thread
Error message
Could not create HyperAgent thread (HTTP ${res2.status}). Ensure the session Cookie is valid and not expired. What it means
Terminal failure in createHyperAgentThread: thread creation did not yield a thread id — no usable Location/x-middleware-rewrite header, non-2xx/3xx status, and no thread id matchable in the response body. As the message states, the usual cause is an invalid or expired session cookie for the HyperAgent web session.
Solutions
- Refresh/re-authenticate the HyperAgent session cookie stored for the connection
- Retry once — occasional transient failures occur during thread creation
- Mark the connection unavailable (cooldown) so account selection rotates to a fresh session
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at open-sse/executors/hyperagent.ts:572 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/fb1f0bc7eda4c57e.
Report an issue: GitHub.
Appendix: source
Thrown at open-sse/executors/hyperagent.ts:572
}),
signal: signal ?? undefined,
redirect: "manual",
});
const loc2 =
res2.headers.get("location") ||
res2.headers.get("Location") ||
res2.headers.get("x-middleware-rewrite") ||
"";
const fromLoc2 = extractThreadIdFromUrl(loc2);
if (fromLoc2) return fromLoc2;
if (res2.status >= 200 && res2.status < 400) {
const text = await res2.text().catch(() => "");
const m = text.match(/\/thread\/(cm[a-z0-9]{20,})/i) || text.match(/"(cm[a-z0-9]{20,})"/i);
if (m) return m[1]!;
}
throw new Error(
`Could not create HyperAgent thread (HTTP ${res2.status}). Ensure the session Cookie is valid and not expired.`
);
}
/**
* Apply model + execution settings on a thread (live SPA does this before chat).
*
* - modelId: wire id (e.g. fable-latest — NOT bare "fable")
* - defaultSubagentModel: short family (fable|opus|sonnet|haiku) matching selected model
* - executionMode: "auto" (only non-null value accepted live)
* - runtimeId: claude-agents-sdk for Claude family
*
* Chat body must NOT carry modelId (API returns model_unknown for bare pricing keys).
*/
export async function configureHyperAgentThread(
cookie: string,
threadId: string,
opts: {View on GitHub (pinned to a179ffed5b)