🤖 fix: use resolved plan file path for tool access #1696
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix: use canonical resolved plan file path in Plan Mode
This fixes a mismatch where Plan Mode instructed the model to use
~/.mux/plans/..., but in dev/test runs mux may resolve~/.muxto a different on-disk directory (e.g.~/.mux-dev). If the model converted the tilde path into an OS-home absolute path, file tools would reject it as “outside the workspace directory”.Changes:
readPlanFile(...).path(canonical resolved path) for:planFilePathValidation:
make typecheckmake static-check📋 Implementation Plan
Fix: Plan Mode plan-file path rejected when using absolute path
Problem
Plan Mode tells the model to read/write a plan file that lives outside the workspace (under mux home). When the model uses an absolute path (e.g.
/Users/.../.mux/plans/...), file tools reject it as “outside the workspace directory”.This happens because the tools only bypass the workspace sandbox for the configured plan file, and the plan file identity check is currently brittle across different “equivalent” plan paths.
Recommended approach (A): Always use the canonical resolved plan path everywhere
Goal: ensure the path shown to the model, the path used by tools (
config.planFilePath), and the path used bypropose_planare all the same canonical absolute path.Changes
aiService.ts, stop using the rawplanFilePathstring built fromruntime.getMuxHome().readPlanFile(...), use the returned canonical resolved path (planResult.path) as:getPlanModeInstruction(...)/getPlanFileHint(...)injectModeTransition(...)(when including plan path)planFilePathingetToolsForModel(...))planFilePathonly where needed for legacy migration logic (if any), but do not expose it to the model or tool config.Why this works
readPlanFile()already callsruntime.resolvePath()and returns a canonical absolute path.file_read,file_edit_*) treatconfig.planFilePathas the single escape hatch to allow access outside the workspace. If we standardize it to the canonical absolute path, the “is this the plan file?” check stays stable, even when the model uses absolute paths.Validation
file_readof the injected plan file path succeeds (or returns ENOENT if missing), without “restricted to workspace” errors.file_edit_insertcan create the plan file.propose_planreads the same file.Net LoC estimate (product code): ~10–20 LoC.
Alternative (B): Make plan-file identity check tolerant to “mux home” aliasing
Instead of changing what path is injected/configured, make
isPlanFilePath()consider both:~/.mux/...(mux home, which may differ in dev)~/.mux/...This reduces user-visible confusion but increases ambiguity (two possible plan files) and can cause
propose_planto read a different file than the model edited.Net LoC estimate (product code): ~20–40 LoC.
Alternative (C): Prompt-only mitigation
Update Plan Mode instructions to explicitly say: “Use the plan file path exactly as provided; do not convert
~to/Users/....”This is easy but relies on model compliance and does not fix the root mismatch.
Net LoC estimate (product code): ~3–6 LoC.
Notes / root cause details
validatePathInCwd()(file tool restriction).isPlanFilePath(targetPath, config)matchesconfig.planFilePath.~/.mux-dev) and some code paths treat~/.muxas an alias for mux home. Models may expand~/.muxto/Users/<name>/.mux, which is not necessarily the same directory mux is using.readPlanFile()removes this ambiguity._Generated with
mux• Model:openai:gpt-5.2• Thinking:xhigh• Cost: $