[Built-In API] Add kInternal InputSource for metric attribution. [chromium/src : main]

0 views
Skip to first unread message

Robbie McElrath (Gerrit)

unread,
Mar 13, 2026, 4:50:12 PM (2 days ago) Mar 13
to Isaac Ahouma, Chromium Metrics Reviews, (Julie)Jeongeun Kim, AyeAye, Steven Holte, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, francisjp...@google.com, feature-v...@chromium.org, gcasto+w...@chromium.org, ortuno...@chromium.org, feature-me...@chromium.org, browser-comp...@chromium.org, dtseng+c...@chromium.org, dtseng...@chromium.org, blink-...@chromium.org, derinel+wat...@google.com, josiah...@chromium.org, yuzo+...@chromium.org, titoua...@chromium.org, dewitt...@chromium.org, eme-r...@chromium.org, blink-revie...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, nickdiego+wa...@igalia.com, katie...@chromium.org, ios-r...@chromium.org, net-r...@chromium.org, cblume...@chromium.org, oshima...@chromium.org, webauthn...@chromium.org, anastas...@google.com, kyungjunle...@google.com, max+watc...@igalia.com, vasilii+watchlis...@chromium.org, abigailbk...@google.com, nektar...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com
Attention needed from Isaac Ahouma

Robbie McElrath added 1 comment

Patchset-level comments
File-level comment, Patchset 4:
Robbie McElrath . unresolved

Are these actually all user input, or are some of them things like system prompts or model output?

Isaac Ahouma

I checked with Gemini CLI and this is what I got:

```
I have verified that all three call sites correctly use kUserInput based on the available InputSource enum values:
   1. OnDeviceContext::Append: This is used to feed the conversation history and any feature-specific context into the model session. Since this data is
provided as part of the user's interaction session, kUserInput is the most appropriate attribution.
2. OnDeviceExecution::BeginExecution: This appends the user's actual prompt right before generation. This is direct user input, making kUserInput the
correct choice.
3. OnDeviceModelValidator::ValidateNextPrompt: This sends pre-defined validation prompts to the model. While these are synthetic, they represent the "user
side" of the interaction, and kUserInput is the most accurate existing attribution (as they are certainly not model feedback or unknown).
  None of these calls involve feeding the model's own generated output back into itself, which is what kModelOutputFeedback is reserved for. Additionally,
the current InputSource enum does not have a specific value for system-generated prompts, so kUserInput is the standard for all non-feedback inputs in this
context.
```
Isaac Ahouma

I guess, one thing we can consider here is adding a separate enum value for system prompts (or rename kModelOutputFeedback). WDYT?

Steven Holte

I'm confused about how this is different from what the control tokens are supposed to tell you? I think "UserInput" defined as "input provided directly by the user" is promising a distinction you can't actually make, since it suggests things like tokens coming from the prompt template are distingushed from tokens in the actual text inserted in the template.

Isaac Ahouma

Thanks for the feedback! I'm not deeply familiar with the Token enum (control tokens), but my understanding is that Token and InputSource operate at different levels:

  • Token: Seems to work at the piece-level. It helps the model distinguish structural roles within the input text, like separating system instructions from user text in a template.
  • InputSource: This is used at the action-level (via AppendOptions). It was introduced specifically for accurate performance metric attribution (like tokens/sec and processing time) by tagging the origin of the entire task.

