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 :)

@khushalsagar

Copy link
Copy Markdown
Collaborator Author

#53 summarizes the motivation for this change. The problem with the current API is that its not principled in either direction: is the default the conservative choice or not? read-only hint being false is conservative (assume tools mutate state unless said otherwise) but consequential hint is permissive (assume tools are not consequential unless said otherwise).

On the issue we considered all options: everything is permissive, everything is conservative (like MCP) or give the consumer a tri-state. The discussion on the issue converged on the last option which is my preference too. Going with the pessimistic default is more likely to make the consumers just ignore the hint. The MCP blog post you linked acknowledges that: "Many servers ship without them, and clients vary in how strictly they honor the pessimistic defaults."

We considered making them required but that can't be done in a backwards compatible way as new annotations are added.

@johannhof

Copy link
Copy Markdown
Contributor

Why is not being principled a problem?

@domfarolino

Copy link
Copy Markdown
Collaborator

I see the current defaults as principled. They don't all fall to one side of the "conservative" vs. "permissive" line, but I don't think that's the right line that all annotations should fall to one side or the other of. I see the current annotations as justified like so:

  • readOnlyHint: We can't decide that something is read-only for the developer by default, so leave this "conservative". We expect developers to tell us otherwise, because being "read-only" is something special the developer has to tell us about.
  • consequentialHint: Similarly, most actions are not particularly consequential—this is why you don't get an "are you sure?" dialog when you click every single button on the web. We can't decide that an action is unusually consequential compared to others, so we default to permissive. This is supported by the fact that if we defaulted to conservative, we risk warning fatigue to model harnesses, and consequential-ity loses all meaning.

@khushalsagar

Copy link
Copy Markdown
Collaborator Author

Lets move the discussion to the issue. too many threads. :)

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.

4 participants