Repository navigation
fix(anthropic): repoint references inside dependencies and contentSchema subschemas - #3246
Merged
Merged
Conversation
… nested root keyword Co-authored-by: Aarav Gupta <134804732+Amronos@users.noreply.github.com>
…schema The walk that repoints references into a root keyword moved under the double not skipped draft-07 dependencies, so a reference there kept pointing at the old place. It now walks dependencies like dependentSchemas; a list of names in it is not a schema and is left as written. Co-authored-by: Aarav Gupta <134804732+Amronos@users.noreply.github.com>
Co-authored-by: Aarav Gupta <134804732+Amronos@users.noreply.github.com>
contentSchema holds a subschema, so the walk that repoints references into a root keyword moved under the double not now follows it too. Co-authored-by: Aarav Gupta <134804732+Amronos@users.noreply.github.com>
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.
Description
Follow-up to #3241. When a tool schema has a root
anyOf/oneOf/allOf, the Anthropic provider moves it under{"not": {"not": ...}}and repoints local references like#/anyOf/0to#/not/not/anyOf/0. The walk that finds those references skipped two keywords that hold subschemas: draft-07dependenciesandcontentSchema(2019-09 and later). A reference inside either kept pointing at the old place, which no longer exists.Before (sent to Anthropic):
{"type": "object", "dependencies": {"x": {"$ref": "#/anyOf/0"}}, "not": {"not": {"anyOf": [...]}}}After:
{"type": "object", "dependencies": {"x": {"$ref": "#/not/not/anyOf/0"}}, "not": {"not": {"anyOf": [...]}}}The walk now follows
dependencieslikedependentSchemas, andcontentSchemalikepropertyNames. A dependency that is a list of property names ("y": ["x"]) is not a schema and stays as written.Found by a read-only fix-check review of #3241's late commits (
dependencies) and by this PR's reviewers (contentSchema); the completeness reviewer found no other subschema keyword missing across draft-04 to 2020-12.Not changed, and left as #3241 documents it: a reference whose first pointer token is percent-encoded (
#/%61nyOf/0) is not repointed. No schema generator writes that.Changelog
dependenciessubschema or acontentSchemainto a rootanyOf/oneOf/allOfnow follows it under the doublenot.Migration
None.
Type of change
Testing
Failing tests first (commits 1 and 3): new cases in
providers::anthropic::completion::tests::pointer_references_into_moved_keywords_follow_them. On main:The
contentSchemacase failed the same way at commit 2 (contentSchema: {"$ref": "#/anyOf/0"}left as written, tests.rs:555). Both pass with commits 2 and 4.cargo nextest run --locked --profile local -p rig-core anthropic(176 passed)cargo clippy --locked -p rig-core --all-targets -- -D warningsProduction lines: +6 / -3. Test lines: +34.
Try it: