gemini-cli - ✅(Solved) Fix Improve Shell Tool Output: Dynamic Command vs. Description Display [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#24901Fetched 2026-04-09 08:17:41
View on GitHub
Comments
0
Participants
1
Timeline
9
Reactions
0
Participants
Assignees
Timeline (top)
labeled ×3added_to_project_v2 ×1assigned ×1closed ×1

Fix Action

Fixed

PR fix notes

PR #24903: feat(core): refine shell tool description display logic

Description (problem / solution / changelog)

Summary

Refines the ShellTool output logic to dynamically choose between displaying the raw shell command and its natural language description. This provides immediate visual clarity for straightforward routines while leveraging NL descriptions for massive or complex commands.

Details

  • Added a length check (150 characters) to determine whether to prioritize the raw command or the description.
  • Falls back to the raw command if no description is provided by the model.
  • Added comprehensive unit tests in shell.test.ts covering the new branches of the getDescription logic.

Related Issues

Fixes #24901

How to Validate

  1. Check out the branch and run tests: npm test -w @google/gemini-cli-core -- src/tools/shell.test.ts
  2. Start the CLI and run a simple command (e.g., echo "hello"). The output should display the raw command.
  3. Run an artificially long shell command or a massive one-liner. The CLI should display the NL description of the command instead of printing a giant block of shell code.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Changed files

  • packages/core/src/tools/shell.test.ts (modified, +40/-26)
  • packages/core/src/tools/shell.ts (modified, +7/-3)
RAW_BUFFERClick to expand / collapse

What would you like to be added?

Enhance the shell tool output to dynamically choose between displaying the raw shell command and the Natural Language (NL) description based on the complexity of the command.

Specifically:

  • If the shell command is relatively straightforward (e.g., under 150 characters), display the raw shell command to the user.
  • If the shell command is long or complex (e.g., > 150 characters), display the NL description generated by the model instead.
  • If no description is provided, fall back to displaying the raw command.

Why is this needed?

This provides a balanced approach to the CLI output:

  • Raw shell commands are often the most accurate and easily understood representation for simple actions (like mkdir -p foo or npm test).
  • However, for massive one-liners, chained commands, or scripts, a raw command block can be overwhelming and visually clutter the CLI output. In these cases, a succinct NL description (like "Building the application and running tests") is much better for quickly understanding the AI's intent.

Additional context

This has already been implemented and tested in the feature/tool-output/shell-tool-output-update branch.

extent analysis

TL;DR

Implement a conditional statement to dynamically switch between displaying raw shell commands and Natural Language descriptions based on command length.

Guidance

  • Determine the length of the shell command and compare it to the 150-character threshold to decide which output to display.
  • Use the existing implementation in the feature/tool-output/shell-tool-output-update branch as a reference for the conditional logic.
  • Consider adding a fallback mechanism to display the raw command when no NL description is available.
  • Review the branch's test cases to ensure the new behavior covers various command lengths and description availability scenarios.

Example

if len(shell_command) <= 150:
    print(shell_command)
elif nl_description:
    print(nl_description)
else:
    print(shell_command)

Notes

This approach assumes that the complexity of the command is directly related to its length, which might not always be the case. Additional complexity metrics, such as the number of pipes or redirects, could be considered in the future.

Recommendation

Apply workaround by implementing the conditional statement, as the existing implementation in the feature/tool-output/shell-tool-output-update branch can serve as a starting point.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING