fix(go): eagerly resolve genkit schema references in reflection API#5221
Open
fix(go): eagerly resolve genkit schema references in reflection API#5221
Conversation
The Reflection API returned raw `{"$ref": "genkit:Foo"}` references in
action metadata, causing the Dev UI to render empty forms because it
doesn't perform secondary lookups for Genkit's internal registry refs.
`ActionDef.Desc()` now resolves `genkit:` references in InputSchema and
OutputSchema (matching its existing doc comment), with a best-effort
fallback that preserves the `$ref` when the registry isn't set or the
schema hasn't been defined yet, keeping the existing deferred-resolution
flow intact. `listResolvableActions` also resolves descriptors returned
by DynamicPlugin.ListActions, which bypass `Desc()`.
Fixes #5219
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces schema reference resolution for action descriptors. The Desc() method and listResolvableActions function now resolve "genkit:" schema references to their concrete definitions, facilitating easier consumption by tools like the Dev UI. A review comment identifies an opportunity to improve the deduplication logic in listResolvableActions by properly initializing the tracking map with existing actions to prevent duplicates from dynamic plugins.
…eActions A DynamicPlugin returning an action that is also already registered in the global registry would previously be appended to the result a second time, since the keys map only tracked names from plugin iteration. Initialize keys with the names from the initial listActions(g) result so registered actions take precedence over plugin re-listings.
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 #5219
ActionDef.Desc()now resolvesgenkit:schema references inInputSchemaandOutputSchema(matching what its existing doc comment already promised).listResolvableActionsalso resolves descriptors returned fromDynamicPlugin.ListActions, which bypassDesc().Checklist
core/action_test.goandgenkit/reflection_test.go)