[GH-ISSUE #2019] [Bug] Claude Code context window #670

Closed
opened 2026-10-15 18:27:14 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @DwarfishRex on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/2019

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

MCP or agent integration

Observed behavior

This may or may not be a valid bug, but the context window almost instantly gets filled by the MCP using 120% of the context causing it to spam compact which stops the model "● Autocompact is thrashing: the context refilled to the limit within 3 turns of the previous compact, 3 times in a row. A file being read or a tool output is likely too large for the context window. Try reading in smaller chunks, or use /clear to start fresh."

Reproduction

  1. Follow install
  2. use deepseek-v4-flash (only tested on that model)
  3. make it use the mcp and check usage /context

Expected behavior

● Autocompact is thrashing: the context refilled to the limit within 3 turns of the previous compact, 3 times in a row. A file being read or a tool output is likely too large for the context window. Try reading in smaller chunks, or use /clear to start fresh. after a while should happen

Impact and scope

Agent is affected

REA version

6.4

Runtime and platform

Node 26.7

Target and artifact context

No response

Interface

MCP

Earliest failure stage

Unknown

Relevant output or evidence


Typed outcome or recovery expected

No response

Analysis or suspected cause

No response

Additional context

No response

Originally created by @DwarfishRex on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/2019 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area MCP or agent integration ### Observed behavior This may or may not be a valid bug, but the context window almost instantly gets filled by the MCP using 120% of the context causing it to spam compact which stops the model "● Autocompact is thrashing: the context refilled to the limit within 3 turns of the previous compact, 3 times in a row. A file being read or a tool output is likely too large for the context window. Try reading in smaller chunks, or use /clear to start fresh." ### Reproduction 1. Follow install 2. use deepseek-v4-flash (only tested on that model) 3. make it use the mcp and check usage /context ### Expected behavior ● Autocompact is thrashing: the context refilled to the limit within 3 turns of the previous compact, 3 times in a row. A file being read or a tool output is likely too large for the context window. Try reading in smaller chunks, or use /clear to start fresh. after a while should happen ### Impact and scope Agent is affected ### REA version 6.4 ### Runtime and platform Node 26.7 ### Target and artifact context _No response_ ### Interface MCP ### Earliest failure stage Unknown ### Relevant output or evidence ```text ``` ### Typed outcome or recovery expected _No response_ ### Analysis or suspected cause _No response_ ### Additional context _No response_
bsakaguchi 2026-10-15 18:27:14 +00:00
  • closed this issue
  • added the
    triage
    bug
    labels
Author
Owner

@kaoru0822-kitauji commented on GitHub (Oct 12, 2026):

I couldn't reproduce this directly because I don't have a deepseek-v4-flash setup for Claude Code. I did measure what REA advertises to a client at startup. The likely cause is the size of REA's tool catalog when every tool definition is loaded into the model's context up front.

Measured through stdio MCP tools/list on current main (04089d5be), 172 tools:

profile names + descriptions + input schemas output schemas whole tools/list
default (full) 520,286 bytes 1,796,065 bytes 2,316,351 bytes
REA_MCP_INPUT_SCHEMA_PROFILE=compact 314,278 bytes 1,796,065 bytes 2,110,343 bytes

The model-facing part is the first column, the tool names, descriptions and input schemas. At typical JSON tokenization that is on the order of 100k+ tokens in the default profile. It can exceed a model's whole window before any analysis output arrives. That would produce exactly "refilled to the limit within 3 turns of the previous compact". The cause would be the tool definitions themselves, not a large tool result.

Two things would confirm or rule this out:

  1. Your /context breakdown right after starting a session with REA enabled, before calling any tool. Does the MCP tools line account for most of the usage?
  2. Whether Claude Code defers MCP tool definitions (tool search) with your endpoint. If tool definitions are loaded eagerly for this provider, the whole catalog counts against the window on every turn.

Possible mitigations today:

  • Set REA_MCP_INPUT_SCHEMA_PROFILE=compact in the server env. It cuts the model-facing size by about 40% but does not make the catalog small.
  • Use a larger-context model, or a client configuration that defers MCP tool loading.

Related work on catalog size under bounded context: #1065 and #1554, and open PR #1669 (operator tool selection). I'm leaving the fix to that work rather than guessing at one here.

<!-- gh-comment-id:6116982666 --> @kaoru0822-kitauji commented on GitHub (Oct 12, 2026): I couldn't reproduce this directly because I don't have a deepseek-v4-flash setup for Claude Code. I did measure what REA advertises to a client at startup. The likely cause is the size of REA's tool catalog when every tool definition is loaded into the model's context up front. Measured through stdio MCP `tools/list` on current main (04089d5be), 172 tools: | profile | names + descriptions + input schemas | output schemas | whole `tools/list` | | --- | ---: | ---: | ---: | | default (`full`) | 520,286 bytes | 1,796,065 bytes | 2,316,351 bytes | | `REA_MCP_INPUT_SCHEMA_PROFILE=compact` | 314,278 bytes | 1,796,065 bytes | 2,110,343 bytes | The model-facing part is the first column, the tool names, descriptions and input schemas. At typical JSON tokenization that is on the order of 100k+ tokens in the default profile. It can exceed a model's whole window before any analysis output arrives. That would produce exactly "refilled to the limit within 3 turns of the previous compact". The cause would be the tool definitions themselves, not a large tool result. Two things would confirm or rule this out: 1. Your `/context` breakdown right after starting a session with REA enabled, before calling any tool. Does the MCP tools line account for most of the usage? 2. Whether Claude Code defers MCP tool definitions (tool search) with your endpoint. If tool definitions are loaded eagerly for this provider, the whole catalog counts against the window on every turn. Possible mitigations today: - Set `REA_MCP_INPUT_SCHEMA_PROFILE=compact` in the server env. It cuts the model-facing size by about 40% but does not make the catalog small. - Use a larger-context model, or a client configuration that defers MCP tool loading. Related work on catalog size under bounded context: #1065 and #1554, and open PR #1669 (operator tool selection). I'm leaving the fix to that work rather than guessing at one here.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#670
No description provided.