Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep the OOM analysis message from re-matching its own detector

Adam Eivyc9eefbd4eebb
diff --git a/server/lib/aiToolkit/errorDetection.js b/server/lib/aiToolkit/errorDetection.js
index 231e147fe0..99433adf02 100644
--- a/server/lib/aiToolkit/errorDetection.js
+++ b/server/lib/aiToolkit/errorDetection.js
@@ -513,10 +513,19 @@ export function createTerminalRequestTimeoutDetector({ maxBuffer = 512 } = {}) {
*/
export function detectLocalRuntimeOom(text) {
if (!text) return null;
- const match = String(text).match(LOCAL_RUNTIME_OOM_PATTERN);
- if (!match) return null;
+ // `.test` rather than `.match`: only the yes/no matters, and the pattern
+ // carries no `g` flag, so there is no `lastIndex` to leak between calls.
+ if (!LOCAL_RUNTIME_OOM_PATTERN.test(String(text))) return null;
return {
hasError: true,
+ // A FIXED sentence, deliberately not the vendor text that was matched.
+ // This message becomes the run's error string, which becomes a failure
+ // reason a CoS task description can go on to quote — and a TUI echoes a
+ // pasted prompt back into this very detector. Quoting the vendor constant
+ // here would let the signal re-match its own propagated message and nudge
+ // (then fail) the agent dispatched to investigate it. agy's quota banner
+ // solves the same problem with a lookahead; a fixed message is the simpler
+ // answer when the analysis doesn't need the original text.
category: ERROR_CATEGORIES.RESOURCE_EXHAUSTED,
message: 'Local inference runtime ran out of GPU memory',
waitTime: null,
diff --git a/server/lib/aiToolkit/errorDetection.test.js b/server/lib/aiToolkit/errorDetection.test.js
index a3c69e93e3..e6d4bb8014 100644
--- a/server/lib/aiToolkit/errorDetection.test.js
+++ b/server/lib/aiToolkit/errorDetection.test.js
@@ -575,6 +575,15 @@ describe('Error Detection', () => {
});
});
+ it('reports a message that cannot re-match the detector', () => {
+ // The message becomes the run's error string, which a CoS task
+ // description can quote back — straight into this detector via the TUI's
+ // prompt echo. If it re-matched, the agent dispatched to investigate an
+ // OOM would itself be nudged and failed over.
+ const { message } = detectLocalRuntimeOom(WRAPPED_OOM_BOX);
+ expect(detectLocalRuntimeOom(message)).toBeNull();
+ });
+
it('classifies the same text in a post-hoc output scan', () => {
expect(analyzeError(WRAPPED_OOM_BOX, 1)).toMatchObject({
category: ERROR_CATEGORIES.RESOURCE_EXHAUSTED,