Skip to content

Commit aec89d0

Browse files
authored
feat(workflows): add maxSessionTurns to all workflows (#62)
This commit introduces the `maxSessionTurns` setting to all Gemini CLI workflows, providing granular control over the conversation length for each use case. This enhancement allows for more tailored and efficient interactions with the Gemini assistant, preventing runaway conversations and ensuring that the AI's focus remains on the specific task at hand. The following changes are included in this commit: - **`maxSessionTurns` added to all workflows:** Each of the three primary workflows (issue triage, pull request review, and the general CLI) now has a `maxSessionTurns` value configured in its corresponding workflow file. These values have been set to reasonable defaults for each use case: - Issue Triage: 25 - Pull Request Review: 20 - General CLI: 50 - **Documentation updated:** The `workflows/README.md` file has been updated to include a new "Configuration" section that explains how to use the `maxSessionTurns` setting. This documentation provides a clear example of how to modify the setting and links to the comprehensive Gemini CLI documentation for more information. By providing this level of control, we empower users to fine-tune the behavior of the Gemini CLI to better suit their specific needs and preferences, leading to a more efficient and effective AI-assisted workflow.
1 parent 66fd7fd commit aec89d0

10 files changed

Lines changed: 61 additions & 18 deletions

.github/workflows/gemini-cli.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ jobs:
184184
with:
185185
settings: |
186186
{
187+
"maxSessionTurns": 50,
187188
"coreTools": [
188189
"run_shell_command(echo)",
189190
"run_shell_command(gh pr view)",

.github/workflows/gemini-issue-automated-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
with:
7777
settings: |-
7878
{
79+
"maxSessionTurns": 25,
7980
"coreTools": [
8081
"run_shell_command(gh label list)",
8182
"run_shell_command(gh issue edit)"

.github/workflows/gemini-issue-scheduled-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
with:
8585
settings: |-
8686
{
87+
"maxSessionTurns": 25,
8788
"coreTools": [
8889
"run_shell_command(echo)",
8990
"run_shell_command(gh label list)",

.github/workflows/gemini-pr-review.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ jobs:
163163
with:
164164
settings: |-
165165
{
166+
"maxSessionTurns": 20,
166167
"coreTools": [
167168
"run_shell_command(echo)",
168169
"run_shell_command(gh pr view)",

README.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ environment variables, and secrets.
7575

7676
Set the following environment variables in your repository or workflow:
7777

78-
| Name | Description | Type | Required | When Required |
79-
|---------------------------|---------------------------------------------------------------------------------------------|----------|----------|------------------------------|
80-
| GEMINI_CLI_VERSION | Controls which version of the Gemini CLI is installed. Supports `npm` versions (e.g., `0.1.0`, `latest`), a branch name (e.g., `main`), or a commit hash. | Variable | No | To pin or override the CLI version |
81-
| GCP_WIF_PROVIDER | Full resource name of the Workload Identity Provider. | Variable | No | When using observability |
82-
| OTLP_GOOGLE_CLOUD_PROJECT | Google Cloud project for telemetry. | Variable | No | When using observability |
83-
| GOOGLE_CLOUD_PROJECT | Google Cloud project for Vertex AI authentication. | Variable | No | When using Vertex AI authentication |
84-
| GOOGLE_CLOUD_LOCATION | Geographic location of the Google Cloud project for Vertex AI authentication. | Variable | No | When using Vertex AI authentication |
85-
| GOOGLE_GENAI_USE_VERTEXAI | Set to 'true' to use Vertex AI | Variable | No | When using Vertex AI authentication |
86-
| APP_ID | GitHub App ID for custom authentication. | Variable | No | When using a custom GitHub App |
78+
| Name | Description | Type | Required | When Required |
79+
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------------------------------- |
80+
| GEMINI_CLI_VERSION | Controls which version of the Gemini CLI is installed. Supports `npm` versions (e.g., `0.1.0`, `latest`), a branch name (e.g., `main`), or a commit hash. | Variable | No | To pin or override the CLI version |
81+
| GCP_WIF_PROVIDER | Full resource name of the Workload Identity Provider. | Variable | No | When using observability |
82+
| OTLP_GOOGLE_CLOUD_PROJECT | Google Cloud project for telemetry. | Variable | No | When using observability |
83+
| GOOGLE_CLOUD_PROJECT | Google Cloud project for Vertex AI authentication. | Variable | No | When using Vertex AI authentication |
84+
| GOOGLE_CLOUD_LOCATION | Geographic location of the Google Cloud project for Vertex AI authentication. | Variable | No | When using Vertex AI authentication |
85+
| GOOGLE_GENAI_USE_VERTEXAI | Set to 'true' to use Vertex AI | Variable | No | When using Vertex AI authentication |
86+
| APP_ID | GitHub App ID for custom authentication. | Variable | No | When using a custom GitHub App |
8787

8888

8989
To add an environment variable: 1) Go to your repository's **Settings > Secrets and
@@ -95,10 +95,10 @@ For organization-wide or environment-specific variables, refer to the
9595

9696
The following secrets are required for security:
9797

98-
| Name | Description | Required | When Required |
99-
|-------------------|-----------------------------------------------|----------|-----------------------------------------------------------|
100-
| GEMINI_API_KEY | Your Gemini API key from Google AI Studio. | No | If you are using the Gemini API key from Google AI Studio |
101-
| APP_PRIVATE_KEY | Private key for your GitHub App (PEM format). | No | If you are using a custom GitHub App |
98+
| Name | Description | Required | When Required |
99+
| --------------- | --------------------------------------------- | -------- | --------------------------------------------------------- |
100+
| GEMINI_API_KEY | Your Gemini API key from Google AI Studio. | No | If you are using the Gemini API key from Google AI Studio |
101+
| APP_PRIVATE_KEY | Private key for your GitHub App (PEM format). | No | If you are using a custom GitHub App |
102102

103103
To add a secret, go to your repository's **Settings > Secrets and variables >
104104
Actions > New repository secret**. For more information, refer to the
@@ -137,11 +137,6 @@ AI assistant within the pull requests and issues to perform a wide range of
137137
tasks. For a detailed guide on how to set up the [Gemini CLI], go to the Generic
138138
[Gemini CLI workflow documentation](./workflows/gemini-cli).
139139

140-
You can configure the [`maxSessionTurns`](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/configuration.md#available-settings-in-settingsjson)
141-
when running the Gemini CLI in the workflow's YAML configuration file if you want to restrict
142-
the maximum number of session turns for each of the `yolo` Gemini CLI runs. In the 'Run Gemini' step ,
143-
you can configure the `maxSessionTurns` in the settings.
144-
145140
## Authentication
146141

147142
This action requires a GitHub token to interact with the GitHub API. You can

workflows/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
This directory contains a collection of example workflows that demonstrate how to use the [Google Gemini CLI GitHub Action](https://github.com/google-github-actions/run-gemini-cli). These workflows are designed to be reusable and customizable for your own projects.
44

5+
- [Gemini CLI Workflows](#gemini-cli-workflows)
6+
- [Available Workflows](#available-workflows)
7+
- [Configuration](#configuration)
8+
- [Workflows](#workflows)
9+
- [Timeouts](#timeouts)
10+
- [Settings](#settings)
11+
- [`maxSessionTurns`](#maxsessionturns)
12+
- [Contributing](#contributing)
13+
14+
515
## Available Workflows
616

717
* **[Issue Triage](./issue-triage)**: Automatically triage GitHub issues using Gemini. This workflow can be configured to run on a schedule or be triggered by issue events.
@@ -24,6 +34,36 @@ jobs:
2434
timeout-minutes: 10
2535
```
2636
37+
### Settings
38+
39+
You can customize the behavior of the Gemini CLI by modifying the `settings` input in your workflow files.
40+
41+
For more information on all available settings, please see the [Gemini CLI documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/configuration.md#available-settings-in-settingsjson).
42+
43+
#### `maxSessionTurns`
44+
45+
This setting controls the maximum number of turns in a conversation.
46+
47+
**Defaults:**
48+
49+
The default `maxSessionTurns` for each workflow is as follows:
50+
51+
| Workflow | Default `maxSessionTurns` |
52+
| ---------------------------------- | ------------------------- |
53+
| [Issue Triage](./issue-triage) | 25 |
54+
| [Pull Request Review](./pr-review) | 20 |
55+
| [Gemini CLI](./gemini-cli) | 50 |
56+
57+
**Example:**
58+
59+
```yaml
60+
with:
61+
settings: |
62+
{
63+
"maxSessionTurns": 10
64+
}
65+
```
66+
2767
## Contributing
2868

2969
We encourage you to contribute to this collection of workflows! If you have a workflow that you would like to share with the community, please open a pull request.

workflows/gemini-cli/gemini-cli.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ jobs:
184184
with:
185185
settings: |
186186
{
187+
"maxSessionTurns": 50,
187188
"coreTools": [
188189
"run_shell_command(echo)",
189190
"run_shell_command(gh pr view)",

workflows/issue-triage/gemini-issue-automated-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
with:
7777
settings: |-
7878
{
79+
"maxSessionTurns": 25,
7980
"coreTools": [
8081
"run_shell_command(gh label list)",
8182
"run_shell_command(gh issue edit)"

workflows/issue-triage/gemini-issue-scheduled-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
with:
8585
settings: |-
8686
{
87+
"maxSessionTurns": 25,
8788
"coreTools": [
8889
"run_shell_command(echo)",
8990
"run_shell_command(gh label list)",

workflows/pr-review/gemini-pr-review.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ jobs:
162162
with:
163163
settings: |-
164164
{
165+
"maxSessionTurns": 20,
165166
"coreTools": [
166167
"run_shell_command(echo)",
167168
"run_shell_command(gh pr view)",

0 commit comments

Comments
 (0)