← Back to PRs

#17135: fix: allow message tool to send files from agent workspace directories

by Limitless2023 open 2026-02-15 13:07 View on GitHub →
channel: telegram gateway scripts commands agents stale size: S
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