#17135: fix: allow message tool to send files from agent workspace directories
channel: telegram
gateway
scripts
commands
agents
stale
size: S
Cluster:
Media Handling Improvements
Fixes #17133
## Problem
The `message` tool fails to send file attachments when the file resides in an agent-specific workspace directory (e.g., `~/.openclaw/workspace-clawdy/`). The error is:
```
Local media path is not under an allowed directory
```
## Root Cause
`getDefaultLocalRoots()` only includes `~/.openclaw/workspace`, but agent workspaces are sibling directories (`workspace-<agentId>`). The `image` tool handles this correctly by adding the agent's `workspaceDir` to `localRoots`, but `message` tool did not.
## Solution
Pass `workspaceDir` through the call chain:
1. `MessageToolOptions.workspaceDir`
2. `RunMessageActionParams.workspaceDir`
3. `normalizeSandboxMediaParams` - checks workspaceDir as fallback for relative paths
## Impact
- Agents can now send file attachments from their own workspace directories
- Consistent behavior with image tool
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds `workspaceDir` parameter to the `message` tool's call chain to enable file attachments from agent-specific workspace directories (e.g., `~/.openclaw/workspace-clawdy/`), bringing it in line with the `image` tool's behavior.
**Main changes:**
- Threads `workspaceDir` through `MessageToolOptions` → `RunMessageActionParams` → `normalizeSandboxMediaParams`
- Updates `normalizeSandboxMediaParams` to try `workspaceDir` as a fallback for relative paths when `sandboxRoot` doesn't match
**Additional unrelated fixes in this PR:**
- Filters out invalid session store entries (empty/invalid `sessionFile` paths)
- Defaults Control UI and webchat to `operator.read` scope when token auth provides no scopes
- Adds `.catch(() => undefined)` to gateway health check in status command
- Persists `responseUsage` setting across session resets
- Transcribes voice messages in Telegram DMs so agents receive text instead of raw audio
**Critical issues:**
- Two blocking bugs were previously identified and remain unaddressed: temporal dead zone error in `bot-message-context.ts:401` and missing try/catch wrapper in `message-action-params.ts:243` that prevents the `workspaceDir` fallback from working for absolute paths.
<h3>Confidence Score: 1/5</h3>
- This PR has two critical runtime errors that will break functionality
- The previously reported bugs are confirmed: `preflightTranscript` is used before declaration (runtime error), and the `sandboxRoot` block throws exceptions that bypass the `workspaceDir` fallback (breaking the main fix). These are blocking issues.
- Pay close attention to `src/telegram/bot-message-context.ts` and `src/infra/outbound/message-action-params.ts` - both contain critical bugs that must be fixed
<sub>Last reviewed commit: bc7ebd2</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20294: fix(message): thread mediaLocalRoots through channel plugin dispatch
by odrobnik · 2026-02-18
82.2%
#20488: fix(discord): pass mediaLocalRoots to sendMessageDiscord
by olyashok · 2026-02-19
75.9%
#21132: fix: allow message(action='read') in isolated/cron sessions + add H...
by matt-bedda · 2026-02-19
73.2%
#19171: fix(feishu): pass mediaLocalRoots to sendMediaFeishu for agent-scop...
by whiskyboy · 2026-02-17
73.2%
#22401: fix: resolve relative media paths against workspace and fix /tmp on...
by derrickburns · 2026-02-21
72.8%
#23085: fix(workspace): respect OPENCLAW_STATE_DIR for workspace paths, fix...
by charojo · 2026-02-22
72.5%
#19325: feat: support messages.mediaLocalRoots for custom media directories
by deggertsen · 2026-02-17
72.5%
#20186: fix(discord): thread mediaLocalRoots through reply delivery path
by pvoo · 2026-02-18
72.5%
#16922: fix: remove incorrect sandbox file tool guidance
by carrotRakko · 2026-02-15
72.5%
#20336: fix(sessions): resolve transcriptPath using agentId when storePath ...
by Limitless2023 · 2026-02-18
72.2%