Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ runs:
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.

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


if [[ "${FAILED}" = true ]]; then
LAST_LINE="$(echo "${GEMINI_ERRORS}" | tail -n1)"
echo "::error title=Gemini CLI execution failed::${LAST_LINE}"
Expand Down
Loading