Skip to content

fix(anthropic): repoint references inside dependencies and contentSchema subschemas - #3246

Merged
gold-silver-copper merged 4 commits into
mainfrom
fix/anthropic-repoint-dependencies
Nov 10, 2026
Merged

gold-silver-copper merged 4 commits into
mainfrom
fix/anthropic-repoint-dependencies

Conversation

@gold-silver-copper

@gold-silver-copper gold-silver-copper commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

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/0 to #/not/not/anyOf/0. The walk that finds those references skipped two keywords that hold subschemas: draft-07 dependencies and contentSchema (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 dependencies like dependentSchemas, and contentSchema like propertyNames. 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

  • (anthropic) a reference inside a draft-07 dependencies subschema or a contentSchema into a root anyOf/oneOf/allOf now follows it under the double not.

Migration

None.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

Failing tests first (commits 1 and 3): new cases in providers::anthropic::completion::tests::pointer_references_into_moved_keywords_follow_them. On main:

panicked at crates/rig-core/src/providers/anthropic/completion/tests.rs:535:5:
assertion `left == right` failed
  left: ... "dependencies": Object {"x": Object {"$ref": String("#/anyOf/0")}, ...
 right: ... "dependencies": Object {"x": Object {"$ref": String("#/not/not/anyOf/0")}, ...

The contentSchema case 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 warnings

Production lines: +6 / -3. Test lines: +34.

Try it:

cd ~/code/rig && git fetch origin && git switch --detach origin/fix/anthropic-repoint-dependencies && cargo nextest run -p rig-core pointer_references_into_moved

gold-silver-copper and others added 4 commits November 10, 2026 13:50
… 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>
@gold-silver-copper gold-silver-copper changed the title fix(anthropic): repoint references inside a draft-07 dependencies subschema fix(anthropic): repoint references inside dependencies and contentSchema subschemas Nov 10, 2026
@gold-silver-copper
gold-silver-copper added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit e2a39ec Nov 10, 2026
17 checks passed
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.

1 participant