genkit icon indicating copy to clipboard operation
genkit copied to clipboard

[plugins] Anthropic Python: add typed AnthropicConfig schema as customOptions

Open hilariie opened this issue 5 months ago • 0 comments

Parent: #5617 (Phase A, P0: item 33)

Why

Python advertises a generic ModelConfig as customOptions, so every Anthropic-specific option (thinking modes, output_config.effort, tool_choice, api_version, betas, and metadata) is invisible to reflection, the dev UI, and type hints. Today a caller can only discover these by reading the source, and the values are not validated before they reach the API.

Beyond discoverability, a typed config is the scaffold that the rest of the config-driven parity work hangs off (thinking modes, effort, the stable/beta split). Defining it once, up front, means those fields are typed a single time instead of being re-typed by each later change, which is why the epic sequences it before the thinking request-side work (item 11, #5629 ).

What needs to be done

  • Provide a typed Anthropic config that surfaces and validates the Anthropic-specific options: thinking, output_config (including effort and task_budget), tool_choice, metadata, api_version, and betas, modelled on the JS config and thinking schemas.
  • Advertise it as the customOptions for every Anthropic model so the options are discoverable and typed in reflection and the dev UI.
  • Preserve backward compatibility for callers that currently pass plain-dict configs.

Acceptance

  • Anthropic-specific options are discoverable via reflection / dev UI and are typed and validated.
  • The typed config is advertised as customOptions for all Anthropic models.
  • Existing dict-based configs continue to work; tests cover the schema and its validation rules (e.g. enabled requires a budget; enabled and adaptive are mutually exclusive).

Reference

  • Current customOptions wiring: py/plugins/anthropic/src/genkit/plugins/anthropic/plugin.py:126 and plugin.py:144.
  • JS target: js/plugins/anthropic/src/types.ts:68-159 (ThinkingConfigSchema, AnthropicConfigSchema).

hilariie avatar Jun 26 '26 11:06 hilariie