The main reason for adding InputSource (in https://crrev.com/c/7577516) was to get a clear signal for bucketed logging. This allows the backend to separate metrics for new user inputs versus "feedback" inputs, where the model's previous output is used as the next input. The histograms were updated in https://crrev.com/i/9029232 to use this, adding suffixes like .ModelFeedback to fix http://b/483729567.

Regarding the scope of InputSource, IIUC an input should be tagged kUserInput if it originates from the active user interaction session, even if that input string contains system-provided template elements (which would be marked by Token enums).

I'm open to suggestions, so please let me know if this interpretation/approach is off and how we should make it better.

Isaac Ahouma

Unresolving

Steven Holte

My main issue is that InputSource and input_source field are documented in such a way that they suggest they are authoritative fields about the provencance of the data, but we don't actually even expect all of the things the pass input here to break down their inputs in such a way "UserInput" is in a seperate Append.

I think we should change the semantics here to clarify that this field is *just* for distinguishing metrics. If we don't actually need these metrics broken down for these features (which this CL wouldn't do, since it's assigning the same label to *all* of the append calls for those features), then it seems reasonable they just continue to log as Unknown type input.

If we wanted to distinguish say, context vs execution for them, it would be reasonable to add new labels, but it's not clear that's useful here?

Robbie McElrath

I thought InputSource was meant to reflect provenance as well. If it's not supposed to do that then renaming kUserInput might be all we need here, though populating the field is probably still a good idea.

Open in Gerrit

Related details

Attention is currently required from:
  • Isaac Ahouma
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icace3cde321b51d748cd575bd8c5b8f6d33fdfbb
Gerrit-Change-Number: 7664070
Gerrit-PatchSet: 11
Gerrit-Owner: Isaac Ahouma <iah...@google.com>
Gerrit-Reviewer: Isaac Ahouma <iah...@google.com>
Gerrit-Reviewer: Robbie McElrath <rmce...@chromium.org>
Gerrit-Reviewer: Steven Holte <ho...@chromium.org>
Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Isaac Ahouma <iah...@google.com>
Gerrit-Comment-Date: Fri, 13 Mar 2026 20:50:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Isaac Ahouma <iah...@google.com>
Comment-In-Reply-To: Robbie McElrath <rmce...@chromium.org>
Comment-In-Reply-To: Steven Holte <ho...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Isaac Ahouma (Gerrit)

unread,
Mar 13, 2026, 4:58:57 PM (2 days ago) Mar 13
to Chromium Metrics Reviews, (Julie)Jeongeun Kim, AyeAye, Steven Holte, Robbie McElrath, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, francisjp...@google.com, feature-v...@chromium.org, gcasto+w...@chromium.org, feature-me...@chromium.org, browser-comp...@chromium.org, dtseng+c...@chromium.org, dtseng...@chromium.org, blink-...@chromium.org, derinel+wat...@google.com, josiah...@chromium.org, dewitt...@chromium.org, eme-r...@chromium.org, blink-revie...@chromium.org, devtools...@chromium.org, katie...@chromium.org, ios-r...@chromium.org, cblume...@chromium.org, anastas...@google.com, kyungjunle...@google.com, max+watc...@igalia.com, abigailbk...@google.com, nektar...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com
Attention needed from Robbie McElrath and Steven Holte

Isaac Ahouma added 1 comment

Patchset-level comments
Isaac Ahouma

Yes, InputSource is used to indicate provenance as well for metric attribution purposes. I have updated the documentation. I was actually thinking about adding a `kInternal` value (although maybe this is not needed for this cl and I can remove this change if so) and adding a proper variant for that in the histogram.

Open in Gerrit

Related details

Attention is currently required from:
  • Robbie McElrath
  • Steven Holte
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icace3cde321b51d748cd575bd8c5b8f6d33fdfbb
Gerrit-Change-Number: 7664070
Gerrit-PatchSet: 11
Gerrit-Owner: Isaac Ahouma <iah...@google.com>
Gerrit-Reviewer: Isaac Ahouma <iah...@google.com>
Gerrit-Reviewer: Robbie McElrath <rmce...@chromium.org>
Gerrit-Reviewer: Steven Holte <ho...@chromium.org>
Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Robbie McElrath <rmce...@chromium.org>
Gerrit-Attention: Steven Holte <ho...@chromium.org>
Gerrit-Comment-Date: Fri, 13 Mar 2026 20:58:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Robbie McElrath <rmce...@chromium.org>
Comment-In-Reply-To: Isaac Ahouma <iah...@google.com>
Comment-In-Reply-To: Steven Holte <ho...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Isaac Ahouma (Gerrit)

unread,
Mar 13, 2026, 4:59:12 PM (2 days ago) Mar 13
to francisjp...@google.com, josiah...@chromium.org, feature-me...@chromium.org, ios-r...@chromium.org, feature-v...@chromium.org, kyungjunle...@google.com, max+watc...@igalia.com, eme-r...@chromium.org, gcasto+w...@chromium.org, katie...@chromium.org, nektar...@chromium.org
Attention needed from Robbie McElrath and Steven Holte

Isaac Ahouma has uploaded the change for review

Commit message

[Built-In API] Add kInternal InputSource for metric attribution.

This CL updates the InputSource enum to include a new kInternal value
for tasks like validation and clarifies its purpose for performance
metric attribution.

Specifically:
- Updated on_device_model.mojom with kInternal and improved docs.
- Updated OnDeviceModelValidator to use kInternal.
- Added .Internal metric variant and updated C++ mapping.
- Added unit tests to verify InputSource attribution.
Bug: 492208016
Change-Id: Icace3cde321b51d748cd575bd8c5b8f6d33fdfbb

Change diff


Change information

Files:
  • M components/optimization_guide/core/model_execution/on_device_context.cc
  • M components/optimization_guide/core/model_execution/on_device_execution.cc
  • M components/optimization_guide/core/model_execution/on_device_model_validator.cc
  • M components/optimization_guide/core/model_execution/on_device_model_validator_unittest.cc
  • M services/on_device_model/public/cpp/test_support/fake_service.cc
  • M services/on_device_model/public/mojom/on_device_model.mojom
  • M tools/metrics/histograms/metadata/on_device_model/histograms.xml
Change size: S
Delta: 7 files changed, 25 insertions(+), 1 deletion(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Robbie McElrath
  • Steven Holte
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages