From 4de02094ab1a35f873ec7857f364fe67f50b7f23 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 12 Apr 2026 00:42:25 +0900 Subject: [PATCH] test(background-agent): lock nullish loop detector behavior Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../background-agent/loop-detector.test.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/features/background-agent/loop-detector.test.ts b/src/features/background-agent/loop-detector.test.ts index f3f85d2c1..a35307818 100644 --- a/src/features/background-agent/loop-detector.test.ts +++ b/src/features/background-agent/loop-detector.test.ts @@ -112,6 +112,20 @@ describe("loop-detector", () => { expect(result).toBe("read") }) + test("#given nullish inputs #when signatures are created #then null and undefined behave the same", () => { + // given + const undefinedInput = undefined + const nullInput = null + + // when + const undefinedResult = createToolCallSignature("read", undefinedInput) + const nullResult = createToolCallSignature("read", nullInput) + + // then + expect(undefinedResult).toBe("read") + expect(nullResult).toBe(undefinedResult) + }) + test("#given tool with empty object input #when signature created #then returns bare tool name", () => { const result = createToolCallSignature("read", {}) @@ -259,5 +273,24 @@ describe("loop-detector", () => { expect(result).toEqual({ triggered: false }) }) }) + + describe("#given nullish tool inputs", () => { + test("#when recorded #then null and undefined produce the same unknown-input window", () => { + // given + const settings = resolveCircuitBreakerSettings() + + // when + const undefinedWindow = recordToolCall(undefined, "read", settings, undefined) + const nullWindow = recordToolCall(undefined, "read", settings, null) + + // then + expect(undefinedWindow).toEqual(nullWindow) + expect(undefinedWindow).toEqual({ + lastSignature: "read::__unknown-input__", + consecutiveCount: 1, + threshold: settings.consecutiveThreshold, + }) + }) + }) }) })