Repository navigation
fix(py): serialize ModelInfo with camelCase aliases for Dev UI capability compatibility - #5964
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates define_model and define_background_model to serialize ModelInfo using by_alias=True and exclude_none=True when calling model_dump(), and adds corresponding unit tests. The review feedback highlights an issue in define_background_model where unconditionally setting model_options['label'] = label overwrites any custom label provided in info, and suggests updating both the implementation and the tests to handle and verify this correctly.
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates model definition functions to serialize model info using aliases and exclude null values, and refactors label resolution in background models to follow a clear precedence order. A review comment correctly points out a bug where the original label variable is still referenced in a cancel action description, which could lead to an incorrect description if label is not explicitly provided.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Description
When defining custom models or background models in Python (
define_modelanddefine_background_model), dumpingModelInfowithout parameters serialized snake_case names (e.g.system_role,long_running,content_type,config_schema) and includedNonevalues.This PR passes
by_alias=Trueandexclude_none=Truetoinfo.model_dump(...)in_model.pyand_background.pyso field names are properly formatted as camelCase JSON aliases matching JS schema expectations andNonefields are omitted.This fixes an issue with Genkit Python on Dev UI. When the Dev UI evaluates `metadata.model.supports?.systemRole in JavaScript, "system_role" is not recognized, returning undefined. The UI interprets this as false and hides capability controls (such as the System Prompt input card). All the model info metadata is broken in the same way.
(I noticed this bug while testing with Ollama. Gemini/Vertex models have some magic on Dev UI side that hides this wire format inconsistency.)
Checklist
Manual inspection in Dev UI
I tested before/after using an Ollama sample.
BEFORE: System prompt is missing.

AFTER: system prompt renders correctly.
