Skip to content

Comments

fix(core): ensure user rejections update tool outcome for telemetry#18982

Merged
chrstnb merged 1 commit intogoogle-gemini:mainfrom
abhiasap:agreement-rate-with-esc
Feb 19, 2026
Merged

fix(core): ensure user rejections update tool outcome for telemetry#18982
chrstnb merged 1 commit intogoogle-gemini:mainfrom
abhiasap:agreement-rate-with-esc

Conversation

@abhiasap
Copy link
Contributor

@abhiasap abhiasap commented Feb 13, 2026

Summary

This PR fixes a bug where the "User Agreement" (agreementRate) telemetry metric always reported 100%, even when users rejected tool call confirmations.

Details

The core issue was that user rejection outcomes were not being set in the scheduler's state, causing these events to be missed by the telemetry system.

The _processToolCall method in packages/core/src/scheduler/scheduler.ts only called this.state.setOutcome() when a tool was auto-allowed. This PR ensures this.state.setOutcome() is called unconditionally with the outcome derived from resolveConfirmation(), correctly capturing user decisions like ToolConfirmationOutcome.Cancel. This allows the ToolCallEvent to be created with the correct ToolCallDecision.REJECT, so it's properly logged.

Because outcome is now properly set for all code paths, this check ensures the policy engine is only invoked when the user actively made a choice, preventing unintended side-effects from sending default outcomes for auto-allowed tools.

Related Issues

Fixes #19035 (mirror of b/484240481)

Testing

  • Run the core tests: npm test -w @google/gemini-cli-core. All tests should pass, including the new assertion in scheduler.test.ts specifically checking for the setOutcome call on cancel.

How to Validate

  • Run npm run start
  • Trigger a tool call that requires user confirmation (e.g., ask it to condense the README into half)
  • When prompted by Gemini CLI, use the down arrow key and enter key to select "4. No, suggest changes (esc)"
  • Ask it to try again
  • This time, choose "1. Allow Once"
  • Run /stats (or simply exit out of the CLI)

Previous Behavior (Bug):
In stats, the User Agreement is (pre-fix)

User Agreement:             100.0% (1 reviewed)

Fixed Behavior:
In stats, the User Agreement is now (post-fix)

User Agreement:             50.0% (2 reviewed)

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

@abhiasap abhiasap requested a review from a team as a code owner February 13, 2026 11:04
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @abhiasap, 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 resolves a critical bug impacting the accuracy of telemetry data, specifically the agreementRate metric for tool calls. By ensuring that all user decisions, including rejections, are consistently recorded in the scheduler's state, the system can now accurately capture and report tool call outcomes. This change improves the reliability of telemetry and refines the logic for invoking the policy engine based on explicit user interaction.

Highlights

  • Telemetry Accuracy: Corrected a bug where the agreementRate telemetry metric always reported 100%, even when users rejected tool call confirmations, leading to inaccurate data.
  • Outcome Recording: Ensured that this.state.setOutcome() is called unconditionally within the _processToolCall method to accurately capture all user decisions, including cancellations, in the scheduler's state.
  • Policy Engine Invocation: Modified the updatePolicy invocation to only occur when a user actively made a choice (PolicyDecision.ASK_USER) and an outcome is available, preventing unintended side-effects from default outcomes for auto-allowed tools.
  • New Test Case: Added a new test assertion to scheduler.test.ts to verify that setOutcome is correctly called with ToolConfirmationOutcome.Cancel when a user cancels a tool call.
Changelog
  • packages/core/src/scheduler/scheduler.test.ts
    • Added an assertion to confirm mockStateManager.setOutcome is called with ToolConfirmationOutcome.Cancel when a tool call is cancelled.
  • packages/core/src/scheduler/scheduler.ts
    • Removed the unconditional this.state.setOutcome(callId, ToolConfirmationOutcome.ProceedOnce) call.
    • Introduced an unconditional this.state.setOutcome(callId, outcome) call after resolveConfirmation to ensure all outcomes are recorded.
    • Wrapped the updatePolicy call within a conditional block, ensuring it only executes if decision is PolicyDecision.ASK_USER and an outcome is present.
Activity
  • No specific review comments or progress updates have been recorded for this pull request yet.
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.

Copy link
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 effectively resolves a bug in telemetry reporting for tool call agreement rates. By ensuring setOutcome is called for all user decisions, including rejections, the telemetry will now accurately reflect user choices. The accompanying change to conditionally call updatePolicy only after a user interaction is a logical improvement that enhances code clarity. The new test case correctly validates the fix. The changes are well-implemented and address the issue described.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 13, 2026
@abhiasap abhiasap force-pushed the agreement-rate-with-esc branch from c9fca0f to 7cdfb24 Compare February 13, 2026 22:32
@gemini-cli gemini-cli bot added area/enterprise Issues related to Telemetry, Policy, Quota / Licensing and removed status/need-issue Pull requests that need to have an associated issue. labels Feb 13, 2026
@chrstnb chrstnb enabled auto-merge February 18, 2026 19:40
auto-merge was automatically disabled February 19, 2026 06:18

Head branch was pushed to by a user without write access

@abhiasap abhiasap force-pushed the agreement-rate-with-esc branch from 7cdfb24 to 95bb7cd Compare February 19, 2026 06:18
@chrstnb chrstnb enabled auto-merge February 19, 2026 13:00
@chrstnb chrstnb added this pull request to the merge queue Feb 19, 2026
Merged via the queue into google-gemini:main with commit ad9c49a Feb 19, 2026
26 of 27 checks passed
@abhiasap abhiasap deleted the agreement-rate-with-esc branch February 20, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/enterprise Issues related to Telemetry, Policy, Quota / Licensing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telemetry: agreementRate always shows 100% even when tool calls are rejected

3 participants