Keep shadow-test failures from retrying successful production work

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Celekli
2026-10-02 14:21:49 -04:00
parent d3f71c4bb8
commit 8ecb75e241
@@ -58,7 +58,14 @@ export async function optimizeAndRoute(
// Background Self-Learning: Asynchronously test the output
// against a cheaper model to see if we can optimize later.
shadowTestAgainstAlternative(serviceTask, result, getCheapestProvider(providers));
// Shadow failures must not enter the production retry/circuit-breaker path.
// Deferring the call also captures synchronous adapter failures.
void Promise.resolve()
.then(() => shadowTestAgainstAlternative(
serviceTask, result, getCheapestProvider(providers)))
.catch((error) => {
console.error('Shadow evaluation failed', error);
});
return result;