Skip to content

feat(py): core support for background model operations and typed model refs - #5854

Open
cabljac wants to merge 3 commits into
mainfrom
jh-interactions-1-core
Open

feat(py): core support for background model operations and typed model refs#5854
cabljac wants to merge 3 commits into
mainfrom
jh-interactions-1-core

Conversation

@cabljac

@cabljac cabljac commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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)

  1. feat(py): core support for background model operations and typed model refs #5854 core support for background model operations and typed model refs
  2. feat(py/plugins/google-genai): raw Interactions HTTP client, converters, and options #5855 Interactions HTTP client, converters, and options
  3. feat(py/plugins/google-genai): Deep Research, Antigravity, and Lyria interaction models #5856 Deep Research, Antigravity, and Lyria interaction models
  4. refactor(py/plugins/google-genai): move Veo to background model actions #5857 move Veo to background model actions
  5. feat(py/plugins/google-genai): wire Interactions models into GoogleAI plugin #5858 wire Interactions models into GoogleAI plugin
  6. feat(py/plugins/google-genai): finish_message for image models and effective config echo #5859 gemini finish_message (parallel, based on this PR)

Recombining this stack reproduces the tree of #5806 byte-for-byte. Work co-authored with @huangjeff5.

Breaking changes

  • ModelRequest.config no longer coerces bare dict configs into ModelConfig: ModelRequest(config={...}) keeps the dict, and ModelRequest[PluginConfig] coerces into the plugin schema instead. Code that relied on attribute access on an implicitly-coerced ModelConfig must use dict access or bind a config schema.
  • ModelRequest.config now raises TypeError for values that are neither a BaseModel nor a dict.

Cross-language files

The aborted finish reason already exists in the JS runtime on main; this PR syncs the tools zod source (genkit-tools/common/src/types/model.ts), the generated genkit-schema.json, and Go's generated go/ai/gen.go to match (CI enforces all three). No hand-written Go or tools changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread py/packages/genkit/src/genkit/_core/_action.py Outdated
cabljac and others added 2 commits July 30, 2026 12:23
…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
cabljac force-pushed the jh-interactions-1-core branch from c0b14c3 to 2a2ad94 Compare July 30, 2026 11:28
@cabljac
cabljac requested a review from hilariie July 30, 2026 12:14
…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>
@github-actions github-actions Bot added the go label Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant