Skip to content

refactor(py/amazon-bedrock, py/ollama)!: trim plugin surfaces - #6706

Merged
huangjeff5 merged 18 commits into
mainfrom
chore/py-plugin-trim
Oct 10, 2026
Merged

huangjeff5 merged 18 commits into
mainfrom
chore/py-plugin-trim

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Trims the Bedrock and Ollama public surfaces down to what callers use.

Bedrock models= takes plain model IDs, the same shape embedders= already had. The plugin routes each ID the way resolve already did for unlisted ones:

# before
from genkit_amazon_bedrock import Bedrock, ModelDefinition
Bedrock(models=[ModelDefinition(name='stability.sd3-5-large-v1:0', type='image')])

# after
from genkit_amazon_bedrock import Bedrock
Bedrock(models=['stability.sd3-5-large-v1:0'])

cache_point_part() takes no arguments. Bedrock has one cache-point type (default), so the free-form cache_type str was either redundant or a 400 from the service. Passing it now raises TypeError; drop the argument:

# before
cache_point_part('default')    # the only value Bedrock accepts
cache_point_part('ephemeral')  # type-checks, Bedrock rejects it

# after
cache_point_part()

These root names now raise ImportError:

  • genkit_amazon_bedrock.{BedrockRerankOptions, RerankerRequest, RerankerResponse, RankedDocumentData, RankedDocumentMetadata, BedrockImageConfig, ModelDefinition}
  • genkit_ollama.{RequestHeaderFunction, RequestHeaders}

OllamaAPITypes is gone; ModelDefinition.api_type takes 'chat' or 'generate', matching JS ApiType.

Decisions

  • Bedrock.rerank() is removed, along with its request/response/options types. It was a method on the plugin instance, not a Genkit action, so callers had to hold the plugin and await it outside ai.*. Genkit Python has no reranker primitive; reranking comes back when core has one. Rerank model IDs still never resolve as chat or embedder models.
  • Bedrock infers the route from the ID: image-generation families go through InvokeModel, everything else through Converse. type='text' was identical to 'chat', so nothing is lost. models= now only adds Dev UI rows; [Python] Bedrock: list the model catalog like Google GenAI so Bedrock() needs no models= genkit-python#208 tracks listing the catalog instead.
  • BedrockImageConfig declares no fields and accepts anything, so it adds nothing over a dict. It stays as the image models' internal config schema.
  • cache_point_part() drops cache_type. A keyword can come back without breaking callers if Bedrock adds a second type.
  • RequestHeaderFunction / RequestHeaders only name what request_headers= already accepts. Pass a dict, or a callback typed with RequestHeaderParams.
  • No package-level changelogs. Bedrock and Ollama had the only two; their Changelog URL now points at GitHub Releases like every other package, since all 15 packages version and ship together. chore(py): release from a merged PR, with checks before tagging #6702 fixes the release scripts that referenced py/CHANGELOG.md.
  • bedrock_name / ollama_name stay on the roots here; feat(py)!: stop exporting bedrock_name, anthropic_name, ollama_name #6662 removes them independently.

@huangjeff5
huangjeff5 added this pull request to stack #6705 October 9, 2026 02:52
@github-actions github-actions Bot added docs Improvements or additions to documentation python Python config chore labels Oct 9, 2026

@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 removes the reranking feature from the Amazon Bedrock plugin and simplifies model registration across both the Bedrock and Ollama plugins by replacing custom classes and enums (like ModelDefinition and OllamaAPITypes) with plain string lists and literal types. It also removes local CHANGELOG.md files in favor of GitHub releases. The review feedback points out that removing the cache_type parameter from cache_point_part is a breaking change for existing callers and suggests keeping it as a deprecated optional parameter to maintain backward compatibility.

@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch 2 times, most recently from 87e14c8 to cfbc0f8 Compare October 9, 2026 02:56
@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch from cfbc0f8 to 8c47951 Compare October 9, 2026 03:47
@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch from 8c47951 to 11c0a1a Compare October 9, 2026 04:14
@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch from 11c0a1a to c8bce2f Compare October 9, 2026 04:49
@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch from c8bce2f to 3c7e9d5 Compare October 9, 2026 05:40
@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch from 3c7e9d5 to fd2b368 Compare October 9, 2026 05:57
@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch from fd2b368 to e5840f9 Compare October 9, 2026 06:32
@huangjeff5
huangjeff5 force-pushed the chore/py-plugin-trim branch from e5840f9 to 9c44d7d Compare October 9, 2026 06:49
Every module except each package's top-level __init__.py (and the exp
namespaces) is now underscore-prefixed in genkit-amazon-bedrock,
genkit-ollama, genkit-flask, genkit-django, genkit-fastapi,
genkit-evaluators, genkit-google-cloud, and genkit-vertexai. Import from
the package root.
Private subpackages (_model_garden, _models, _evaluators, _telemetry,
_context_caching) re-exported their internals through __init__.py, a second
import path nobody outside the package should use. Drop the files, matching
core's _ai and _core, and import from the defining module.
built_in_formats moves to _formats/_builtin.py; imports point at defining modules.
- Bedrock: drop RerankerRequest, RerankerResponse, RankedDocumentData,
  RankedDocumentMetadata, and BedrockImageConfig from the root. Genkit has no
  reranker primitive, so public copies would collide with future core types;
  the image config schema is empty and callers pass a dict.
- Ollama: drop RequestHeaderFunction and RequestHeaders (they only name what
  request_headers= accepts). ModelDefinition.api_type is Literal['chat',
  'generate'], matching JS ApiType, replacing the OllamaAPITypes enum that
  this PR would otherwise have hidden.
huangjeff5 and others added 3 commits October 9, 2026 18:59
…_plugin.py

Co-authored-by: Alex Pascal <apascal07@gmail.com>
# Conflicts:
#	py/packages/genkit-amazon-bedrock/src/genkit_amazon_bedrock/__init__.py
#	py/packages/genkit-amazon-bedrock/tests/plugin_test.py
#	py/packages/genkit-ollama/tests/plugin_api_test.py
Base automatically changed from chore/py-plugin-layout to main October 10, 2026 01:05
…route-to-schema helper

- models= and embedders= raise TypeError on a str instead of listing one model per character.
- _config_schema(model_type) picks the config schema for resolve and list_actions; the route is computed once per ID.
- bedrock_name becomes a private _action_name.
- Pin that a rerank ID fails as GenkitError NOT_FOUND before any AWS call.
huangjeff5 added a commit that referenced this pull request Oct 10, 2026
A missing bracket (models='llama3.2') iterated the string and listed one model per character. Same guard as Bedrock in #6706.
@huangjeff5
huangjeff5 merged commit 5715d3b into main Oct 10, 2026
25 checks passed
@huangjeff5
huangjeff5 deleted the chore/py-plugin-trim branch October 10, 2026 01:31
cabljac added a commit that referenced this pull request Oct 12, 2026
…lic surface

The Python plugins on main export only what a caller needs, take flat
keyword arguments instead of nested option objects (#6706), and report
failures as GenkitError with a status rather than plugin error classes
(#6710). The MCP client follows the same rules.

define_mcp_client takes command, args, env and cwd as keyword
arguments. McpStdioServerConfig stays as the internal model those
arguments build. The provider name is also the tool name prefix, as in
the Go plugin, so tool_prefix goes away. disabled goes away too: not
calling define_mcp_client does the same.

The error classes become private GenkitError subclasses: a closed
client is FAILED_PRECONDITION, a server that cannot start or dies is
UNAVAILABLE, and a protocol violation is INTERNAL.
cabljac added a commit that referenced this pull request Oct 12, 2026
…lic surface

The Python plugins on main export only what a caller needs and take
flat keyword arguments instead of nested option objects (#6671, #6706).
The client now does the same.

define_mcp_client and McpClient take command, args, env and cwd as
keyword arguments and build the stdio config internally. The provider
name is also the tool name prefix, as in the Go plugin, so tool_prefix
and the tool_prefix property go away, and the name has to satisfy the
tool name rule as well as the selector rule. disabled goes away: not
calling define_mcp_client does the same.

create_mcp_client goes away. An unregistered client has no use on its
own while generate(tools=) takes names rather than actions, and McpClient
is still there for the host to build clients without registering each.
dynamic_action_provider becomes private: no caller outside the package
needs it.

The package exports McpClient and define_mcp_client. Errors are
GenkitError with a status, as for the other plugins after #6710, so the
error classes are no longer exported. A test pins the exported names,
replacing the smoke test main deleted.
cabljac added a commit that referenced this pull request Oct 12, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
cabljac added a commit that referenced this pull request Oct 13, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
hilariie pushed a commit that referenced this pull request Oct 16, 2026
…lic surface

The Python plugins on main export only what a caller needs, take flat
keyword arguments instead of nested option objects (#6706), and report
failures as GenkitError with a status rather than plugin error classes
(#6710). The MCP client follows the same rules.

define_mcp_client takes command, args, env and cwd as keyword
arguments. McpStdioServerConfig stays as the internal model those
arguments build. The provider name is also the tool name prefix, as in
the Go plugin, so tool_prefix goes away. disabled goes away too: not
calling define_mcp_client does the same.

The error classes become private GenkitError subclasses: a closed
client is FAILED_PRECONDITION, a server that cannot start or dies is
UNAVAILABLE, and a protocol violation is INTERNAL.
hilariie pushed a commit that referenced this pull request Oct 16, 2026
…lic surface

The Python plugins on main export only what a caller needs and take
flat keyword arguments instead of nested option objects (#6671, #6706).
The client now does the same.

define_mcp_client and McpClient take command, args, env and cwd as
keyword arguments and build the stdio config internally. The provider
name is also the tool name prefix, as in the Go plugin, so tool_prefix
and the tool_prefix property go away, and the name has to satisfy the
tool name rule as well as the selector rule. disabled goes away: not
calling define_mcp_client does the same.

create_mcp_client goes away. An unregistered client has no use on its
own while generate(tools=) takes names rather than actions, and McpClient
is still there for the host to build clients without registering each.
dynamic_action_provider becomes private: no caller outside the package
needs it.

The package exports McpClient and define_mcp_client. Errors are
GenkitError with a status, as for the other plugins after #6710, so the
error classes are no longer exported. A test pins the exported names,
replacing the smoke test main deleted.
cabljac added a commit that referenced this pull request Oct 19, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
cabljac added a commit that referenced this pull request Oct 19, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
cabljac added a commit that referenced this pull request Oct 19, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
cabljac added a commit that referenced this pull request Oct 20, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
cabljac added a commit that referenced this pull request Oct 22, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
cabljac added a commit that referenced this pull request Oct 22, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
hilariie pushed a commit that referenced this pull request Oct 29, 2026
…lic surface

The Python plugins on main export only what a caller needs, take flat
keyword arguments instead of nested option objects (#6706), and report
failures as GenkitError with a status rather than plugin error classes
(#6710). The MCP client follows the same rules.

define_mcp_client takes command, args, env and cwd as keyword
arguments. McpStdioServerConfig stays as the internal model those
arguments build. The provider name is also the tool name prefix, as in
the Go plugin, so tool_prefix goes away. disabled goes away too: not
calling define_mcp_client does the same.

The error classes become private GenkitError subclasses: a closed
client is FAILED_PRECONDITION, a server that cannot start or dies is
UNAVAILABLE, and a protocol violation is INTERNAL.
hilariie pushed a commit that referenced this pull request Oct 29, 2026
…lic surface

The Python plugins on main export only what a caller needs and take
flat keyword arguments instead of nested option objects (#6671, #6706).
The client now does the same.

define_mcp_client and McpClient take command, args, env and cwd as
keyword arguments and build the stdio config internally. The provider
name is also the tool name prefix, as in the Go plugin, so tool_prefix
and the tool_prefix property go away, and the name has to satisfy the
tool name rule as well as the selector rule. disabled goes away: not
calling define_mcp_client does the same.

create_mcp_client goes away. An unregistered client has no use on its
own while generate(tools=) takes names rather than actions, and McpClient
is still there for the host to build clients without registering each.
dynamic_action_provider becomes private: no caller outside the package
needs it.

The package exports McpClient and define_mcp_client. Errors are
GenkitError with a status, as for the other plugins after #6710, so the
error classes are no longer exported. A test pins the exported names,
replacing the smoke test main deleted.
hilariie pushed a commit that referenced this pull request Oct 29, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
hilariie pushed a commit that referenced this pull request Oct 30, 2026
…ping

The host follows the same surface rules as the client: no exported
nested config, flat keyword arguments, and only names a caller needs
(#6671, #6706).

define_mcp_host and McpHost take mcp_servers=, a mapping in the shape of
the mcpServers block Claude Desktop and Cursor read, so a block loaded
from one of those files passes straight through. Each entry is validated
into the internal stdio config, so a misspelt key still fails without
echoing values. connect takes command, args, env and cwd as keyword
arguments, as define_mcp_client does.

The mapping key is the server name and its tool name prefix, as in the
Go plugin. Keys are unique, so the shared-prefix check and tool_prefix
go away. McpHostServer and create_mcp_host go away, server_names goes
(tests read the host's clients), and dynamic_action_provider becomes
private.

The package now exports McpClient, McpHost, define_mcp_client and
define_mcp_host, which the exports test pins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore config docs Improvements or additions to documentation python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants