fix: permission checks for external_directory and doom_loop (#4433)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: AerionDyseti <AerionDyseti@users.noreply.github.com>
This commit is contained in:
K Whiteside
2025-11-18 17:18:23 -06:00
committed by GitHub
parent 52cf9e3423
commit 47bfae52c0
6 changed files with 62 additions and 1 deletions

View File

@@ -136,6 +136,7 @@ export namespace SessionProcessor {
const parts = await MessageV2.parts(input.assistantMessage.id)
const lastThree = parts.slice(-DOOM_LOOP_THRESHOLD)
if (
lastThree.length === DOOM_LOOP_THRESHOLD &&
lastThree.every(
@@ -160,6 +161,17 @@ export namespace SessionProcessor {
input: value.input,
},
})
} else if (permission.doom_loop === "deny") {
throw new Permission.RejectedError(
input.assistantMessage.sessionID,
"doom_loop",
value.toolCallId,
{
tool: value.toolName,
input: value.input,
},
`You seem to be stuck in a doom loop, please stop repeating the same action`,
)
}
}
}