OpenClaw and large files: how to stop context overflow
OpenClaw's context is bounded by your model's context window. When a large file's contents land in the conversation, OpenClaw hits a context-overflow error, compacts older turns and retries, and the agent loses detail. Keep large data out of context: have the agent compute in a script that prints only results, enable session pruning, or connect the file through an MCP server that returns totals instead of rows.
Getting the file in: channel size caps
Each channel caps inbound media with mediaMaxMb. WhatsApp defaults to 50 MB; OpenClaw's Telegram and Discord examples use 100; iMessage uses 16 and needs includeAttachments turned on. Raise the cap in your channel config if a big export is refused. A file that downloads fine can still be far too big for the model.
Why large files overflow the context window
Everything OpenClaw sends the model for a run, from instructions and history to every tool result, has to fit in the model's context window. A 40 MB CSV is tens of millions of tokens, and even printing a few thousand rows to "take a look" can fill a large window.
When the model returns a context-overflow error, OpenClaw compacts: older turns are summarised into one entry, the most recent messages (about 20,000 tokens by default) are kept, and the request is retried. Your session keeps going, but the summary drops detail, often the exact numbers the agent read earlier. You can also compact by hand with /compact, optionally with a focus such as /compact keep the column names and totals.
Turn on session pruning
OpenClaw's own advice for frequent compaction is that tool outputs may be large and you should try session pruning. With agents.defaults.contextPruning.mode set to cache-ttl, old tool results over 4,000 characters are cut to their first and last 1,500 characters, and very old ones are replaced with a placeholder. Pruning is off by default for non-Anthropic providers.
Pruning helps the session survive, but the data the agent pruned is gone from its view. It treats the symptom, not the cause.
Keep the data out of context entirely
The fix is to let something else hold the rows. One option is to tell your claw to load the file in a script and print only aggregates, never raw rows. That works if the agent remembers every time, and if it parses the file correctly: export headers that start on row 5, amounts with commas or brackets and mixed date formats trip up quick scripts.
The other is an MCP server. Fileshape Ask AI holds a cleaned copy of your file (up to 50 MB free, 200 MB on Pro) and gives OpenClaw tools like aggregate, filter and search. A question like "refunds per month" comes back as twelve numbers computed over every row. Every call is capped (at most 200 rows and 100,000 characters), so one tool call can't flood the context and trigger compaction.
- Upload the file at fileshape.app/account/datasets.
- Where your gateway runs: openclaw mcp set fileshape '{"url":"https://mcp.fileshape.app/mcp","transport":"streamable-http","auth":"oauth"}'
- Run openclaw mcp login fileshape and sign in, then check with openclaw mcp doctor fileshape --probe.
- Ask your claw: "Using Fileshape, how many orders shipped late each week?"
Convert or reshape a file in your browser. Nothing is uploaded.
Open the converterFAQ
Questions
What does context overflow mean in OpenClaw?
The request no longer fits the model's context window. OpenClaw compacts older turns into a summary and retries, so the session continues with less detail.
How do I compact an OpenClaw session manually?
Send /compact, optionally followed by what to focus on, for example /compact keep the column names and totals.
How big a file can I send to OpenClaw?
Each channel's mediaMaxMb decides: 50 MB by default on WhatsApp, configurable on Telegram, Discord and others. Fitting the contents into the model's context is the tighter limit.
Does Fileshape send my whole file to the model?
No. The model only receives tool results, capped per call. Masked columns show as XXXX1234 and hidden columns are never uploaded.
More from the blog
Keep reading
- AI for data analysis: which tool to use, and how to trust the answersThe three ways to use AI for data analysis (chat uploads, spreadsheet add-ins, connected agents), which fits which job, and how to check the numbers.
- How to upload files to ChatGPT and Claude, and share them with any AIUpload a file to ChatGPT or Claude, fix uploads that fail, and share the same files with every AI app through one URL instead of re-uploading.
- Is it safe to upload a bank statement to ChatGPT or Claude?What ChatGPT and Claude keep when you upload a bank statement, the settings that stop training on it, and how to share only the columns the AI needs.
- Bank statement analysis with ChatGPT or Claude: prompts that get the numbers rightCopy-paste prompts for analysing a bank or card statement in ChatGPT or Claude, plus how to prepare the file so the totals come out right.
Updated 2026-11-21