google-gemini / google-gemini/gemini-cli

Gemini CLI sends large shell output back to the provider

Open
#28,090 2 comments 0 reactions 0 assignees View on GitHub
area/agent kind/bug priority/p1 status/manual-triage
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

## What happened?

A deterministic Gemini-compatible provider can ask Gemini CLI to run a shell command that prints a large output payload, and Gemini CLI sends a tool-result payload far above the expected resource-bound threshold back to the provider.

The standalone reproducer installs public `@google/gemini-cli@0.47.0`, starts a local mock provider, asks for a large shell-output command, and verifies that Gemini CLI forwards a 40319-byte tool result.

## What did you expect to happen?

Gemini CLI should bound, summarize, truncate, or otherwise mediate large tool output before sending it back to the model/provider.

## Client information

```console
Package: @google/gemini-cli
Affected version checked locally: 0.47.0
Current npm latest checked on 2026-06-22: 0.47.0
Upstream repository: https://github.com/google-gemini/gemini-cli
Platform: Linux x86_64 in Docker (node:24-bookworm)
Interface: CLI
```

## Login information

API key flow against a local Gemini-compatible mock endpoint. The reproduction uses a fake API key and makes no live Gemini request.

## Anything else we need to know?

**Standalone reproduction**

Prerequisites: Docker, Python 3, and the GitHub CLI (`gh`) for the clone command below. The linked reproducer is self-contained and uses only Python standard-library modules plus Docker. It builds the affected CLI version from the public npm package and starts a local mock provider; it does not require this repository or any private fuzzing harness. The Docker run is limited to 2 CPUs and 4 GiB RAM by default.

Complete self-contained reproducer: https://gist.github.com/N0zoM1z0/1ed81a6deb8488925e67fcc64a53a67c

The Gist contains `gemini-cli-huge-stdout-resource-bound.reproduce.py`. Download and run:

```bash
gh gist clone 1ed81a6deb8488925e67fcc64a53a67c gemini-cli-huge-stdout-resource-bound-reproducer
cd gemini-cli-huge-stdout-resource-bound-reproducer
python3 gemini-cli-huge-stdout-resource-bound.reproduce.py
```

To reuse an already-built local image:

```bash
python3 gemini-cli-huge-stdout-resource-bound.reproduce.py --skip-build
```

Key output from a local run against the affected version:

```text
provider_requests_at_least: observed=2 expected>=2
tool_result_bytes_at_least: observed=40319 expected>=8192
REPRODUCED
```

**Steps to reproduce**

Run the standalone reproducer above.

**Actual behavior**

Gemini CLI forwards a large shell-output tool result to the provider. The public reproducer observes a 40319-byte tool-result payload, above the 8192-byte resource-bound threshold used for this class.

**Expected behavior**

Gemini CLI should bound large local tool output before returning it to the provider.

**Public-upstream status**

This report targets stock public `@google/gemini-cli@0.47.0`, which is the current npm latest checked on 2026-06-22. This is separate from the already filed duplicate tool-result issue because it is an output/resource-pressure class.

Contributor guide

Open the contributing guide

Research direction

Start by running gemini-cli-huge-stdout-resource-bound.reproduce.py against the affected package to confirm the 40319-byte tool result. Trace the shell tool-result handling in the Gemini CLI; done means large local output is mediated before the provider request and the reproducer no longer observes a result above the 8192-byte threshold.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.