Repository navigation
fix(agent): resolve refs under schema-keyword property names - #45093
Merged
BeautyyuYanli merged 3 commits intoNov 13, 2026
Merged
Conversation
Local #/$defs refs under name-to-schema maps (properties, patternProperties,
$defs, definitions, dependentSchemas, draft-07 dependencies) were skipped
whenever the map entry name matched a literal-value keyword ("const",
"default", "enum", "example", "examples"). A property named "default"
holding a local ref was therefore treated as literal data: the ref was never
inlined and pydantic's JSON schema generation raised KeyError: '#/$defs/..'
during create_agent. The same misclassification let remote refs under such
properties bypass the non-local ref rejection.
Make both traversals position-aware: keyword-name skipping only applies to
schema objects, while every entry value of a name-to-schema map is traversed
as a schema regardless of the entry name.
Fixes langgenius#45092
Co-Authored-By: Claude Code <[email protected]>
Contributor
|
Thanks for the fix! I merged
(This message is automated while I'm responsible for it.) |
BeautyyuYanli
approved these changes
Nov 13, 2026
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.
Fixes #45092
Summary
dify-agent's structured-output layer inlines local#/$defs/...refs before handing the schema to pydantic. The traversal skipped values whose key matched a literal-value keyword (const,default,enum,example,examples) — including in name→schema maps, where the key is user data. A property literally nameddefaultthat held a local$refwas therefore treated as literal data: the ref was never inlined, the root$defswas dropped, and pydantic's JSON-schema generation raisedKeyError: '#/$defs/Widget'duringcreate_agent. The same misclassification let remote$refs under such properties bypass the non-local-ref rejection.properties,patternProperties,$defs,definitions,dependentSchemas, draft-07dependencies) is traversed as a schema regardless of the entry name._iter_schema_refs) uses the same rule, so remote refs under keyword-named entries are rejected consistently; array-formdependenciesvalues are preserved untouched.Screenshots
Not a UI change.
Checklist
dependenciesentry (local and remote), literaldefault/examplesvalues staying untouched, and nested/$ref-sibling/boolean/recursion cases via probes.e5acabc3, 13 of the new tests fail (dangling$ref/ non-local refs accepted); with this change the output-layer module is 33/33.defaultproperty and the agent run returns{'default': {'id': 'x'}};ruff check/formatclean.Known pre-existing limitation (not caused by, and not fixable in this change): a literal
"$ref"string inside adefault/const/enumvalue still confuses pydantic's own JSON-schema walker (identical one5acabc3;examplesis unaffected). This fix correctly leaves that literal data untouched.From Claude Code