Fix destructiveHint/openWorldHint coerced to true when explicitly false#147
Open
rickreyhsig-wealthbox wants to merge 1 commit into
Open
Conversation
Annotation#initialize used `annotation["key"] || default`, which discards an explicit `false` from the server and falls back to the truthy default. `fetch(key, default)` only applies the default when the key is absent, so an explicit false is preserved. readOnlyHint and idempotentHint are unaffected since their defaults are already false. Fixes patvice#143
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #143.
Annotation#initializereadsdestructiveHint/openWorldHintwithannotation["key"] || default. Since both default totrue, an explicitfalsefrom the server (false || true) is silently discarded and replaced withtrue.readOnlyHint/idempotentHintdon't have this problem — their defaults are alreadyfalse, so||never overrides an explicit value either way.Fix
Swapped
||forfetch(key, default), which only applies the default when the key is absent from the hash — an explicitfalse(ortrue) passes through untouched:Tests
Updated the existing
RubyLLM::MCP::Annotationspec block intool_spec.rb, which had a test explicitly documenting the old (buggy) behavior — flipped it to assert the correct behavior instead, and dropped stale comments elsewhere in that block referencing the old||semantics.Verified directly against the real
RubyLLM::MCP::Annotationclass (Ruby 3.2, gem's own dependency chain) for both the fixed fields and the two fields that were already correct — all pass:I wasn't able to run the full spec suite locally —
tool_spec.rb'sbefore(:all)spins up the fixture MCP servers overbun, and getting those running requires installing@modelcontextprotocol/sdkfor each fixture app individually, which felt out of scope for verifying this change. Happy to do so if that's actually needed for review.