You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ACP mode does not truncate tool output (truncateToolOutputThreshold ignored); large shell output exceeds the model's input limit #29777
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
Start gemini-cli as an ACP agent (gemini --acp) from any ACP client, with tool approval on auto (yolo).
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.
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
factory-golang: gemini-cli v0.64.0 with ACP tool-output truncation (#…