Hermes Agent "context length exceeded" with large files: what to do
Hermes reports "Context length exceeded" when the conversation no longer fits your model's context window, or when it detected the wrong window. Large files are a common cause: read_file returns up to about 100K characters per call, and a few reads fill the window. Run /compress or start a new session, set model.context_length correctly, and keep big data out of context with execute_code or an MCP server that returns results instead of rows.
What the error means
Hermes's FAQ gives two causes: the conversation has grown too long for the model's context window, or Hermes detected the wrong context length for your model. Check the context limit Hermes prints at startup, or run /usage, and compare it with what your model really supports.
If it's wrong, set it in ~/.hermes/config.yaml under model → context_length (for example 131072). For local models the FAQ's example treats 64,000 as Hermes's minimum.
Immediate fixes
Any of these gets you unstuck:
- /compress summarises the session while keeping key context. The FAQ recommends running it regularly in long sessions.
- hermes chat starts a fresh session when the current one is past saving.
- A model with a larger context window, if your files are routinely big.
Why spreadsheets fill the window so fast
read_file returns up to about 100K characters per call, truncated on a line boundary with a next_offset to continue. That's roughly 25,000 tokens per read. Ask Hermes to "go through" a 30 MB transactions CSV and it will page through it with offset and limit, adding each page to the conversation, until the window is full.
Hermes's own tools reference points at the better pattern: use execute_code to filter and reduce large outputs before they enter your context. Asked to load the file in Python and print only totals, Hermes stays small. The weak spot is parsing: statement exports with a preamble above the header, amounts like ₹1,23,456.00 or (450.00) stored as text, and mixed date formats make quick scripts return wrong totals without any error.
Query large files without loading them
Fileshape Ask AI is a hosted MCP server that does the parsing once. Upload a CSV, Excel or PDF statement (up to 50 MB free, 200 MB on Pro), and Fileshape finds the header row, turns amounts into numbers and dates into YYYY-MM-DD. Hermes then calls aggregate, filter, search and distinct, which compute over every row and return at most 200 rows or 100,000 characters per call, so a single answer can't blow the context window.
Add it to ~/.hermes/config.yaml: mcp_servers → fileshape → url: "https://mcp.fileshape.app/mcp" and auth: oauth. Then, in a new terminal, run hermes mcp login fileshape, and in your session run /reload-mcp. See Hermes Agent and Excel for tool filters and API-key setup on headless servers.
Convert or reshape a file in your browser. Nothing is uploaded.
Open the converterFAQ
Questions
How do I set the context length in Hermes Agent?
In ~/.hermes/config.yaml under model → context_length, set to your model's real context window (for example 131072). Custom endpoints can set it per model under providers.
What does /compress do in Hermes?
It manually compresses the conversation, summarising earlier turns while preserving key context, so the session fits the window again.
How much of a file does read_file return?
About 100K characters per call, truncated on a line boundary, with a next_offset to read the next part.
Will connecting Fileshape use less context?
Yes. Hermes receives only tool results (totals, filtered rows), each capped, instead of pages of raw file content.
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-22