Skip to content

fix(py): write generate and render span config in wire spelling - #116

Merged
huangjeff5 merged 1 commit into
mainfrom
fix/py-devui-config-camelcase
Nov 12, 2026
Merged

huangjeff5 merged 1 commit into
mainfrom
fix/py-devui-config-camelcase

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Writes declared model configuration keys in their camelCase wire spelling on the generate input span and the render output span.

The Dev UI's "Open in model runner" action inspects the generate span's config dictionary by exact wire key (e.g. maxOutputTokens, stopSequences). When callers configure generation using Pythonic snake_case (config={'max_output_tokens': 64}), the runner previously failed to match the form fields and displayed "default".

# --- BEFORE ---
await ai.generate(model='googleai/gemini-2.5-flash', prompt='hi', config={'max_output_tokens': 64})
# generate span input config: {'max_output_tokens': 64}
# Dev UI "Open in model runner" pre-fill: maxOutputTokens shows "default" (unmatched)

# --- AFTER ---
await ai.generate(model='googleai/gemini-2.5-flash', prompt='hi', config={'max_output_tokens': 64})
# generate span input config: {'maxOutputTokens': 64}
# Dev UI "Open in model runner" pre-fill: maxOutputTokens shows 64

Main Changes

  • Span config uses wire spelling: Previously, the generate input span and prompt render output span recorded whatever casing the caller passed in, while the downstream model span wrote the camelCase wire dictionary. Now, declared fields on the model's config schema are mapped to their wire key (serialization_alias / alias) so telemetry spans and Dev UI forms match across SDKs.
  • Undeclared extras stay as written: For models with passthrough configs (extra='allow') or models without a registered config class, unknown keys pass through untouched without renaming.
  • Prompts fold overrides under one wire key: Overriding a prompt's frontmatter config (maxOutputTokens: 256) with a call-time keyword (config={'max_output_tokens': 64}) merges onto the wire key, ensuring the span and model request see a single resolved key ({'maxOutputTokens': 64}).

All unit tests and preflight CI checks pass.
1_model_runner_prefill_max_output_tokens
2_generate_span_camelcase_wire_config

The Dev UI model runner pre-fills its form from the generate span's
config by exact camelCase key. ai.generate(config={'max_output_tokens': 64})
recorded max_output_tokens there, so "Open in model runner" showed Max
output tokens as "default". Prompt render output had the same problem,
even for frontmatter maxOutputTokens, because the merge folds every
spelling to the Python field name.

to_generate_options now renames fields the model's config class declares
to the key that class writes in Genkit JSON (camelCase on GenkitConfig),
after the prompt/ref/call merge. Keys the class doesn't declare stay as
written, and a model with no config class keeps the caller's keys. The
model span already used this spelling, so the three spans now agree, and
options built in process match what /util/generate receives from the Dev UI.
@huangjeff5
huangjeff5 merged commit 3c1c395 into main Nov 12, 2026
21 checks passed
@huangjeff5
huangjeff5 deleted the fix/py-devui-config-camelcase branch November 12, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants