[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)
Tracking
(firefox158 fixed)
| 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
| Assignee | ||
Comment 1•2 months ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=92719
| Assignee | ||
Comment 2•2 months ago
|
||
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
- /ai/rewriter/rewriter-abort.tentative.https.window.html [wpt.fyi]
- Aborting Rewriter.create():
FAIL - Aborting Rewriter.rewrite():
FAIL - Aborting Rewriter.rewriteStreaming():
FAIL - Aborting Rewriter.rewriteStreaming() after finished reading:
FAIL
- Aborting Rewriter.create():
- /ai/rewriter/rewriter-availability-available.tentative.https.window.html [wpt.fyi]
- Rewriter.availability() is available with no options:
FAIL - Rewriter.availability() returns available with supported options:
FAIL - Rewriter.availability() returns unavailable for unsupported languages and create() rejects:
FAIL
- Rewriter.availability() is available with no options:
- /ai/rewriter/rewriter-availability.tentative.https.window.html [wpt.fyi]
- Rewriter.availability() is defined:
FAIL - Rewriter.availability() returns a valid value with no options:
FAIL - Rewriter.availability() returns a valid value with plausible options:
FAIL - Rewriter.availability() rejects when given invalid language tags:
FAIL
- Rewriter.availability() is defined:
- /ai/rewriter/rewriter-create-available.tentative.https.window.html [wpt.fyi]
- Rewriter.create() returns a valid object with default options:
FAIL - Rewriter.create() notifies its monitor on downloadprogress:
FAIL - Progress events are not emitted after aborted:
FAIL - Rewriter.sharedContext:
FAIL - Creating a Rewriter with "more-formal" tone:
FAIL - Creating a Rewriter with "more-casual" tone:
FAIL - Creating a Rewriter with "plain-text" format:
FAIL - Creating a Rewriter with "markdown" format:
FAIL - Creating a Rewriter with "shorter" length:
FAIL - Creating a Rewriter with "longer" length:
FAIL - Rewriter.expectedInputLanguages:
FAIL - Rewriter.expectedContextLanguages:
FAIL - Rewriter.outputLanguage:
FAIL - Creating Rewriter with malformed language string:
FAIL - Rewriter.create() canonicalizes language tags:
FAIL - Rewriter optional attributes return null:
FAIL
- Rewriter.create() returns a valid object with default options:
- /ai/rewriter/rewriter-create-user-activation.tentative.https.window.html [wpt.fyi]
- Create requires sticky user activation when availability is "downloadable":
FAIL(Chrome:TIMEOUT, Safari:FAIL)
- Create requires sticky user activation when availability is "downloadable":
- /ai/rewriter/rewriter-create.tentative.https.window.html [wpt.fyi]
- Rewriter must be defined.:
FAIL - If monitor throws an error, Rewriter.create() rejects with that error:
FAIL
- Rewriter must be defined.:
- /ai/rewriter/rewriter-from-detached-iframe.tentative.https.window.html [wpt.fyi]
- Detaching iframe during Rewriter.create() should not leak memory:
FAIL - Rewriter.create() fails on a detached iframe.:
FAIL - Rewriter.rewrite() fails on a detached iframe.:
FAIL - Rewriter.rewriteStreaming() fails on a detached iframe.:
FAIL - Detaching iframe during Rewriter.rewrite() should not leak memory:
FAIL
- Detaching iframe during Rewriter.create() should not leak memory:
- /ai/rewriter/rewriter-iframe.tentative.https.html [wpt.fyi]
- Throw a 'NotAllowedError' when creating Rewriter within cross-origin iframe:
FAIL - Rewriter can be created within cross-origin iframe with permission policy:
FAIL - Rewriter can be used within same-origin iframe:
FAIL - Rewriter is unavailable within cross-origin iframe:
FAIL - Rewriter is available within cross-origin iframe with permission policy:
FAIL - Rewriter is available within same-origin iframe:
FAIL
- Throw a 'NotAllowedError' when creating Rewriter within cross-origin iframe:
- /ai/rewriter/rewriter-measureInputUsage.tentative.https.window.html [wpt.fyi]
- Rewriter.measureInputUsage() returns non-empty result:
FAIL
- Rewriter.measureInputUsage() returns non-empty result:
- /ai/rewriter/rewriter-rewrite-post-abort.tentative.https.window.html [wpt.fyi]
- Rewrite after aborting a previous rewrite.:
FAIL
- Rewrite after aborting a previous rewrite.:
- /ai/rewriter/rewriter-rewrite-streaming-post-abort.tentative.https.window.html [wpt.fyi]
- Rewrite after aborting a previous rewriteStreaming.:
FAIL
- Rewrite after aborting a previous rewriteStreaming.:
- /ai/rewriter/rewriter-rewrite-streaming.tentative.https.window.html [wpt.fyi]
- Simple Rewriter.rewriteStreaming() call:
FAIL - Rewriter.rewriteStreaming() fails after destroyed:
FAIL - Rewriter.rewriteStreaming() returns a ReadableStream without any chunk on an empty input:
FAIL - Multiple Rewriter.rewriteStreaming() calls are resolved successfully:
FAIL - Rewrite Streaming API must continue even after GC has been performed.:
FAIL
- Simple Rewriter.rewriteStreaming() call:
- /ai/rewriter/rewriter-rewrite.tentative.https.window.html [wpt.fyi]
- Rewriter.rewrite() with an empty input returns an empty text:
FAIL - Rewriter.rewrite() with a whitespace input returns a whitespace text:
FAIL - Rewriter.rewrite() with a whitespace context returns a non-empty result:
FAIL - Calling Rewriter.destroy() aborts calls to rewrite and measureInputUsage.:
FAIL - Rewriter.create()'s abort signal destroys its Rewriter after creation.:
FAIL - Simple Rewriter.rewrite() call:
FAIL - Multiple Rewriter.rewrite() calls are resolved successfully:
FAIL
- Rewriter.rewrite() with an empty input returns an empty text:
- /ai/summarizer/summarizer-abort.tentative.https.window.html [wpt.fyi]
- Aborting Summarizer.create().:
FAIL - Aborting Summarizer.summarize():
FAIL - Aborting Summarizer.summarizeStreaming():
FAIL - Aborting Summarizer.summarizeStreaming() after finished reading:
FAIL
- Aborting Summarizer.create().:
- /ai/summarizer/summarizer-availability-available.tentative.https.window.html [wpt.fyi]
- Summarizer.availability() is available with no options:
FAIL - Summarizer.availability() returns available with supported options:
FAIL - Summarizer.availability() returns unavailable for unsupported languages and create() rejects:
FAIL
- Summarizer.availability() is available with no options:
- /ai/summarizer/summarizer-availability.tentative.https.window.html [wpt.fyi]
- Summarizer.availability() is defined:
FAIL - Summarizer.availability() returns a valid value with no options:
FAIL - Summarizer.availability() returns a valid value with plausible options:
FAIL - Summarizer.availability() rejects when given invalid language tags:
FAIL
- Summarizer.availability() is defined:
- /ai/summarizer/summarizer-create-available.tentative.https.window.html [wpt.fyi]
- Summarizer.create() returns a valid object with default options:
FAIL - Summarizer.create() notifies its monitor on downloadprogress:
FAIL - Progress events are not emitted after aborted:
FAIL - Summarizer.sharedContext:
FAIL - Summarizer.type:
FAIL - Summarizer.format:
FAIL - Summarizer.length:
FAIL - Summarizer.expectedInputLanguages:
FAIL - Summarizer.expectedContextLanguages:
FAIL - Summarizer.outputLanguage:
FAIL - Creating Summarizer with malformed language string:
FAIL - Summarizer.create() canonicalizes language tags:
FAIL - Summarizer optional attributes return null:
FAIL
- Summarizer.create() returns a valid object with default options:
- /ai/summarizer/summarizer-create-user-activation.tentative.https.window.html [wpt.fyi]
- Create requires sticky user activation when availability is "downloadable":
FAIL(Chrome:TIMEOUT, Safari:FAIL)
- Create requires sticky user activation when availability is "downloadable":
- /ai/summarizer/summarizer-create.tentative.https.window.html [wpt.fyi]
- Summarizer.create() is defined:
PRECONDITION_FAILED - If monitor throws an error, Summarizer.create() rejects with that error:
FAIL
- Summarizer.create() is defined:
- /ai/summarizer/summarizer-from-detached-iframe.tentative.https.window.html [wpt.fyi]
- Detaching iframe during Summarizer.create() should not leak memory:
FAIL - Summarizer.create() fails on a detached iframe:
FAIL - Summarizer.summarize() fails on a detached iframe:
FAIL - Summarizer.summarizeStreaming() fails on a detached iframe:
FAIL - Detaching iframe during Summarizer.summarize() should not leak memory:
FAIL
- Detaching iframe during Summarizer.create() should not leak memory:
- /ai/summarizer/summarizer-iframe.tentative.https.html [wpt.fyi]
- Throw a 'NotAllowedError' when creating Summarizer within cross-origin iframe:
FAIL - Summarizer can be created within cross-origin iframe with permission policy:
FAIL - Summarizer can be used within same-origin iframe:
FAIL - Summarizer is unavailable within cross-origin iframe:
FAIL - Summarizer is available within cross-origin iframe with permission policy:
FAIL - Summarizer is available within same-origin iframe:
FAIL
- Throw a 'NotAllowedError' when creating Summarizer within cross-origin iframe:
- /ai/summarizer/summarizer-measureInputUsage.tentative.https.window.html [wpt.fyi]
- Summarizer.measureInputUsage() returns non-empty result:
FAIL
- Summarizer.measureInputUsage() returns non-empty result:
- /ai/summarizer/summarizer-summarize-post-abort.tentative.https.window.html [wpt.fyi]
- Summarize after aborting a previous summarize.:
FAIL
- Summarize after aborting a previous summarize.:
- /ai/summarizer/summarizer-summarize-streaming-post-abort.tentative.https.window.html [wpt.fyi]
- Summarize after aborting a previous summarizeStreaming.:
FAIL
- Summarize after aborting a previous summarizeStreaming.:
- /ai/summarizer/summarizer-summarize-streaming.tentative.https.window.html [wpt.fyi]
- Simple Summarizer.summarizeStreaming() call:
FAIL - Summarizer.summarizeStreaming() fails after destroyed:
FAIL - Summarizer.summarizeStreaming() returns a ReadableStream without any chunk on an empty input:
FAIL - Multiple Summarizer.summarizeStreaming() calls are resolved successfully:
FAIL - Summarize Streaming API must continue even after GC has been performed.:
FAIL
- Simple Summarizer.summarizeStreaming() call:
- /ai/summarizer/summarizer-summarize.tentative.https.window.html [wpt.fyi]
- Summarizer.summarize() with an empty input returns an empty text:
FAIL - Summarizer.summarize() with a whitespace context returns an empty result:
FAIL - Calling Summarizer.destroy() aborts calls to summarize and measureInputUsage.:
FAIL - Summarizer.create()'s abort signal destroys its Summarizer after creation.:
FAIL - Simple Summarizer.summarize() call:
FAIL - Multiple Summarizer.summarize() calls are resolved successfully:
FAIL
- Summarizer.summarize() with an empty input returns an empty text:
- /ai/writer/writer-abort.tentative.https.window.html [wpt.fyi]
- Aborting Writer.create():
FAIL - Aborting Writer.write():
FAIL - Aborting Writer.writeStreaming():
FAIL - Aborting Writer.writeStreaming() after finished reading:
FAIL
- Aborting Writer.create():
- /ai/writer/writer-availability-available.tentative.https.window.html [wpt.fyi]
- Writer.availability() is available with no options:
FAIL - Writer.availability() returns available with supported options:
FAIL - Writer.availability() returns unavailable for unsupported languages and create() rejects:
FAIL
- Writer.availability() is available with no options:
- /ai/writer/writer-availability.tentative.https.window.html [wpt.fyi]
- Writer.availability() is defined:
FAIL - Writer.availability() returns a valid value with no options:
FAIL - Writer.availability() returns a valid value with plausible options:
FAIL - Writer.availability() rejects when given invalid language tags:
FAIL
- Writer.availability() is defined:
- /ai/writer/writer-create-available.tentative.https.window.html [wpt.fyi]
- Writer.create() returns a valid object with default options:
FAIL - Writer.create() notifies its monitor on downloadprogress:
FAIL - Progress events are not emitted after aborted:
FAIL - Writer.sharedContext:
FAIL - Creating a Writer with "formal" tone:
FAIL - Creating a Writer with "casual" tone:
FAIL - Creating a Writer with "markdown" format:
FAIL - Creating a Writer with "medium" length:
FAIL - Creating a Writer with "long" length:
FAIL - Writer.expectedInputLanguages:
FAIL - Writer.expectedContextLanguages:
FAIL - Writer.outputLanguage:
FAIL - Creating Writer with malformed language string:
FAIL - Writer.create() canonicalizes language tags:
FAIL - Writer optional attributes return null:
FAIL
- Writer.create() returns a valid object with default options:
- /ai/writer/writer-create-user-activation.tentative.https.window.html [wpt.fyi]
- Create requires sticky user activation when availability is "downloadable":
FAIL(Chrome:TIMEOUT, Safari:FAIL)
- Create requires sticky user activation when availability is "downloadable":
- /ai/writer/writer-create.tentative.https.window.html [wpt.fyi]
- Writer must be defined.:
FAIL - If monitor throws an error, Writer.create() rejects with that error:
FAIL
- Writer must be defined.:
- /ai/writer/writer-from-detached-iframe.tentative.https.window.html [wpt.fyi]
- Detaching iframe during Writer.create() should not leak memory:
FAIL - Writer.create() fails on a detached iframe:
FAIL - Writer.write() fails on a detached iframe:
FAIL - Writer.writeStreaming() fails on a detached iframe:
FAIL - Detaching iframe during Writer.write() should not leak memory:
FAIL
- Detaching iframe during Writer.create() should not leak memory:
- /ai/writer/writer-iframe.tentative.https.html [wpt.fyi]
- Throw a 'NotAllowedError' when creating Writer within cross-origin iframe:
FAIL - Writer can be created within cross-origin iframe with permission policy:
FAIL - Writer can be used within same-origin iframe:
FAIL - Writer is unavailable within cross-origin iframe:
FAIL - Writer is available within cross-origin iframe with permission policy:
FAIL - Writer is available within same-origin iframe:
FAIL
- Throw a 'NotAllowedError' when creating Writer within cross-origin iframe:
- /ai/writer/writer-measureInputUsage.tentative.https.window.html [wpt.fyi]
- Writer.measureInputUsage() returns non-empty result:
FAIL
- Writer.measureInputUsage() returns non-empty result:
- /ai/writer/writer-write-post-abort.tentative.https.window.html [wpt.fyi]
- Write after aborting a previous write.:
FAIL
- Write after aborting a previous write.:
- /ai/writer/writer-write-streaming-post-abort.tentative.https.window.html [wpt.fyi]
- Write after aborting a previous writeStreaming.:
FAIL
- Write after aborting a previous writeStreaming.:
- /ai/writer/writer-write-streaming.tentative.https.window.html [wpt.fyi]
- Simple Writer.writeStreaming() call:
FAIL - Writer.writeStreaming() fails after destroyed:
FAIL - Writer.writeStreaming() returns a ReadableStream without any chunk on an empty input:
FAIL - Multiple Writer.writeStreaming() calls are resolved successfully:
FAIL - Write Streaming API must continue even after GC has been performed.:
FAIL
- Simple Writer.writeStreaming() call:
- /ai/writer/writer-write.tentative.https.window.html [wpt.fyi]
- Writer.write() with an empty input returns an empty text:
FAIL - Writer.write() with a whitespace input returns an empty text:
FAIL - Writer.write() with a whitespace context returns a non-empty result:
FAIL - Calling Writer.destroy() aborts calls to write and measureInputUsage.:
FAIL - Writer.create()'s abort signal destroys its Writer after creation.:
FAIL - Simple Writer.write() call:
FAIL - Multiple Writer.write() calls are resolved successfully:
FAIL
- Writer.write() with an empty input returns an empty text:
Comment 4•2 months ago
|
||
| bugherder | ||
Comment 5•2 months ago
|
||
| bugherder | ||
Description
•