Skip to content

Don't default ToolAnnotations members to false - #407

Open
khushalsagar wants to merge 1 commit into
mainfrom
annotations-no-default
Open

khushalsagar wants to merge 1 commit into
mainfrom
annotations-no-default

Conversation

@khushalsagar

@khushalsagar khushalsagar commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Removes the = false defaults from the ToolAnnotations members (readOnlyHint,
untrustedContentHint, consequentialHint, debugging). An omitted member now
stays absent instead of reading as false, so consumers can tell "not set"
apart from "explicitly false" (option 1b in #53).


Preview | Diff

ToolAnnotations members no longer have default values, so consumers can
tell whether the author set a hint. The internal annotations struct
stores null for hints that were not provided, and Tool.annotations omits
those members instead of reporting false.

This is the annotations part of the generic tool calling explainer
(#375). See #53.
@beaufortfrancois

Copy link
Copy Markdown
Collaborator

Should debugging also drop its = false default here, or keep it? Unlike the safety/side-effect hints discussed in #53 (readOnlyHint, untrustedContentHint, consequentialHint), it's less clear that consumers need to distinguish debugging: false from omitted.

@domfarolino

Copy link
Copy Markdown
Collaborator

I want to better understand the motivation for this? Do we have evidence that models will treat explicitly set values different from missing values with their current defaults, if we give them the ability? That is, do any models want to treat an explicit readOnlyHint: false tool differently than a tool without the attribute—and those models have a weaker security posture today because of the implicit collapsing that our defaults give?

I'm looking to how MCP handles this for inspiration too. In MCP technically tool annotations can be absent, however the spec explicitly prescribes semantic defaults for each annotation for the missing case: https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations-title (also see this post). Again it's not clear to me if models treat the missing default different from explicit values that match the missing default. If the "default" prescribed by the MCP spec is normatively enforced, than the answer is no (because harness aren't allowed to act on the difference, and the fact that missing values are observable on the wire protocol is entirely incidental).

I think if we move forward with this, then we at least want to provide some kind of set of semantic defaults like MCP does. However, I still think that's worse than just doing it in our API directly. I think tri-state booleans are somewhat discouraged, so I only want to do this if it's clear models are lacking something real in our current spec. Otherwise, I'd follow the TAG guidance in https://w3ctag.github.io/design-principles/#optional-parameters:

If an argument for an API method has a reasonable default value, make that argument optional and specify the default value.
For boolean arguments, a default value of false is strongly preferred.
The default value should be the value that most authors will choose, if that choice is obvious. For boolean attributes, that might mean that the attribute name needs to be chosen so that false is the common choice.

I think this is largely backed up by whatwg/webidl#1485, which acknowledges that there are legitimate tri-state variable usages, but I'm personally not convinced this is one :)

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.

3 participants