-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: exec workdir with leading ~ falls back and still executes command #94434
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
execdoes not expand a leading~inworkdir, then falls back to another directory and still executes the command, causing relative commands to run from the wrong location.Steps to reproduce
Start OpenClaw 2026.6.8.
Trigger an agent/tool call equivalent to:
{ "workdir": "~/<workspace>/skills/example", "command": "./scripts/run.py" }Observe that
workdiris treated literally, reported unavailable, and the command is run from a fallback directory.Expected behavior
For an explicit invalid
workdir, OpenClaw should either:~/~/consistently with other user-facing path inputs, orActual behavior
The tool emits a warning and still executes the command from the fallback directory:
OpenClaw version
2026.6.8
Operating system
Ubuntu 24.04.4 LTS
Install method
npm global, running as a systemd user service
Model
Observed after an Ollama cloud model emitted the tool call, but the behavior is in the exec tool runtime after the structured tool arguments are produced.
Provider / routing chain
OpenClaw -> configured model provider -> OpenClaw exec tool
Additional provider/model setup details
Provider likely not relevant. The issue is reproducible from the structured exec arguments once a model emits
workdirwith a leading~.Logs, screenshots, and evidence
Redacted example:
Local package comparison showed the same
resolveWorkdir()behavior in several recent published versions, so this does not appear to be a newly introduced regression in 2026.6.8.Impact and severity
Affected: Agent runs that use structured
exec.workdirwith a leading~.Severity: Medium. It can break scheduled or isolated runs and make the real failure non-obvious.
Frequency: Intermittent; depends on whether the model chooses
workdir: "~..."instead ofcd ~/...inside the shell command.Consequence: Relative commands fail from the fallback directory, and recovery depends on the model noticing and correcting the path.
Additional information
This does not require full shell expansion. Full shell expansion in structured fields may be undesirable.
The safer request is either:
workdiris invalid instead of executing from a fallback directory.The main concern is the silent fallback: an invalid explicit
workdircan cause commands to execute from a different directory than intended.