Skip to content

Pin the prompt-cache provider gate against its class-name fallback - #61

Merged
rezaho merged 1 commit into
mainfrom
s349-provider-gate-test
Sep 11, 2026
Merged

rezaho merged 1 commit into
mainfrom
s349-provider-gate-test

Conversation

@rezaho

@rezaho rezaho commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Follow-up to #60, tests only, no behaviour change.

The explicit prompt-cache fields are gated on the provider, and the gate reads the provider the factory stamped on the adapter, falling back to the adapter's own class name. That fallback answers "openai" for the very class every unrecognized provider is routed to. Through the factory the stamp always decides and the fallback never runs, so nothing in the suite depended on it and a later edit to _provider_name could have moved which endpoints receive the fields without failing a test.

Three tests in tests/models/test_openai_prompt_cache.py state the matrix directly:

  • A hand-built adapter carries no stamp and is taken at its class name, which is the intended reading: constructing OpenAIAdapter by hand says the request is bound for OpenAI's own endpoint, and AzureOpenAIAdapter pins azure the same way. Both name a surface the fields were measured on.
  • A stamped foreign provider (xai, groq, an unknown gateway) closes the gate whichever class carries the stamp. A factory-built payload cannot show this on its own, since the factory picks the class and writes the stamp together.
  • openrouter and xai through the factory, which route to OpenRouterAdapter and its own chat-completions body, receive nothing.

Checked by mutation: dropping the stamp read fails 12 of the new cases, and dropping the fallback fails 76 across the file.

pytest tests/models -q: 871 passed, 39 skipped. No network anywhere in the file.

The gate reads the provider the factory stamped on the adapter and falls back
to the adapter's own class name, which answers "openai" for the very class
every unrecognized provider is routed to. Through the factory the stamp always
decides and the fallback never runs, so a later edit to _provider_name could
move which endpoints receive the fields without failing anything.

Three tests state the matrix the gate is written against. A hand-built adapter
carries no stamp and is taken at its class name, which is the intended reading:
constructing OpenAIAdapter by hand says the request is bound for OpenAI's own
endpoint, and the Azure subclass pins azure the same way. A stamped foreign
provider closes the gate whichever class carries the stamp, which is the part a
factory-built payload cannot show on its own, since the factory picks the class
and writes the stamp together. And openrouter and xai, which the factory hands
to their own builder, are pinned as receiving nothing.

No behaviour change.
@rezaho
rezaho merged commit 5b59f46 into main Sep 11, 2026
1 check passed
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.

1 participant