Repository navigation
Don't default ToolAnnotations members to false - #407
khushalsagar wants to merge 1 commit into
Conversation
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.
|
Should |
|
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 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:
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 :) |
|
#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. |
|
Why is not being principled a problem? |
|
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:
|
|
Lets move the discussion to the issue. too many threads. :) |
Removes the
= falsedefaults 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