refactor(core): replace positional execute params with ExecuteOptions bag#22674
refactor(core): replace positional execute params with ExecuteOptions bag#22674adamfweidman merged 9 commits intomainfrom
Conversation
…ckground completion support
Rename UserHintService to InjectionService as a generic, source-agnostic
injection mechanism. InjectionService supports typed sources ('user_steering'
and 'background_completion') with source-specific gating — user_steering
respects the model steering toggle while background_completion always fires.
Add background completion lifecycle to ExecutionLifecycleService: tracks
backgrounded executions, fires onBackgroundComplete listeners when they
settle, and supports FormatInjectionFn callbacks so execution creators
control how their output is formatted for reinjection.
Wire AppContainer to route background completions through InjectionService
and submit them to the model when idle, independent of model steering.
Wire ExecutionLifecycleService.setInjectionService() in Config constructor so backgrounded executions inject directly via settleExecution instead of routing through a useEffect bridge in AppContainer.
…nt loop The agent loop in local-executor now listens via onInjection (all sources) instead of onUserHint (steering only), picking up background completions between turns. This removes the separate bg completion useEffect, refs, state, and callback from AppContainer entirely.
…rface Remove legacy onUserHint/offUserHint/addUserHint methods. All callers now use addInjection(text, source) and onInjection/offInjection with source-based filtering where needed.
…ve dead code Rename getUserHints/getUserHintsAfter/getLatestHintIndex to getInjections/getInjectionsAfter/getLatestInjectionIndex with optional source filter so bg completions don't get formatted as user hints. Swap unshift ordering so bg completions appear before user hints in the message — the model sees context before the user's reaction to it. Remove unused getLastUserHintAt().
Wrap background completion output in <background_output> XML tags with inline instructions to treat as data, consistent with <user_input> tags used for user steering hints. Guard listener iteration in InjectionService.addInjection and ExecutionLifecycleService.settleExecution with try/catch so a throwing listener doesn't block subsequent listeners or crash the caller.
… flow Tests cover XML tag wrapping with safety instruction, ordering (background completions before user hints), and source filtering to prevent background output from leaking into user hint getters.
… bag Collapse shellExecutionConfig and setExecutionIdCallback into a single optional ExecuteOptions object on ToolInvocation.execute(). This avoids forcing every tool implementation to accept shell-specific parameters just to reach later positional args.
|
Hi @adamfweidman, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
Summary of ChangesHello, 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 significant refactoring to the core tool execution mechanism by consolidating multiple positional parameters into a single, extensible Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors several tool execution methods to replace positional parameters (shellExecutionConfig and setExecutionIdCallback) with a single ExecuteOptions options bag. The changes are applied across interfaces (ToolInvocation), base classes (BaseToolInvocation, DeclarativeTool), concrete implementations (ShellToolInvocation), and core functions (executeToolWithHooks), along with their corresponding call sites and tests. This change improves API extensibility for tool execution.
# Conflicts: # packages/a2a-server/src/commands/memory.ts # packages/cli/src/acp/commands/memory.ts
|
Size Change: -31 B (0%) Total Size: 26.2 MB
ℹ️ View Unchanged
|
Summary
Replaces positional
shellExecutionConfigandsetExecutionIdCallbackparameters onexecute()/executeToolWithHooks()with a singleExecuteOptionsbag. This makes it straightforward to add new execution options (e.g.completionBehaviorfor background tasks) without growing positional parameter lists.Details
ExecuteOptionsinterface intools.tswithshellExecutionConfigandsetExecutionIdCallbackfieldsToolInvocationinterface,BaseToolInvocation,DeclarativeTool.buildAndExecute,ShellToolInvocation.execute,executeToolWithHooks, andToolExecutorcall sitessanitizationConfigundershellExecutionConfigin a2a-server / ACP memory commandsThe immediate motivation is that downstream PRs need to add
completionBehaviorfor background task support. Without this refactor, that would mean yet another positional parameter that most callers pass asundefined:Related Issues
Related to #18197
How to Validate
coreToolHookTriggers.test.ts,tool-executor.test.ts, andmemory.test.tsupdated and passingPre-Merge Checklist