Skip to content

[Bug]: tools/sandbox: MEDIA_MAX_BYTES (5 MB) is hardcoded and not user-configurable #40880

@lijihua2017

Description

@lijihua2017

Bug type

Regression (worked before, now fails)

Summary

Bug Description

The sandbox media staging limit is hardcoded at 5 MB in dist/store-*.js:

const MEDIA_MAX_BYTES = 5 * 1024 * 1024;

Files larger than 5 MB (e.g. large PDFs, PowerPoint files, images) cannot be
copied into the sandbox container and silently fail or are rejected.

This constant has been hardcoded since at least v2026.3.7 and is still present
in v2026.3.8.
Expected Behavior
MEDIA_MAX_BYTES should be user-configurable via openclaw.json, for example:
{
"tools": {
"media": {
"maxBytes": 524288000
}
}
}

The existing tools.media.image.maxBytes and tools.media.audio.maxBytes
per-type config keys suggest the infrastructure already supports per-type limits,
but there is no way to override the sandbox staging cap that applies before
the per-type check.

### Steps to reproduce

Configure a sandboxed agent (sandbox.mode: "non-main")
Send a file larger than 5 MB (e.g. a 10 MB PDF or PPTX)
Observe the file is rejected / not available inside the sandbox

### Expected behavior

MEDIA_MAX_BYTES should be user-configurable via openclaw.json, for example:
{
"tools": {
"media": {
"maxBytes": 524288000
}
}
}

The existing tools.media.image.maxBytes and tools.media.audio.maxBytes
per-type config keys suggest the infrastructure already supports per-type limits,
but there is no way to override the sandbox staging cap that applies before
the per-type check.

Steps to Reproduce
Configure a sandboxed agent (sandbox.mode: "non-main")
Send a file larger than 5 MB (e.g. a 10 MB PDF or PPTX)
Observe the file is rejected / not available inside the sandbox
Workaround
Manually patch dist/store-*.js after every npm install -g openclaw update:
sed -i 's/const MEDIA_MAX_BYTES = 5 \* 1024 \* 1024/const MEDIA_MAX_BYTES = 500 * 1024 * 1024/' \
$(find $(npm root -g)/openclaw/dist -name "store-*.js")
openclaw gateway restart

### Actual behavior

Files larger than 5 MB (e.g. large PDFs, PowerPoint files, images) cannot be
copied into the sandbox container and silently fail or are rejected.

This constant has been hardcoded since at least v2026.3.7 and is still present
in v2026.3.8.

### OpenClaw version

2026.3.8

### Operating system

ubuntu 24

### Install method

npm

### Logs, screenshots, and evidence

```shell

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper 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:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.regressionBehavior that previously worked and now fails

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions