Claude's context get's filled up by reading a single file #1960

Closed
opened 2026-02-16 17:33:27 -05:00 by yindo · 14 comments
Owner

Originally created by @vivalareda on GitHub (Oct 5, 2025).

Originally assigned to: @thdxr on GitHub.

https://github.com/user-attachments/assets/a11596d5-2e29-4b20-adba-3e72f5b411af

I don't really know what is going on but after reading a file, the session keeps getting compacted and so claude never actually does the edit. I tried removing all MCP servers but didn't fix it

Originally created by @vivalareda on GitHub (Oct 5, 2025). Originally assigned to: @thdxr on GitHub. https://github.com/user-attachments/assets/a11596d5-2e29-4b20-adba-3e72f5b411af I don't really know what is going on but after reading a file, the session keeps getting compacted and so claude never actually does the edit. I tried removing all MCP servers but didn't fix it
yindo closed this issue 2026-02-16 17:33:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 5, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2945: Session automatically compacted, destroying the entire working context - describes similar behavior where automatic compacting destroys context after reaching limits
  • #2234: compact causes llm to forget convo - reports that compacting causes Claude to forget the conversation and behave like a fresh session
  • #2351: Context counter does not show real context usage - related to inaccurate context tracking which could contribute to unexpected compacting

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 5, 2025): This issue might be a duplicate of existing issues. Please check: - #2945: Session automatically compacted, destroying the entire working context - describes similar behavior where automatic compacting destroys context after reaching limits - #2234: compact causes llm to forget convo - reports that compacting causes Claude to forget the conversation and behave like a fresh session - #2351: Context counter does not show real context usage - related to inaccurate context tracking which could contribute to unexpected compacting Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

@vivalareda how big is that file?

could you maybe share the session?

@rekram1-node commented on GitHub (Oct 5, 2025): @vivalareda how big is that file? could you maybe share the session?
Author
Owner

@vivalareda commented on GitHub (Oct 5, 2025):

@vivalareda how big is that file?

not big at all like 200 lines of code. I have a feeling it's not really realated to the file. On the first run, it does everything correctly and even did edits to that same file but once it compacts once, it just enter that loop and never actually does anything

@vivalareda commented on GitHub (Oct 5, 2025): > [@vivalareda](https://github.com/vivalareda) how big is that file? not big at all like 200 lines of code. I have a feeling it's not really realated to the file. On the first run, it does everything correctly and even did edits to that same file but once it compacts once, it just enter that loop and never actually does anything
Author
Owner

@vivalareda commented on GitHub (Oct 5, 2025):

@vivalareda how big is that file?

could you maybe share the session?

yes here it is, you can see from that whole conversation, barely edit was done
https://opencode.ai/s/BE0cXGOt

@vivalareda commented on GitHub (Oct 5, 2025): > [@vivalareda](https://github.com/vivalareda) how big is that file? > > could you maybe share the session? yes here it is, you can see from that whole conversation, barely edit was done https://opencode.ai/s/BE0cXGOt
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

Hm looks like the session is massive I can't view it it broke the worker lmao

Can you do a opencode export instead? It will dump the session data as json (same data used to populate a share link) but ig it is so big that I cna't see the share link

@rekram1-node commented on GitHub (Oct 5, 2025): Hm looks like the session is massive I can't view it it broke the worker lmao Can you do a `opencode export` instead? It will dump the session data as json (same data used to populate a share link) but ig it is so big that I cna't see the share link
Author
Owner

@vivalareda commented on GitHub (Oct 5, 2025):

opencode export

Image wait that's weird, I still had the tab open and it was working but yeah when I refresh the page it's disappeared. Anyway here's the json data

out.txt

@vivalareda commented on GitHub (Oct 5, 2025): > opencode export <img width="3452" height="2290" alt="Image" src="https://github.com/user-attachments/assets/9e547f14-83c4-4636-981f-b406aef27c9c" /> wait that's weird, I still had the tab open and it was working but yeah when I refresh the page it's disappeared. Anyway here's the json data [out.txt](https://github.com/user-attachments/files/22711738/out.txt)
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

@vivalareda for the export you need to select a session the file you sent me was just:

opencode export [sessionID]

export session data as JSON

Positionals:
  sessionID  session id to export                                       [string]

Options:
      --help        show help                                          [boolean]
  -v, --version     show version number                                [boolean]
      --print-logs  print logs to stderr                               [boolean]
      --log-level   log level
                            [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"]
@rekram1-node commented on GitHub (Oct 5, 2025): @vivalareda for the export you need to select a session the file you sent me was just: ``` opencode export [sessionID] export session data as JSON Positionals: sessionID session id to export [string] Options: --help show help [boolean] -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] ```
Author
Owner

@vivalareda commented on GitHub (Oct 5, 2025):

@vivalareda for the export you need to select a session the file you sent me was just:

opencode export [sessionID]

export session data as JSON

Positionals:
  sessionID  session id to export                                       [string]

Options:
      --help        show help                                          [boolean]
  -v, --version     show version number                                [boolean]
      --print-logs  print logs to stderr                               [boolean]
      --log-level   log level
                            [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"]

ah damn my mistake, do you know how I can pipe it to a file? It's too big for me to copy it all from the output, ghostty or tmux not sure which one it is doesn't let me scroll up to the top

@vivalareda commented on GitHub (Oct 5, 2025): > @vivalareda for the export you need to select a session the file you sent me was just: > ``` > opencode export [sessionID] > > export session data as JSON > > Positionals: > sessionID session id to export [string] > > Options: > --help show help [boolean] > -v, --version show version number [boolean] > --print-logs print logs to stderr [boolean] > --log-level log level > [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] > ``` ah damn my mistake, do you know how I can pipe it to a file? It's too big for me to copy it all from the output, ghostty or tmux not sure which one it is doesn't let me scroll up to the top
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

yeah lemme seee, unfortunately not well suited for piping we should definitely fix that... there has got to be a way tho one sec

@rekram1-node commented on GitHub (Oct 5, 2025): yeah lemme seee, unfortunately not well suited for piping we should definitely fix that... there has got to be a way tho one sec
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

if you interact with the broken session to make it the most recently updated one, then do:

expect -c 'spawn opencode export; expect "Select session to export"; send "\r"; interact' > out.json

that is probably the easiest thing rn, alternatively i could give you command to grab session id and then export normally but this is prolly simpliest

@rekram1-node commented on GitHub (Oct 5, 2025): if you interact with the broken session to make it the most recently updated one, then do: ``` expect -c 'spawn opencode export; expect "Select session to export"; send "\r"; interact' > out.json ``` that is probably the easiest thing rn, alternatively i could give you command to grab session id and then export normally but this is prolly simpliest
Author
Owner

@vivalareda commented on GitHub (Oct 5, 2025):

if you interact with the broken session to make it the most recently updated one, then do:

expect -c 'spawn opencode export; expect "Select session to export"; send "\r"; interact' > out.json

that is probably the easiest thing rn, alternatively i could give you command to grab session id and then export normally but this is prolly simpliest

thanks worked yup thanks!

However file is too big for github I uploaded it to google drive. If you want me to do it another way lmk
https://drive.google.com/file/d/1XaLuKIwvvn-3u6IOCXakwZ_cIe6m3dWX/view?usp=sharing

@vivalareda commented on GitHub (Oct 5, 2025): > if you interact with the broken session to make it the most recently updated one, then do: > > ``` > expect -c 'spawn opencode export; expect "Select session to export"; send "\r"; interact' > out.json > ``` > > that is probably the easiest thing rn, alternatively i could give you command to grab session id and then export normally but this is prolly simpliest thanks worked yup thanks! However file is too big for github I uploaded it to google drive. If you want me to do it another way lmk https://drive.google.com/file/d/1XaLuKIwvvn-3u6IOCXakwZ_cIe6m3dWX/view?usp=sharing
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

That works, what is vibe rules tho? I see a bunch of weird context sent to llm?

Are you writing some AGENTS.md or anything else that would inject a ton of context to system prompt? Your system prompt is over 100k tokens and will most likely degrade llm performance significantly

Excerpt:

provides type-safe versions of common hooks like useParams, useSearch, useRouteContext, useNavigate, useLoaderData, and useLoaderDeps that are pre-bound to a specific route ID and corresponding registered route types.\n\n## RouteApi properties and methods\n\nThe RouteApi has the following properties and methods:\n\n### useMatch method\n\n```tsx\n useMatch<TSelected = TAllContext>(opts?: {\n select?: (match: TAllContext) => TSelected\n }): TS

@rekram1-node commented on GitHub (Oct 5, 2025): That works, what is vibe rules tho? I see a bunch of weird context sent to llm? Are you writing some AGENTS.md or anything else that would inject a ton of context to system prompt? Your system prompt is over 100k tokens and will most likely degrade llm performance significantly Excerpt: > provides type-safe versions of common hooks like `useParams`, `useSearch`, `useRouteContext`, `useNavigate`, `useLoaderData`, and `useLoaderDeps` that are pre-bound to a specific route ID and corresponding registered route types.\n\n## `RouteApi` properties and methods\n\nThe `RouteApi` has the following properties and methods:\n\n### `useMatch` method\n\n```tsx\n useMatch<TSelected = TAllContext>(opts?: {\n select?: (match: TAllContext) => TSelected\n }): TS
Author
Owner

@vivalareda commented on GitHub (Oct 5, 2025):

That works, what is vibe rules tho? I see a bunch of weird context sent to llm?

Are you writing some AGENTS.md or anything else that would inject a ton of context to system prompt? Your system prompt is over 100k tokens and will most likely degrade llm performance significantly

Excerpt:

provides type-safe versions of common hooks like useParams, useSearch, useRouteContext, useNavigate, useLoaderData, and useLoaderDeps that are pre-bound to a specific route ID and corresponding registered route types.\n\n## RouteApi properties and methods\n\nThe RouteApi has the following properties and methods:\n\n### useMatch method\n\n```tsx\n useMatch<TSelected = TAllContext>(opts?: {\n select?: (match: TAllContext) => TSelected\n }): TS

ohhh interesting, it's a tool I saw when reading tanstack router's documentation. I didn't realize it took so much context. I'll have to remove that

Image

@vivalareda commented on GitHub (Oct 5, 2025): > That works, what is vibe rules tho? I see a bunch of weird context sent to llm? > > Are you writing some AGENTS.md or anything else that would inject a ton of context to system prompt? Your system prompt is over 100k tokens and will most likely degrade llm performance significantly > > Excerpt: > > > provides type-safe versions of common hooks like `useParams`, `useSearch`, `useRouteContext`, `useNavigate`, `useLoaderData`, and `useLoaderDeps` that are pre-bound to a specific route ID and corresponding registered route types.\n\n## `RouteApi` properties and methods\n\nThe `RouteApi` has the following properties and methods:\n\n### `useMatch` method\n\n```tsx\n useMatch<TSelected = TAllContext>(opts?: {\n select?: (match: TAllContext) => TSelected\n }): TS ohhh interesting, it's a tool I saw when reading tanstack router's documentation. I didn't realize it took so much context. I'll have to remove that [<img width="1548" height="594" alt="Image" src="https://github.com/user-attachments/assets/dbff24f0-3d4a-4adc-8e74-588d25f3783e" />](https://tanstack.com/router/latest/docs/framework/react/installation#llm-assistance-support)
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

yeah if you remove that it should fix the loop

@rekram1-node commented on GitHub (Oct 5, 2025): yeah if you remove that it should fix the loop
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1960