Skip to content

Add outputSchema to ModelContextTool and RegisteredTool - #254

Open
beaufortfrancois wants to merge 7 commits into
webmachinelearning:mainfrom
beaufortfrancois:outputSchema
Open

beaufortfrancois wants to merge 7 commits into
webmachinelearning:mainfrom
beaufortfrancois:outputSchema

Conversation

@beaufortfrancois

@beaufortfrancois beaufortfrancois commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds an optional outputSchema member to the ModelContextTool and RegisteredTool dictionaries to enable browser agents and in-page agents to help LLMs reliably reason about the return values of tools.

While responseConstraint was previously discussed, that name is too specific to the Built-in AI / Prompt API. TheoutputSchema name aligns directly with the MCP Tools specification outputSchema used to define expected structured outputs with JSON Schema.

FIX #9


Preview | Diff

@arnabwithab arnabwithab mentioned this pull request Sep 3, 2026
7 tasks done
arnabwithab added a commit to arnabwithab/webmcp that referenced this pull request Sep 3, 2026
Codify WebMCP JSON Schema subset (Draft 2020-12) per 2026-03-05 CG resolution.
Meta-validation in registerTool() (TypeError on invalid schema) and input
validation in executeTool() parallel block before tool execute steps
(DataError with {path,reason,schemaPath} for agent self-correction).

Spec-only per review; WPT split to web-platform-tests/wpt (tentative).
Coordinates with webmachinelearning#254 (outputSchema, same dictionaries).
@volkandkaya

Copy link
Copy Markdown

Is this still planned on being added?

@beaufortfrancois

Copy link
Copy Markdown
Collaborator Author

Is this still planned on being added?

I hope so :) 🤞

@domfarolino I've started experimenting with outputSchema in Chromium with https://chromium-review.googlesource.com/c/chromium/src/+/8398367 to test it out.

@markafoltz markafoltz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions/comments about how the serialization result is passed around (might be missing some key idea)

Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs
Comment thread index.bs Outdated

@markafoltz markafoltz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good % a few optional suggested edits

Comment thread index.bs Outdated
Comment thread index.bs
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread README.md Outdated
Comment thread index.bs
<dt><code><var ignore>tool</var>["{{ModelContextTool/outputSchema}}"]</code></dt>
<dd>
<p>A JSON Schema object describing the expected output structure for the tool [[!JSON-SCHEMA]].
Tool output is expected to conform to the provided schema, and [=agents=] may reject outputs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this can be validated at the User Agent level, should this go a step further and throw an exception or fail the executeTools promise if the output does not match the schema?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I guess it's related to #92

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce outputSchema (was: Should output also have a schema?)

4 participants