mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-18 12:52:25 +03:00
Merged. The failure mode was concrete — a matched reasoning rule dropped on native Responses/Anthropic paths, model-suffix/account defaults, or fallback preparation, and `_omnirouteReasoningRule` leaking upstream as `Unsupported parameter` — and the fix is carried in the request-local credential context through dispatch, refreshed credentials and fallbacks, with forced effort winning over defaults and client-forged markers dropped at ingress. The 11-case integration suite exercises the real routing/translation modules. Validated as a combined board first (this PR merged with the 4 siblings of the JxnLexn wave on the release tip): eslint with the frozen suppressions, typecheck:core, check:open-sse-typecheck, complexity, cognitive-complexity, changelog-integrity, docs-sync, migration-numbering, provider-consistency and a duplicate-identifier audit all green, plus 77 passing / 0 failing focused node:test cases across the test files the wave touches. The wave's i18n fill (new keys carried to all 66 locales), free-tier doc counts and file-size rebaseline land in one follow-up PR right after the wave, as with #13904. Thank you — and for keeping this a runtime-only change with the editor and service-tier work in their own PRs.
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
// Request-local execution metadata, not a provider credential or a wire field.
|
|
// Symbol keys survive credential object spreads but cannot be supplied through JSON.
|
|
const FORCED_EFFORT = Symbol.for("omniroute.forcedReasoningEffort");
|
|
const EFFORTS = new Set(["none", "low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
|
|
export function withReasoningRuleContext<T>(credentials: T, directive: unknown): T {
|
|
if (
|
|
!credentials ||
|
|
typeof credentials !== "object" ||
|
|
!directive ||
|
|
typeof directive !== "object"
|
|
)
|
|
return credentials;
|
|
const rule = directive as Record<string, unknown>;
|
|
if (
|
|
!rule.id ||
|
|
rule.effortMode !== "force" ||
|
|
typeof rule.targetEffort !== "string" ||
|
|
!EFFORTS.has(rule.targetEffort)
|
|
)
|
|
return credentials;
|
|
return { ...credentials, [FORCED_EFFORT]: rule.targetEffort };
|
|
}
|
|
|
|
export function getForcedReasoningEffort(credentials: unknown): string | undefined {
|
|
if (!credentials || typeof credentials !== "object") return undefined;
|
|
return (credentials as { [FORCED_EFFORT]?: string })[FORCED_EFFORT];
|
|
}
|