Running the store's assistant on any model
How this reference runs the blueprint's shopping agent on a provider other than Claude, what the provider contract looks like, what each provider gives up, and exactly which of it was verified.
Anthropic's Claude Commerce Agents blueprint defines each agent once (prompt, skills, tool contracts, gates) and runs it on the Messages API, the Claude Agent SDK and Managed Agents. Of its 53 runtime modules, nine import the Anthropic SDK or the Claude Agent SDK, nine speak a Messages API shape without importing it, and 35 are model-free (Skills and modules has the inventory). The nine coupled modules are the turn loops and the memory extraction call. Everything that makes the agent safe (the provenance gate, the cart caps, the data fence, the presentation contract, the skills, the prompt text) sits in the 35.
That is why a model-agnostic version is a new turn loop over the old executor. psp_commerce/runtime/ holds it: a provider contract, four providers, pure conversion functions, and AgnosticShoppingAgent, which imports the blueprint's prompt builders, tool registry, executor, grounding rules, memory runtime and event types unchanged and calls a provider where the blueprint calls client.messages.stream.
The provider contract
psp_commerce/runtime/provider.py defines one method. A provider takes the system text, the conversation, the tool contracts and a token budget, and returns one model turn:
class ModelProvider(Protocol):
name: str
model: str
async def complete(self, *, system: str, messages: list[dict], tools: list[dict], max_tokens: int = 2048) -> ProviderTurn: ...
ProviderTurn carries the text the model wrote, its tool_calls (each a ToolCall with id, name and input), a stop_reason, a usage dictionary with input_tokens and output_tokens, and the provider's raw response. An optional StreamingProvider protocol adds stream_text for text deltas; none of the shipped providers implements it.
The contract leaves four things out on purpose: prompt-cache breakpoints, forced tool choice, streamed partial tool JSON, and server tools. A provider that has an equivalent may use it; the loop depends on none of them.
The canonical shape
The conversation the loop keeps is in the Messages API's block format, because the blueprint's executor, serialization, tests and fixtures already speak it:
{"role": "user", "content": "a family tent under $250"}
{"role": "assistant", "content": [{"type": "text", "text": "Looking."},
{"type": "tool_use", "id": "c1", "name": "search_products", "input": {"query": "family tent"}}]}
{"role": "user", "content": [{"type": "tool_result", "tool_use_id": "c1", "content": "<storefront_data>…</storefront_data>"}]}
Tools keep the blueprint's shape too: a name, a description and a JSON Schema input_schema. Each provider converts to and from its own wire format in psp_commerce/runtime/convert.py, pure functions with unit tests against the documented formats.
| Canonical | OpenAI Chat Completions | Gemini (google-genai) |
|---|---|---|
| system text | the first message, role: "system" |
system_instruction in the request config |
| a tool | {"type": "function", "function": {name, description, parameters}} |
a FunctionDeclaration with parameters_json_schema |
assistant tool_use block |
an entry in tool_calls with JSON-string arguments |
a function_call part in a role: "model" content |
tool_result block |
a role: "tool" message keyed by tool_call_id |
a function_response part in a role: "tool" content |
| tool call id | the provider's id | none; the converter assigns gem-<n> in order and matches results back by position |
| usage | prompt_tokens, completion_tokens |
prompt_token_count, candidates_token_count |
Two converter details matter. anthropic_tools_only keeps only tools that carry an input_schema, which drops the blueprint's server tools (web search, code execution); strip_cache_control removes the cache markers. And a Gemini function_response needs the function's name, which the canonical tool_result block lacks, so messages_to_gemini remembers each call's name by id as it walks the conversation.
The four providers
psp_commerce/runtime/providers.py ships four implementations. The vendor SDKs are imported inside the constructors, so the converters, the scripted provider and the tests run with none installed; pip install openai google-genai adds the other two.
| Provider | Default model | Wire call | Notes |
|---|---|---|---|
AnthropicProvider |
claude-sonnet-5 |
messages.create with the canonical blocks |
the plain version: no cache breakpoints, no forced tool choice, no streaming; a deployment on Claude should use the blueprint's own runtime |
OpenAICompatibleProvider |
gpt-5 |
chat.completions.create with tools, tool_choice: "auto", max_completion_tokens |
base_url and api_key point it at OpenAI, Azure OpenAI, or any server that speaks the endpoint (the docstring names Bedrock's OpenAI-compatible endpoint, vLLM, Ollama and a LiteLLM gateway) |
GeminiProvider |
gemini-2.5-pro |
client.aio.models.generate_content with function declarations |
automatic function calling disabled so the loop stays in charge of every call |
ScriptedProvider |
scripted-model |
none | plays back prepared ProviderTurns and records every request; what the tests run |
The loop
AgnosticShoppingAgent in psp_commerce/runtime/loop.py is one deployment of the shopping agent on one provider. Its constructor builds the static system prompt and the tool list once, as the blueprint does, from the config, the skills directory and any presentation extensions (the tender card registers exactly as it does on Claude). stream_turn(messages, session, state) yields the same AgentEvent stream the blueprint's runtime yields: text_delta, tool_call, ui, cart_update and turn_complete, the last carrying usage totals, the round count, the provider's name and the model id.
docs/MODEL-AGNOSTIC.md.| Blueprint's loop | Agnostic loop | Reason |
|---|---|---|
| one streamed round; tool calls dispatched as their JSON completes | one complete() per round; tools run after the round returns |
streamed partial tool JSON is a Messages API shape; most providers deliver tool calls whole |
grounding by a forced tool_choice on the first round when a rule fires |
grounding by prefetch: the host runs the rule's read before the first call and appends the result to the context under a "Grounding" heading; the terms rule, whose query is the model's to write, becomes a hint | a provider may not support forcing a tool; prefetch works on all of them |
| cache breakpoints after the static text, after the last tool, rolling through the conversation | none; cache_control stripped; the static text is still built once |
a provider with caching applies its own |
| server tools registered when enabled | not registered | no provider-neutral equivalent |
| memory extraction after the turn | off: tier-one facts are read, the extraction pass is never called, nothing is written | the extraction pass is one of the nine coupled modules |
| compaction of long conversations | not implemented | out of scope for a reference |
What is identical: the static prompt, the per-request context, the tool contracts (minus server tools and cache markers), the executor with every gate and fence, the presentation extensions, the skills registry and load_skill, the round-closing rule (the round that carries the chips ends the turn), and the events the web apps render. Out of rounds, the loop makes one closing call with no tools, as the blueprint forces.
Nothing in the safety column moves. The provenance gate, the options gate, the write lock, the caps and the fences run in the executor on every provider because the executor is the same object. A provider that returns a tool call for a product the session never saw gets the same refusal Claude would.
What each provider loses
| Capability in the blueprint | Plain Anthropic provider | OpenAI-compatible | Gemini | Effect |
|---|---|---|---|---|
| prompt caching at three breakpoints | available if the markers are added back | automatic prefix caching on OpenAI for long prompts; other compatible servers vary | context caching exists, explicit and priced; not wired | cost and latency |
| forced first read | available | available through tool_choice naming a function |
available through a function-calling config | the loop uses prefetch on all three so behavior is uniform |
| streamed partial tool JSON, eager dispatch | available | argument fragments stream; the loop would need a reassembler | not streamed per call | first-token latency on multi-tool rounds |
| server tools: web search, code execution | available | web search on the Responses API only | search grounding exists | the optional web search is off; the merchant agent's analysis delegate is not ported |
| extended thinking or effort | thinking |
reasoning_effort on reasoning models |
a thinking budget | not passed; each provider's default applies |
| memory extraction | call the blueprint's MemoryRuntime.extract after the turn |
write an extractor on Chat Completions | write an extractor on generate_content |
none is done here; facts still read from the store |
Text streaming to the host is available on all three and implemented in none of the plain providers; StreamingProvider is the hook. The OpenAI and Gemini rows describe the vendors' documented features as the providers were written against them; the reference has not measured them live.
Running the store's assistant on another provider
The agent takes any merchant backend in this reference. This is the shape tests/test_runtime_agnostic.py uses, with a real provider in place of the scripted one:
from commerce_core import build_tender_options_extension
from psp_commerce.runtime import AgnosticShoppingAgent, GeminiProvider, OpenAICompatibleProvider
from psp_commerce.skills_dir import skills_dir
provider = OpenAICompatibleProvider(model="gpt-5") # OPENAI_API_KEY
provider = OpenAICompatibleProvider(model="llama3.3", base_url="http://localhost:11434/v1", api_key="ollama")
provider = GeminiProvider(model="gemini-2.5-pro") # GOOGLE_API_KEY
agent = AgnosticShoppingAgent(
backend=backend, provider=provider, config=config, skills_dir=skills_dir("shopping"),
extra_presentation_tools=[build_tender_options_extension()],
)
async for event in agent.stream_turn(messages, session, state):
...
backend and config come from a merchant package (verticals/northstar_outfitters/api/backend.py and agent_config.py, for example); executor_class is accepted for a vertical that subclasses the executor. The demo APIs in verticals/*/api/main.py construct the blueprint's own ShoppingAgent on Claude. The agnostic agent yields the same events but has no update_memory method, which the demo host calls after each turn, so wiring it into a demo API means adding that method (a no-op, or an extractor written on the provider). The path the reference does expose by flag is the platform agent.
The platform agent on any provider
scripts/platform_agent.py is a platform agent, a third-party agent that does not belong to the store, shopping at a merchant over UCP (Universal Commerce Protocol); Third-party agents describes it in full. Without --model it is scripted. With --model a model drives the merchant's five proxied tools (search_catalog, get_product, create_cart, create_checkout, get_checkout) through the same provider contract, and the script prints every call.
python scripts/platform_agent.py --merchant http://localhost:8016 --goal "a reading lamp under 60 dollars" --model --provider openai
python scripts/platform_agent.py --merchant http://localhost:8016 --goal "a reading lamp under 60 dollars" --model --provider gemini
--provider is anthropic (the default), openai or gemini, reading ANTHROPIC_API_KEY, OPENAI_API_KEY or GOOGLE_API_KEY. --model takes an optional model id; without one the provider's default applies. --base-url points the OpenAI provider at any OpenAI-compatible endpoint, and when it is given with no OPENAI_API_KEY in the environment the script fills in the placeholder key ollama:
python scripts/platform_agent.py --merchant http://localhost:8016 --goal "a reading lamp under 60 dollars" --model llama3.3 --provider openai --base-url http://localhost:11434/v1
The script's model loop (with_model) keeps the conversation in the canonical block shape, calls provider.complete with the five tool schemas, executes the calls against the merchant's /api/ucp/mcp endpoint, and stops when the model reports the checkout: the item, the total, the continue_url where the shopper pays on the processor's page, and the payment handlers the merchant accepts. The system text tells it never to claim to have paid.
What was verified
| Path | Status |
|---|---|
The platform agent driven by Claude (--model, the Anthropic provider) |
run live against Lumen Home on Stripe on 6 September 2026; the model searched, read one product, built the cart, created the checkout and reported Stripe's continue_url and the handlers; the scripted form ran against Aurora Escapes on Adyen on 7 September 2026 |
| The store's assistant on Claude | the blueprint's own runtime, run live on the Stripe and Adyen merchants on 6 and 7 September 2026 |
AgnosticShoppingAgent on the scripted provider |
tests/test_runtime_agnostic.py: three scripted turns (search, add, checkout with chips) on Northstar Outfitters; the checkout card carries the hosted URL, the provider was called exactly three times, no request body contains the URL or the word checkout_url; a second test shows a fixture order id reaching the system text through the grounding prefetch |
| The OpenAI and Gemini converters | unit-tested both ways against the documented shapes (test_tool_conversion_shapes, test_message_conversion_round_trips) |
| The platform agent on a scripted provider | tests/test_demo_paths.py::test_platform_agent_runs_on_any_provider |
| OpenAI and Gemini live | not run in this repository |
The repository-wide list is What is verified.
.venv/bin/python -m pytest tests/test_runtime_agnostic.py -q
4 passed
Two limits are worth stating plainly. Only the shopping agent is ported; the merchant agent's loop has the same shape and would port the same way, minus its analysis delegate, which depends on the code_execution server tool. And the plain Anthropic provider exists to prove the contract; on Claude, the blueprint's runtime keeps caching, forced reads and streaming, and is the one to deploy.