fix(write-existing-file-guard): defer realpath/existsSync to first tool call

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-18 14:11:03 +09:00
parent a6e3c6a5ed
commit a4c45e2770
3 changed files with 15 additions and 6 deletions
@@ -90,10 +90,10 @@ export async function handleWriteExistingFileGuardToolExecuteBefore(params: {
output: { args?: unknown }
readPermissionsBySession: Map<string, Set<string>>
sessionLastAccess: Map<string, number>
canonicalSessionRoot: string
getCanonicalSessionRoot: () => string
maxTrackedSessions: number
}): Promise<void> {
const { ctx, input, output, readPermissionsBySession, sessionLastAccess, canonicalSessionRoot, maxTrackedSessions } = params
const { ctx, input, output, readPermissionsBySession, sessionLastAccess, getCanonicalSessionRoot, maxTrackedSessions } = params
const toolName = input.tool?.toLowerCase()
if (toolName !== "write" && toolName !== "read") {
return
@@ -107,6 +107,7 @@ export async function handleWriteExistingFileGuardToolExecuteBefore(params: {
}
const resolvedPath = resolveInputPath(ctx, filePath)
const canonicalSessionRoot = getCanonicalSessionRoot()
const canonicalPath = toCanonicalPath(resolvedPath)
if (!isPathInsideDirectory(canonicalPath, canonicalSessionRoot)) {
return