Skip to content

feat(cli): implement event-driven tool execution scheduler#17078

Merged
abhipatel12 merged 3 commits into
mainfrom
abhi/event-driven-tools.8
Jan 21, 2026
Merged

feat(cli): implement event-driven tool execution scheduler#17078
abhipatel12 merged 3 commits into
mainfrom
abhi/event-driven-tools.8

Conversation

@abhipatel12
Copy link
Copy Markdown
Contributor

Summary

Implement the event-driven tool execution scheduler and integrate it into the
CLI UI via a facade hook. This completes the "Bridge" phase of the ReAct loop
migration, allowing for seamless toggling between legacy and modern execution
engines.

Details

  • Event-Driven Hook: Introduced useToolExecutionScheduler.ts, which
    utilizes the new Core Scheduler and MessageBus.
  • Adapter Pattern: Implemented a robust adapter within the hook to inject
    MessageBus-proxying onConfirm callbacks into Core objects, maintaining
    compatibility with legacy UI components.
  • Facade Hook: Created useToolScheduler.ts to act as a single entry point
    for useGeminiStream, switching implementations based on the experimental
    flag.
  • Type Safety: Unified tool tracking types to ensure a stable data contract
    across both implementations.
  • Verification:
    • Added useToolExecutionScheduler.test.ts (400+ lines of coverage).
    • Added useToolSchedulerFacade.test.ts to verify conditional delegation.
    • Updated useGeminiStream.test.tsx to reflect the new facade integration.

Related Issues

Related to #14306

How to Validate

  1. Unit Tests:
    • npm test -w @google/gemini-cli -- src/ui/hooks/useToolExecutionScheduler.test.ts
    • npm test -w @google/gemini-cli -- src/ui/hooks/useToolSchedulerFacade.test.ts
    • npm test -w @google/gemini-cli -- src/ui/hooks/useGeminiStream.test.tsx
  2. Manual Verification:
    • Enable the scheduler: "enableEventDrivenScheduler": true in settings.json
    • Execute tool-heavy prompts (e.g., replace or write_file) and verify:
      • Real-time execution status updates.
      • Confirmation dialogs correctly trigger execution upon approval.
      • Auto-approval (Shift+Tab) works as expected.

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
    • Linux
      • npm run
      • npx
      • Docker

@abhipatel12 abhipatel12 requested a review from a team as a code owner January 20, 2026 05:14
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @abhipatel12, I'm Gemini Code Assist1! 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 new event-driven tool execution scheduler, marking a significant step in migrating the CLI's execution engine. By implementing a facade hook, the system can seamlessly toggle between the existing legacy scheduler and the new, more modern event-driven approach. This change enhances the underlying architecture by utilizing a MessageBus for communication and a dedicated Scheduler from the core, while an adapter layer ensures that the UI remains compatible with the new system without requiring extensive refactoring.

Highlights

  • Event-Driven Scheduler Implementation: Introduced useToolExecutionScheduler.ts which leverages the new Core Scheduler and MessageBus for managing tool execution.
  • Facade Integration: A new useToolScheduler.ts hook acts as a facade, dynamically switching between the legacy useReactToolScheduler and the new event-driven scheduler based on a configuration flag.
  • Adapter Pattern for UI Compatibility: An adapter within useToolExecutionScheduler injects MessageBus-proxying onConfirm callbacks into Core objects, ensuring backward compatibility with existing UI components.
  • Unified Type Safety: Tool tracking types have been unified to provide a consistent data contract across both legacy and modern implementations.
  • Extensive Test Coverage: New unit tests (useToolExecutionScheduler.test.ts, useToolSchedulerFacade.test.ts) and updates to existing tests (useGeminiStream.test.tsx) ensure robust verification of the new scheduler and its integration.
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 👍 and 👎 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.

Footnotes

  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-cli gemini-cli Bot added the area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality label Jan 20, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a well-architected, event-driven tool execution scheduler. The use of a facade hook (useToolScheduler) to toggle between the legacy and new schedulers is an excellent approach for this migration. The adapter pattern in useToolExecutionScheduler is cleanly implemented to maintain compatibility with existing UI components by injecting onConfirm callbacks. The new code is accompanied by comprehensive tests, ensuring the new scheduler and the facade logic are robust. Overall, this is a high-quality contribution that modernizes the tool execution flow while ensuring a seamless transition.

@abhipatel12 abhipatel12 force-pushed the abhi/event-driven-tools.8 branch from 261ce23 to 7aa0506 Compare January 20, 2026 05:46
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 20, 2026

Size Change: +35.4 kB (+0.15%)

Total Size: 23.2 MB

Filename Size Change
./bundle/gemini.js 23.2 MB +35.4 kB (+0.15%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

Comment thread packages/cli/src/ui/hooks/useToolScheduler.ts Outdated
Comment thread packages/cli/src/ui/hooks/useToolScheduler.ts Outdated
@abhipatel12 abhipatel12 force-pushed the abhi/event-driven-tools.8 branch from 7aa0506 to 170a7f4 Compare January 20, 2026 19:40
Comment thread packages/cli/src/ui/hooks/useToolExecutionScheduler.ts Outdated
Comment thread packages/cli/src/ui/hooks/useToolExecutionScheduler.ts Outdated
Comment thread packages/cli/src/ui/hooks/useToolExecutionScheduler.ts Outdated
Comment thread packages/cli/src/ui/hooks/useToolExecutionScheduler.ts Outdated
…imental gate

- Introduces useToolScheduler facade to conditionally toggle between legacy and event-driven schedulers.
- Implements useToolExecutionScheduler using the new event-driven Core Scheduler (Bridge Phase).
- Provides robust Adapter for legacy confirmation callbacks, supporting Inline Edit payloads.
- Ensures functional parity with legacy response submission tracking and session timing.
- Includes comprehensive unit tests for the new hook and the facade.
- Verified with full workspace build, lint, and typecheck.
@abhipatel12 abhipatel12 force-pushed the abhi/event-driven-tools.8 branch from 170a7f4 to ab1798c Compare January 21, 2026 04:46
@abhipatel12 abhipatel12 enabled auto-merge January 21, 2026 05:12
@abhipatel12 abhipatel12 added this pull request to the merge queue Jan 21, 2026
Merged via the queue into main with commit 525539f Jan 21, 2026
25 checks passed
@abhipatel12 abhipatel12 deleted the abhi/event-driven-tools.8 branch January 21, 2026 05:27
Thomas-Shephard pushed a commit to Thomas-Shephard/gemini-cli that referenced this pull request Jan 21, 2026
thacio added a commit to thacio/auditaria that referenced this pull request Jan 24, 2026
kuishou68 pushed a commit to iOfficeAI/aioncli that referenced this pull request Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants