2/2 Implement explicit model gateway - #2440
Conversation
|
d2b2604 to
7f253fa
Compare
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
7f253fa to
63fbb89
Compare
beb241b to
5fba8ca
Compare
There was a problem hiding this comment.
1 issue found across 15 files (changes from recent commits).
Confidence score: 4/5
- In
packages/sdk-python/src/stagehand/client_models.py, theStagehand(...)constructor now throws a raw Pydantic extra-field error when callers passmodel_api_keyormodel_headersfor Browserbase gateway models, which can break previously working client initialization with an opaque message—add explicit handling that rejects or ignores these fields with a clear SDK-level error/migration hint.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/sdk-python/src/stagehand/client_models.py">
<violation number="1" location="packages/sdk-python/src/stagehand/client_models.py:161">
P3: Constructing `Stagehand(model="browserbase/...", model_api_key=...)` or passing `model_headers` now raises a raw Pydantic extra-field validation error. Browserbase gateway models have no per-model connection fields; reject those options explicitly with the SDK's argument-validation path (or otherwise handle them) before expanding `connection`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| if base_url is None: | ||
| if model.startswith("browserbase/"): | ||
| return ModelConfig( | ||
| root=BrowserbaseModelConfig.model_validate({ |
There was a problem hiding this comment.
P3: Constructing Stagehand(model="browserbase/...", model_api_key=...) or passing model_headers now raises a raw Pydantic extra-field validation error. Browserbase gateway models have no per-model connection fields; reject those options explicitly with the SDK's argument-validation path (or otherwise handle them) before expanding connection.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/sdk-python/src/stagehand/client_models.py, line 161:
<comment>Constructing `Stagehand(model="browserbase/...", model_api_key=...)` or passing `model_headers` now raises a raw Pydantic extra-field validation error. Browserbase gateway models have no per-model connection fields; reject those options explicitly with the SDK's argument-validation path (or otherwise handle them) before expanding `connection`.</comment>
<file context>
@@ -155,6 +156,13 @@ def _model_config(
if base_url is None:
+ if model.startswith("browserbase/"):
+ return ModelConfig(
+ root=BrowserbaseModelConfig.model_validate({
+ "model_name": model,
+ **connection,
</file context>
Why
#2438 makes model routing explicit in the protocol. This PR implements that contract in the runtime.
Model IDs from integrated providers are intentionally open:
openai/gpt-future-previewis valid direct-provider input without a Stagehand catalog update. The runtime still validates the stable configuration choices it owns: direct credentials, Browserbase gateway selection, and custom endpoint configuration.What changed
Adds one server-side resolver with three execution targets:
Dispatches on the resolved target instead of treating a missing provider API key as Browserbase routing.
Adds the Browserbase gateway client, which:
Implements the OpenAI-compatible endpoint path.
Updates direct-provider adapters to forward an open provider model ID.
Removes all runtime handling of
type: "unlisted".Test plan