Closed Bug 2072021 Opened 2 months ago Closed 2 months ago

[wpt-sync] Sync PR 62337 - ai: Pre-append prompt templates and establish init barrier for Writing Assistance APIs

Categories

(Testing :: web-platform-tests, task, P4)

task

Tracking

(firefox158 fixed)

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 62337 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/62337
Details from upstream follow.

Alan Ding <alanding@chromium.org> wrote:

ai: Pre-append prompt templates and establish init barrier for Writing Assistance APIs

Pre-append static options and shared context (the system prompt
template) to the on-device session during creation for AISummarizer,
AIWriter, and AIRewriter via OnDeviceSession::SetInput.

Per-request dynamic execution fields (article, instructions,
rewrite_text, and per-request context) are marked as pending on the
initial MultimodalMessage so that template substitution halts at the
static prefix without evaluating empty execution strings or generating
premature control tokens.

This change accomplishes two objectives:

  • crbug.com/540980352: Blocks create() promise resolution until the underlying On-Device Model Service (ODMS) has fully initialized the engine and model weights, eliminating the cold-start penalty currently incurred during the first summarize()/write()/rewrite() call.
  • crbug.com/390006887: Pre-populates and caches the static prompt options and shared context in the session KV cache during session creation, avoiding redundant re-tokenization on every execution call.

Automated tests:

  • Add prompt verification tests across AIWriter, AIRewriter, and
    AISummarizer unit tests to check substituted prompt strings.
  • Add multi-execution session reuse tests to verify shared context
    caching across sequential requests.
  • Add unit test for MultimodalMessage::Merge pending overlay clearance.

Bug: 390006887, 540980352
Change-Id: I199e35e62e6f084f490965a7d8bb7eafda27393c
Reviewed-on: https://chromium-review.googlesource.com/8255743
WPT-Export-Revision: 6c54a775b0ccf867fa6ac823766aca8d8747e8d6

CI Results

Ran 9 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 39 tests and 7 subtests

Status Summary

Firefox

OK : 3[GitHub] 39[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL : 3[GitHub] 162[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PRECONDITION_FAILED: 1

Chrome

TIMEOUT : 6

Safari

OK : 3
FAIL : 3

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Pushed by wptsync@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1b17cd2f577c https://hg.mozilla.org/integration/autoland/rev/ca0d89e2374e [wpt PR 62337] - ai: Pre-append prompt templates and establish init barrier for Writing Assistance APIs, a=testonly
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
You need to log in before you can comment on or make changes to this bug.