feat(py): core support for background model operations and typed model refs - #5854
Open
cabljac wants to merge 3 commits into
Open
feat(py): core support for background model operations and typed model refs#5854cabljac wants to merge 3 commits into
cabljac wants to merge 3 commits into
Conversation
This was referenced Jul 30, 2026
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances background model support and model configuration validation in the Python SDK. Key changes include adding the 'aborted' finish reason, allowing background models to return an Operation to poll, improving model resolution with helpful namespace hints, and refining ModelRequest config validation to gracefully handle plugin-specific schemas and dicts. The feedback suggests optimizing the input validation path in _action.py to avoid the overhead of catching ValidationError on every model call by checking and dumping BaseModel inputs upfront.
…l refs Core plumbing extracted from #5806: FinishReason.ABORTED (schema + typing), cancel-operation action kind and registry lookup, background operation lifecycle updates in _background.py, generate_operation/check_operation plumbing in _ai, and a config_schema parameter on model_ref. Co-authored-by: Jeff Huang <huangjeff@google.com>
genkit-schema.json is generated from this zod enum by export:schemas; adding aborted only to the generated JSON left CI's clean-working-tree check failing once the build regenerated the schema. Co-authored-by: Jeff Huang <huangjeff@google.com>
cabljac
force-pushed
the
jh-interactions-1-core
branch
from
July 30, 2026 11:28
c0b14c3 to
2a2ad94
Compare
…nishReason Regenerates go/ai/gen.go from genkit-schema.json (FinishReasonAborted) and narrows the runtime-parameterized ModelRequest cast to type[BaseModel] to match _override_input_schema's signature. Co-authored-by: Jeff Huang <huangjeff@google.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.
First slice of the #5806 split: FinishReason.ABORTED (typing + genkit-schema.json), a cancel-operation action kind with registry lookup, background operation lifecycle updates, generate_operation/check_operation plumbing, and a config_schema parameter on model_ref.
Stack (split of #5806)
Recombining this stack reproduces the tree of #5806 byte-for-byte. Work co-authored with @huangjeff5.
Breaking changes
ModelRequest.configno longer coerces bare dict configs intoModelConfig:ModelRequest(config={...})keeps the dict, andModelRequest[PluginConfig]coerces into the plugin schema instead. Code that relied on attribute access on an implicitly-coercedModelConfigmust use dict access or bind a config schema.ModelRequest.confignow raisesTypeErrorfor values that are neither aBaseModelnor a dict.Cross-language files
The
abortedfinish reason already exists in the JS runtime on main; this PR syncs the tools zod source (genkit-tools/common/src/types/model.ts), the generatedgenkit-schema.json, and Go's generatedgo/ai/gen.goto match (CI enforces all three). No hand-written Go or tools changes.