Skip to content

feat(py): fallback to BACKGROUND_MODEL in resolve_model - #6129

Open
huangjeff5 wants to merge 3 commits into
mainfrom
feat/py-bg-ops-1-lookup
Open

feat(py): fallback to BACKGROUND_MODEL in resolve_model#6129
huangjeff5 wants to merge 3 commits into
mainfrom
feat/py-bg-ops-1-lookup

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve_model looks up MODEL, then BACKGROUND_MODEL. A name registered only with define_background_model is findable under the same string callers already pass.
  • A foreground model still wins when both kinds share a name.
  • Missing names stay None (NOT_FOUND at the veneer).
  • A plugin whose resolve(MODEL) is None still yields the BACKGROUND_MODEL start action for a slashed name (plug/veo-…).

This PR is lookup only. generate() / generate_operation() boxing is #6130. Plugin resolve(MODEL, veo) already returns None on this stack, so the fallback can see Veo once that name is asked for.

@google-cla

google-cla Bot commented Aug 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 introduces robust support for ModelRef and pure model resolution helpers in the Genkit Python SDK, allowing model names, versions, and configurations to be resolved, normalized, and merged cleanly. It updates core APIs like generate, generate_stream, generate_operation, define_prompt, and define_agent to accept ModelRef and handle configuration aliases (camelCase to snake_case). Additionally, it updates reflection endpoints and registry lookups, and adds comprehensive unit tests. Feedback is provided regarding a potential misleading error in resolve_model_arg when the default model is configured as an empty string.

Comment thread py/packages/genkit/src/genkit/_ai/_model.py Outdated
@huangjeff5
huangjeff5 force-pushed the feat/py-bg-ops-1-lookup branch 4 times, most recently from 8bfcbe3 to cad3728 Compare August 21, 2026 00:34
An error occurred while trying to automatically change base from jh-model-ref-generate2 to py-model-resolution-helpers August 21, 2026 20:13
@huangjeff5
huangjeff5 changed the base branch from jh-model-ref-generate2 to main August 21, 2026 21:17
@huangjeff5
huangjeff5 force-pushed the feat/py-bg-ops-1-lookup branch from 9a93ca6 to 3b8412e Compare August 21, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant