Skip to content

run_shell_command fails in CI: Redirects (>>) force "ASK_USER" downgrade, blocking execution #435

Closed

Description

@trntlg

TL;DR

I am running the Gemini CLI Action in a GitHub Actions workflow. When the model attempts to use run_shell_command to append to a file (specifically writing to $GITHUB_ENV using >>), the Policy Engine automatically downgrades the decision from ALLOW to ASK_USER.

Expected behavior

The Policy Engine should allow file redirection (> or >>) when running in a CI environment, especially when the target file is a known GitHub environment file (like $GITHUB_ENV or $GITHUB_OUTPUT). Alternatively, there should be a configuration option to disable this specific safety check for CI workflows where user interaction is impossible.

Observed behavior

Steps to Reproduce

  1. Create a workflow that uses google-github-actions/run-gemini-cli.
  2. Prompt the model to perform a task that requires setting an output or environment variable (e.g., "Triage this issue and save the labels to the environment").
  3. The model attempts to run a shell command like:
    1 echo "SELECTED_LABELS=bug" >> "/home/runner/work/_temp/_runner_file_commands/set_env_..."
  4. The action fails with a policy error.

Action YAML

- name: 'Run Gemini issue analysis'
        id: 'gemini_analysis'
        if: |-
          ${{ steps.get_labels.outputs.available_labels != '' }}
        uses: 'google-github-actions/run-gemini-cli@v0' # ratchet:exclude
        env:
          GITHUB_TOKEN: '' # Do NOT pass any auth tokens here since this runs on untrusted inputs
          ISSUE_TITLE: '${{ github.event.issue.title }}'
          ISSUE_BODY: '${{ github.event.issue.body }}'
          AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
        with:
          gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
          gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
          gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
          gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
          gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
          gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}'
          gemini_debug: '${{ fromJSON(vars.GEMINI_DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}'
          gemini_model: 'gemini-2.5-flash-lite'
          google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
          use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
          use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
          upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
          workflow_name: 'gemini-triage'
          settings: |-
            {
              "model": {
                "maxSessionTurns": 25
              },
              "telemetry": {
                "enabled": true,
                "target": "local",
                "outfile": ".gemini/telemetry.log"
              },
              "tools": {
                "core": [
                  "run_shell_command(echo)"
                ]
              }
            }
          prompt: '/gemini-triage'

Log output

[MESSAGE_BUS] publish: {"type":"tool-confirmation-request","toolCall":{"name":"run_shell_command","args":{"command":"echo \"SELECTED_LABELS=help wanted\" >> \"/home/runner/work/_temp/_runner_file_commands/set_env_f3cd4c...0\"","description":"Append selected labels to the GitHub environment file."}},"correlationId":"f04c5e29-7f57-4a..."}
[PolicyEngine.check] toolCall.name: run_shell_command, stringifiedArgs: undefined
[PolicyEngine.check] MATCHED rule: toolName=undefined, decision=allow, priority=1.999, argsPattern=none
[PolicyEngine.check] Validating shell command: 1 parts
[PolicyEngine.check] Downgrading ALLOW to ASK_USER for redirected command: echo "SELECTED_LABELS=help wanted" >> "/home/runner/work/_temp/_runner_file_commands/set_env_f3cd4..."
Error executing tool run_shell_command: Tool execution for "Shell" denied by policy.
{
  "session_id": "b1...1",
  "response": "I'm sorry, but I cannot execute that command as it is a security risk. I am unable to set environment variables using the `echo` command as it may lead to unintended consequences.",
  "stats": {
    "models": {
      "gemini-2.5-flash-lite": {
        "api": {
          "totalRequests": 2,
          "totalErrors": 0,
          "totalLatencyMs": 4819
        },
        "tokens": {
          "input": 12462,
          "prompt": 23362,
          "candidates": 129,
          "total": 24182,
          "cached": 10900,
          "thoughts": 691,
          "tool": 0
        }
      }
    },
    "tools": {
      "totalCalls": 1,
      "totalSuccess": 0,
      "totalFail": 1,
      "totalDurationMs": 5,
      "totalDecisions": {
        "accept": 0,
        "reject": 0,
        "modify": 0,
        "auto_accept": 0
      },
      "byName": {
        "run_shell_command": {
          "count": 1,
          "success": 0,
          "fail": 1,
          "durationMs": 5,
          "decisions": {
            "accept": 0,
            "reject": 0,
            "modify": 0,
            "auto_accept": 0
          }
        }
      }
    },
    "files": {
      "totalLinesAdded": 0,
      "totalLinesRemoved": 0
    }
  }
}OpenTelemetry SDK shut down successfully.
::: End Gemini CLI STDOUT :::
Warning: Gemini CLI output was not valid JSON

Additional information

Prompt Context (TOML)
The /gemini-triage command includes instructions to write to the environment file:

Steps

1. Review the issue title, issue body, and available labels provided above.

2. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.

3. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.

4. Use the "echo" shell command to append the CSV labels to the output file path provided above:

    ```
    echo "SELECTED_LABELS=[APPROPRIATE_LABELS_AS_CSV]" >> "[filepath_for_env]"
    ```

    for example:

    ```
    echo "SELECTED_LABELS=bug,enhancement" >> "/tmp/runner/env"
    ```

Activity

  1. gemini-cli commented on Jan 6, 2026

    @gemini-cli
    Contributor

    🤖 Hi @trntlg, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

  2. gemini-cli commented on Jan 6, 2026

    @gemini-cli
    Contributor

    🤖 I'm sorry @trntlg, but I was unable to process your request. Please see the logs for more details.

  3. trntlg commented on Jan 6, 2026

    @trntlg
    Author

    ok, it does not work here also.

  4. jerop commented on Jan 8, 2026

    @jerop
    Contributor

    @MJjainam pointed out that we have a shortlist of env vars in https://github.com/google-gemini/gemini-cli/pull/15160/changes, and that SELECTED_LABELS needs to be added to the list

    Another approach could be to make the list configurable by the user -- or we update these workflows to have GEMINI_CLI_ prefix

  5. jerop commented on Jan 8, 2026

    @jerop
    Contributor
  6. jerop commented on Jan 14, 2026

    @jerop
    Contributor

    @gemini-cli /triage

  7. gemini-cli commented on Jan 14, 2026

    @gemini-cli
    Contributor

    🤖 Hi @jerop, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

  8. jerop commented on Jan 14, 2026

    @jerop
    Contributor

    Fixed in google-gemini/gemini-cli#16183, in stable and preview releases

  9. added this to the v0.1.19 milestone on Jan 14, 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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions