Skip to content

Do not output more than 2000 lines in commands and file reads #1556

Closed

Description

@remorses

One of the reasons Claude Code works so well is that it prevents tool calls from eating up all your context window. All tool calls fail if the output size is longer than 2000 lines or 25k tokens. This way the LLM will repeat the commands and file reads to constrain output size, using for example head -n command

Claude Code also uses an LLM to summarize fetch results, adding a field in the fetch tool for the objective of the fetch call

Activity

  1. self-assigned this
    on Aug 3, 2025
  2. thdxr commented on Aug 3, 2025

    @thdxr
    Member

    hm we should be doing this also - is this specifically with the bash tool that it's a problem?

  3. remorses commented on Aug 4, 2025

    @remorses
    ContributorAuthor

    Yes, bash tool output should be truncated (show last 2000 lines), trying to read a file too long should return an error message, so the LLM can try again and paginate it via line numbers

  4. DiogoDoreto commented on Aug 4, 2025

    @DiogoDoreto

    I've faced this problem too, but in my case with some web searches. Sometimes the model calls the web tool and I've seen my context going straight to 300k tokens when the limit of my model is 128k.

  5. thdxr commented on Aug 12, 2025

    @thdxr
    Member

    fixed this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions