Skip to content

fix(agent, cli): Gemini bugfixes, add fallback if pty isn't available - #1123

Merged
ddupont808 merged 4 commits into
mainfrom
ddupont/ci-bugfixes
Feb 26, 2026
Merged

fix(agent, cli): Gemini bugfixes, add fallback if pty isn't available#1123
ddupont808 merged 4 commits into
mainfrom
ddupont/ci-bugfixes

Conversation

@ddupont808

@ddupont808 ddupont808 commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error resilience in AI model response handling when critical data is missing or incomplete.
    • Shell command execution now automatically falls back to non-interactive mode when interactive mode is unavailable, ensuring commands continue to function properly.

@vercel

vercel Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 26, 2026 2:52pm

Request Review

@ddupont808 ddupont808 changed the title fix(agent, cli): CI bugfixes, add fallback if pty isn't available fix(agent, cli): Gemini bugfixes, add fallback if pty isn't available Feb 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Publishable packages changed

  • pypi/agent
  • pypi/cli

Add release:<service> labels to auto-release on merge (+ optional bump:minor or bump:major, default is patch).
Or add no-release to skip.

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes strengthen resilience in Gemini response parsing with guarded candidate and parts extraction, early returns for missing data, and expanded browser action name support; and introduce graceful PTY fallback to non-interactive execution when remote PTY initialization fails.

Changes

Cohort / File(s) Summary
Gemini Response Resilience
libs/python/agent/agent/loops/gemini.py
Replaced direct candidate/parts access with guarded retrieval, added early returns for missing data, enhanced function_call extraction with safe attribute access, and expanded browser action mapping to support both "open_web_browser" and "open_browser" names.
PTY Fallback Mechanism
libs/python/cua-cli/cua_cli/commands/do.py
Added _PtyUnavailable exception class; modified _shell_remote_pty to raise this exception on PTY creation failure; updated _cmd_shell to catch the exception and gracefully fallback to non-interactive run_command execution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through code so fine,
With guards and catches in each line,
When Gemini speaks without a sound,
Or PTY fails on shaky ground,
We fall back gracefully, bounce around!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: Gemini bugfixes in the agent module and a PTY fallback mechanism in the CLI, matching the actual changeset content.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ddupont/ci-bugfixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sentry

sentry Bot commented Feb 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libs/python/agent/agent/loops/gemini.py 0.00% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libs/python/agent/agent/loops/gemini.py`:
- Around line 840-842: The long chained getattr that builds _dbg_parts is
causing Black to fail; break the expression into smaller, Black-friendly
statements by first assigning _dbg_candidates = getattr(response, "candidates",
None) or [], then compute candidate = _dbg_candidates[0] if _dbg_candidates else
None, then content = getattr(candidate, "content", None), and finally set
_dbg_parts = getattr(content, "parts", None) or []; keep the subsequent for p in
_dbg_parts loop unchanged so the logic remains identical but formatted across
multiple lines for Black compatibility.

In `@libs/python/cua-cli/cua_cli/commands/do.py`:
- Around line 1466-1468: When catching _PtyUnavailable, handle the case where
command is empty by invoking the interactive fallback instead of
_cmd_shell_noninteractive; specifically, check if command is falsy in the except
block and call the interactive handler (e.g., _cmd_shell_interactive(...)) with
the same args, otherwise call _cmd_shell_noninteractive(command, args);
reference _PtyUnavailable, command, args, _cmd_shell_noninteractive and
_cmd_shell_interactive to locate and update the except block.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e21930 and cfe3802.

📒 Files selected for processing (2)
  • libs/python/agent/agent/loops/gemini.py
  • libs/python/cua-cli/cua_cli/commands/do.py

Comment thread libs/python/agent/agent/loops/gemini.py
Comment thread libs/python/cua-cli/cua_cli/commands/do.py
@github-actions

Copy link
Copy Markdown
Contributor

📦 Publishable packages changed

  • pypi/agent
  • pypi/cli

Add release:<service> labels to auto-release on merge (+ optional bump:minor or bump:major, default is patch).
Or add no-release to skip.

@ddupont808
ddupont808 merged commit 2036aa1 into main Feb 26, 2026
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant