gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

feat(hooks): add has_pending_tool_calls to AfterAgent hook payload

Open RyderFreeman4Logos opened this issue 1 year ago • 1 comments

This change introduces a new boolean field, has_pending_tool_calls, to the AfterAgent hook input.

Fix #14596

Rationale: The AfterAgent hook fires at the end of every agent turn. Previously, it was impossible for hooks to distinguish between:

  1. The agent pausing to execute a tool (e.g., run_shell_command).
  2. The agent finishing its task and waiting for user input.

This ambiguity caused issues for integrations like notification systems, which would spam users with alerts during multi-step tool executions.

Changes:

  • Updated AfterAgentInput interface in packages/core/src/hooks/types.ts.
  • Updated GeminiClient to calculate and pass has_pending_tool_calls based on turn.pendingToolCalls.
  • Added integration test integration-tests/hooks-pending-tools.test.ts.
  • Updated documentation in docs/hooks/index.md.

Summary

Details

Related Issues

How to Validate

Pre-Merge Checklist

  • [ ] Updated relevant documentation and README (if needed)
  • [ ] Added/updated tests (if needed)
  • [ ] Noted breaking changes (if any)
  • [ ] Validated on required platforms/methods:
    • [ ] MacOS
      • [ ] npm run
      • [ ] npx
      • [ ] Docker
      • [ ] Podman
      • [ ] Seatbelt
    • [ ] Windows
      • [ ] npm run
      • [ ] npx
      • [ ] Docker
    • [x] Linux
      • [x] npm run
      • [x] npx
      • [ ] Docker

RyderFreeman4Logos avatar Dec 05 '25 21:12 RyderFreeman4Logos

Summary of Changes

Hello @RyderFreeman4Logos, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the AfterAgent hook by adding a has_pending_tool_calls boolean field. This new field provides crucial context to external systems, enabling them to accurately determine if an agent's turn has concluded or if it's merely awaiting the completion of a tool execution. This distinction is vital for preventing premature or irrelevant actions by integrations, such as sending notifications during multi-step agent operations.

Highlights

  • New has_pending_tool_calls field: A new boolean field, has_pending_tool_calls, has been added to the AfterAgent hook input payload. This field indicates whether the agent is currently pausing to execute a tool.
  • Improved Agent Turn Distinction: This feature allows integrations to distinguish between an agent pausing for tool execution and an agent finishing its task and awaiting user input, resolving ambiguity that previously led to issues like notification spam.
  • GeminiClient Integration: The GeminiClient has been updated to calculate and pass the has_pending_tool_calls status to the AfterAgent hook based on the agent's pendingToolCalls.
  • Comprehensive Testing and Documentation: New integration tests have been added to validate the correct reporting of pending tool calls, and the documentation for the AfterAgent hook has been updated to reflect the new input field.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist avatar Dec 05 '25 21:12 gemini-code-assist

Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request.

To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues.

If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding!

gemini-cli[bot] avatar Jan 24 '26 16:01 gemini-cli[bot]