Skip to content

createPathNamespaceCorrectionMiddleware

createPathNamespaceCorrectionMiddleware(appendCorrection): AgentMiddleware<undefined, undefined, unknown, readonly (ClientTool | ServerTool)[], readonly []>

Defined in: _worktrees/docs-release/gaunt-sloth/packages/agent/src/core/GthDeepAgent.ts:800

EXT-22 (S1): the load-bearing path-namespace correction. A gsloth wrapModelCall middleware runs INNERMOST (inside deepagents’ filesystem middleware), so appending a trailing block to request.systemMessage lands AFTER deepagents’ hardcoded “All file paths must start with a /.” line — giving gsloth the last word on path semantics (empirically verified; see handoff/spike-systemmessage-ordering.md). It APPENDS via request.systemMessage.concat(...) (mirroring how deepagents appends its own fs prompt), never string-splices, and returns a NEW request so it never mutates persisted state (no compounding across turns).

appendCorrection gates it to code + virtualMode: only there do the fs virtual / root and the shell’s real-OS paths diverge. On POSIX real-path mode deepagents’ “start with /” is literally true, so the middleware is a transparent pass-through (like the debug-capture middleware when no sink is attached).

boolean

AgentMiddleware<undefined, undefined, unknown, readonly (ClientTool | ServerTool)[], readonly []>