Skip to content

System prompt explicitly instructs model to use excluded SHELL_TOOL_NAME in headless mode #17469

@LyalinDotCom

Description

@LyalinDotCom

What happened?

I ran the following command to check file counts in headless mode:
gemini -p "how many files in this folder"

The model immediately failed with Tool "run_shell_command" not found in registry.

I found that while the shell tool is correctly excluded from the registry in headless mode, prompts.ts still hardcodes instructions to use it:

  • Line 292: Lists '${SHELL_TOOL_NAME}' in primaryWorkflows_suffix.
  • Line 364: Explicitly instructs: - **Command Execution:** Use the '${SHELL_TOOL_NAME}' tool...

The model is simply following the system prompt instructions, but crashes because the tool schema is missing.

What did you expect to happen?

The system prompt should not reference or instruct the use of tools that are not in the current registry.

Suggested Fix:
Make shell-related instructions in prompts.ts conditional on the tool's availability.

const shellInstructions = config.getToolRegistry().getTool(SHELL_TOOL_NAME) 
  ? `- **Command Execution:** Use the '${SHELL_TOOL_NAME}' tool...` 
  : '';

Client information

│ About Gemini CLI │
│ │
│ CLI Version 0.22.5 │
│ Git Commit 8daf2d3
│ Model gemini-3-pro-preview │
│ Sandbox no sandbox │
│ OS darwin │
│ Auth Method OAuth

Login information

OAuth

Anything else we need to know?

Note while this did not reproduce every time, based on my quick analysis it seems like a real bug worth fixing.

Update: I actually was able to reproduce it again, does not always happen but now 3x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/non-interactiveIssues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automationstatus/need-triageIssues that need to be triaged by the triage automation.

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions