Skip to content

feat(workflow): mark workloads as failed if they hit session limit#206

Closed
leehagoodjames wants to merge 1 commit intogoogle-github-actions:mainfrom
leehagoodjames:issue_205
Closed

feat(workflow): mark workloads as failed if they hit session limit#206
leehagoodjames wants to merge 1 commit intogoogle-github-actions:mainfrom
leehagoodjames:issue_205

Conversation

@leehagoodjames
Copy link
Copy Markdown
Contributor

Fixes: #205

Copy link
Copy Markdown
Contributor

@jerop jerop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would we need such error handling for other fatal errors? is there a way to generalize this to other fatal errors?

Comment thread action.yml
echo "${GEMINI_ERRORS}" >> "${GITHUB_OUTPUT}"
echo "EOF" >> "${GITHUB_OUTPUT}"

if echo "${GEMINI_ERRORS}" | grep -q "Reached max session turns for this session"; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the error message"Reached max session turns for this session" changes, then this stops working, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is correct. I see two approaches:

  1. Hitting the maxSessionTurns limit causes gemini-cli to exit with a specific error code
  • Pros
    • Very easy to parse downstream
  • Cons
    • Likely not appropriate for all gemini-cli invocations
  1. (Current behavior) Hitting the maxSessionTurns limit causes gemini-cli to exit with a 0.
  • Pros
    • Does not build into gemini-cli the assumption that hitting the maxSessionTurns indicates that the workload failed
  • Cons
    • Difficult for clients to reliably determine if the maxSessionTurns limit was hit, as checking the output errors requires fragile string matching

Does gemini-cli currently support any type of output that enumerates the possible reasons for ending ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better for the gemini-cli to publish specific exit codes for these kinds of things, no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@gemini-cli gemini-cli Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR adds a check to explicitly fail the action when the session turn limit is reached. This is a good improvement to the action's error handling.

🔍 General Feedback

  • The approach of checking the error message is a bit brittle, but given the current limitations, it's a reasonable solution.
  • The code is clear and easy to understand.
  • I've added one inline comment with a suggestion for improvement.

Comment thread action.yml

if echo "${GEMINI_ERRORS}" | grep -q "Reached max session turns for this session"; then
FAILED=true
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Using `grep` for this check is a bit fragile. If the error message changes slightly in the future, this check will fail. A more robust approach would be to use a dedicated output from the CLI to indicate this specific error condition.

Since we don't have that, we can at least make the grep more specific to avoid accidentally matching other error messages.

Suggested change
fi
if echo "${GEMINI_ERRORS}" | grep -q "Reached max session turns for this session"; then
echo "::error title=Max session turns reached::The Gemini CLI session has reached its maximum number of turns and cannot continue."
FAILED=true
fi

@jerop
Copy link
Copy Markdown
Contributor

jerop commented Aug 21, 2025

@gemini-cli /review how can we improve the prompt?

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli Bot commented Aug 21, 2025

🤖 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.

@jerop
Copy link
Copy Markdown
Contributor

jerop commented Aug 21, 2025

fyi above workflow failed because the PR is from a fork: #167

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli Bot commented Aug 21, 2025

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

@jerop
Copy link
Copy Markdown
Contributor

jerop commented Sep 15, 2025

Closed in favor of using error codes: #217

@jerop jerop closed this Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support handling when maxSessionTurns causes early exit

3 participants