Skip to content

ACP mode does not truncate tool output (truncateToolOutputThreshold ignored); large shell output exceeds the model's input limit #29777

Open

Description

@barney-s

What happened?

When gemini-cli runs as an ACP agent (gemini --acp), a tool's output reaches the model in full, however large it is. tools.truncateToolOutputThreshold (default 40,000 characters) is never applied. A single shell command that prints a lot can therefore push one request past the model's input limit, and the turn fails with:

RPC error [400]: The input token count exceeds the maximum number of tokens allowed 1048576.

The same command in interactive mode or with -p is truncated as documented: the full output is saved to a file, and the model sees the head, the tail and the file's path.

Why

  • The scheduler path applies truncation: packages/core/src/scheduler/tool-executor.ts calls truncateOutputIfNeeded(call, toolResult.llmContent).
  • The ACP path doesn't go through it: packages/cli/src/acp/acpSession.ts calls invocation.execute({ abortSignal }) directly, then records toolResult.llmContent as the function response, untruncated.

Automatic chat compression doesn't catch this either. Before a request, it checks the token count reported by the previous response, which doesn't include the new tool output. So a single large output is sent before compression can run.

Steps to reproduce

  1. Start gemini-cli as an ACP agent (gemini --acp) from any ACP client, with tool approval on auto (yolo).
  2. Prompt the model to run a shell command with a very large output, e.g. seq 1 3000000 (about 20M characters) or a verbose test suite.
  3. The function response sent to the model contains the full output, as the recorded chat session shows. Once that output exceeds the remaining context window, the request fails with the 400 above.

What we observed in practice:

  • A single test command produced about 1.2M characters of output. Context jumped from about 98k to 530k tokens in one turn; compression only ran on the next turn.
  • Another produced about 2.7M characters. The request exceeded 1,048,576 tokens and the turn failed. Retrying fails the same way.

What did you expect to happen?

ACP mode should truncate tool output exactly as the scheduler path does: the same truncateToolOutputThreshold, with the full output saved to a file. The simplest fix is probably for acpSession.ts to use the same truncation helper (or the scheduler's executor) before recording the function response.

Client information

  • gemini-cli 0.64.0 (latest). The same code is present in 0.66.0-nightly.20261016 and on main.
  • Linux, Node 20, model gemini-3.7-flash (1,048,576-token limit), API-key auth.
  • Used as an ACP agent from a custom ACP client, with tool approval on auto.

Activity

  1. added
    status/need-triageIssues that need to be triaged by the triage automation.
    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitystatus/need-triageIssues that need to be triaged by the triage automation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions