Skip to content

fix(py): resolve_model falls back to background models so generate_operation can find them - #6023

Closed
huangjeff5 wants to merge 3 commits into
mainfrom
fix/resolve-model-bg-fallback
Closed

huangjeff5 wants to merge 3 commits into
mainfrom
fix/resolve-model-bg-fallback

Conversation

@huangjeff5

Copy link
Copy Markdown
Contributor

Product Context & Motivation

Genkit Python provides generate_operation() to trigger asynchronous long-running generation tasks (such as Veo video generation or Deep Research). Previously, Registry.resolve_model() only looked up models registered under the standard ActionKind.MODEL namespace. Consequently, background-only models registered under ActionKind.BACKGROUND_MODEL could not be resolved by generate_operation(), causing model lookup errors.

This PR fixes model resolution by enabling resolve_model to fall back to BACKGROUND_MODEL when a model is not found in the foreground MODEL registry.

Key Changes

  • Updated Registry.resolve_model() in genkit._core._registry to fall back to ActionKind.BACKGROUND_MODEL when standard lookup returns None.
  • Updated Genkit.generate_operation() in genkit._ai._aio to call resolve_model(), ensuring background models are correctly discovered.
  • Added comprehensive unit test in registry_test.py covering background model resolution.

Behavioral Nuance & Safety

@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 updates generate_operation to resolve models using resolve_model and enhances resolve_model to fall back to ActionKind.BACKGROUND_MODEL if a standard model is not found. A unit test was also added to verify this fallback behavior. The review feedback suggests updating the return type signature of resolve_model to include Operation to ensure type safety, since background-only models return an Operation rather than a ModelResponse.

@huangjeff5
huangjeff5 requested a review from apascal07 August 12, 2026 17:08
@huangjeff5

Copy link
Copy Markdown
Contributor Author

@gemini review

@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 updates the registry's 'resolve_model' method to fall back to background-only models (registered under 'ActionKind.BACKGROUND_MODEL') when a foreground model is not found, and updates its return type to include 'Operation'. Additionally, 'generate_operation' is updated to use 'resolve_model', and a unit test is added to verify this fallback behavior. There are no review comments, so I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant