test(background-agent): lock nullish loop detector behavior
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -112,6 +112,20 @@ describe("loop-detector", () => {
|
|||||||
expect(result).toBe("read")
|
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", () => {
|
test("#given tool with empty object input #when signature created #then returns bare tool name", () => {
|
||||||
const result = createToolCallSignature("read", {})
|
const result = createToolCallSignature("read", {})
|
||||||
|
|
||||||
@@ -259,5 +273,24 @@ describe("loop-detector", () => {
|
|||||||
expect(result).toEqual({ triggered: false })
|
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,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user