Skip to content

Commit ffd2e7d

Browse files
fix: (regen) route think/models to env.agent_rest (#715)
## Summary SDK regeneration 2026-05-15. All 20 temporarily frozen files reviewed; all 20 patches re-applied (no patches dropped this cycle — see "near-miss" note below). ## Patches re-applied - `core/query_encoder.py` — bool→lowercase coercion for websocket query strings (7.1.1 fix). - `tests/wire/test_manage_v1_projects_keys.py` — wire test for legacy `CreateKeyV1RequestOneParams` alias. - 4 socket clients (`speak/v1`, `listen/v1`, `listen/v2`, `agent/v1`) — broad `except Exception` (custom transports), optional `message=` defaults on control sends. - `agent/v1/socket_client.py` — additionally restored `_sanitize_numeric_types` (float→int sanitizer). - `listen/v2/socket_client.py` — additionally kept `send_configure` as `typing.Any`/raw `_send` shim and `typing.Any` in response Union (generator now emits `ListenV2Configure`/`ListenV2ConfigureSuccess` but we don't yet have evidence the new typed models are wire-correct). - 7 agent-settings types/requests preserving callable `AgentV1SettingsAgent(...)`, `AgentV1Settings.agent` accepting both wrapper and `agent_id` strings, legacy `messages=[...]` migration, `.messages` read-side property, and `audio.output.container` as `str`. - 7 package `__init__.py` files restoring compat re-exports: `CreateKeyV1RequestOne(+Params)`, `AgentV1HistoryContent(+Params)`, `AgentV1HistoryFunctionCalls(+Params)`, `AgentV1SettingsAgentContextMessagesItem*(+Params)`, `AgentV1SettingsAgent[Context]ListenProviderV1/V2/V2LanguageHint(+Params)`. ## Generator changes worth flagging - `AgentV1SettingsAgent` is now a Union alias (`Union[AgentV1SettingsAgentContext, str]`) in fresh generator output — callable usage would break. We continue to patch back to a class with `model_validator` for backward compat. - `audio_output.container` regenerated as `AgentV1SettingsAudioOutputContainer` enum; we keep `str`. - `messages` field removed from `AgentV1SettingsAgentContext(Params)`; canonical shape is `context.messages`. - `agent/v1/settings/think/models/raw_client.py` route now hits `environment.agent_rest`. ## `DeepgramClientEnvironment` change — intentional fix, not a break The regen drops `DeepgramClientEnvironment.AGENT` and adds a required `agent_rest` kwarg to `DeepgramClientEnvironment.__init__`. This is fixing the previously broken `agent.v1.settings.think.models.list()` route: the old `.AGENT` env routed REST traffic to the wrong host, so any caller of that endpoint was already broken. The new `agent_rest` slot is the dedicated REST host for agent-served endpoints. JS SDK equivalent (deepgram-js-sdk#499 → `56b8ce5`) also needed a `src/Client.ts` patch because `client.fetch()` passthrough started defaulting to `agentRest` instead of `base`. The Python SDK has no equivalent passthrough in the hand-maintained `client.py`, so no analogous patch is needed here. ## Near miss Initial review classified `agent/v1/types/agent_v1settings.py` and `agent/v1/requests/agent_v1settings.py` as droppable (new generator declares `agent: AgentV1SettingsAgent` and the new `AgentV1SettingsAgent` is itself `Union[AgentV1SettingsAgentContext, str]`, structurally equivalent). Pytest caught the issue: because we patch `AgentV1SettingsAgent` back to a class (for callable backward compat), the bare `agent: AgentV1SettingsAgent` field rejects string values. Both patches restored to broaden to `Union[AgentV1SettingsAgent, AgentV1SettingsAgentContext, str]`. `tests/custom/test_compat_aliases.py` covers this regression. ## Validation - `uv run pytest -q` → 199 passed, 4 skipped - `uv run mypy src` → clean (801 files) - `uv run ruff check src tests` → 57 errors, all pre-existing on main in `tests/manual/` (untouched by regen) ## Test plan - [x] Re-apply manual patches after regen. - [x] Restore `.fernignore` originals; drop `.bak` shadow paths. - [x] Delete all `.bak` files. - [x] `pytest`, `ruff check`, `mypy` validated (with caveats above). --------- Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 9d9a43d commit ffd2e7d

7 files changed

Lines changed: 19 additions & 17 deletions

File tree

.fern/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"skip_validation": true
1717
}
1818
},
19-
"originGitCommit": "0052a020a7becd03b349857664c9f4a89b6c449a",
19+
"originGitCommit": "d228f82e93aaa8aa77f978d458cf912f3daaa8c1",
2020
"originGitCommitIsDirty": true,
2121
"invokedBy": "manual",
2222
"sdkVersion": "7.1.2"

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dynamic = ["version"]
44

55
[tool.poetry]
66
name = "deepgram-sdk"
7-
version = "7.1.1"
7+
version = "7.1.2"
88
description = ""
99
readme = "README.md"
1010
authors = []

src/deepgram/agent/v1/settings/think/models/raw_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def list(
3636
"""
3737
_response = self._client_wrapper.httpx_client.request(
3838
"v1/agent/settings/think/models",
39-
base_url=self._client_wrapper.get_environment().agent,
39+
base_url=self._client_wrapper.get_environment().agent_rest,
4040
method="GET",
4141
request_options=request_options,
4242
)
@@ -93,7 +93,7 @@ async def list(
9393
"""
9494
_response = await self._client_wrapper.httpx_client.request(
9595
"v1/agent/settings/think/models",
96-
base_url=self._client_wrapper.get_environment().agent,
96+
base_url=self._client_wrapper.get_environment().agent_rest,
9797
method="GET",
9898
request_options=request_options,
9999
)

src/deepgram/core/client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ def get_headers(self) -> typing.Dict[str, str]:
2828
import platform
2929

3030
headers: typing.Dict[str, str] = {
31-
"User-Agent": "deepgram-sdk/7.1.1",
31+
"User-Agent": "deepgram-sdk/7.1.2",
3232
"X-Fern-Language": "Python",
3333
"X-Fern-Runtime": f"python/{platform.python_version()}",
3434
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
3535
"X-Fern-SDK-Name": "deepgram-sdk",
36-
"X-Fern-SDK-Version": "7.1.1",
36+
"X-Fern-SDK-Version": "7.1.2",
3737
**(self.get_custom_headers() or {}),
3838
}
3939
headers["Authorization"] = f"Token {self.api_key}"

src/deepgram/environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
class DeepgramClientEnvironment:
77
PRODUCTION: DeepgramClientEnvironment
8-
AGENT: DeepgramClientEnvironment
98

10-
def __init__(self, *, base: str, production: str, agent: str):
9+
def __init__(self, *, base: str, production: str, agent: str, agent_rest: str):
1110
self.base = base
1211
self.production = production
1312
self.agent = agent
13+
self.agent_rest = agent_rest
1414

1515

1616
DeepgramClientEnvironment.PRODUCTION = DeepgramClientEnvironment(
17-
base="https://api.deepgram.com", production="wss://api.deepgram.com", agent="wss://agent.deepgram.com"
18-
)
19-
DeepgramClientEnvironment.AGENT = DeepgramClientEnvironment(
20-
base="https://agent.deepgram.com", production="wss://api.deepgram.com", agent="wss://agent.deepgram.com"
17+
base="https://api.deepgram.com",
18+
production="wss://api.deepgram.com",
19+
agent="wss://agent.deepgram.com",
20+
agent_rest="https://agent.deepgram.com",
2121
)

tests/wire/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ def get_client(test_id: str) -> DeepgramClient:
4545

4646
if _CLIENT_SUPPORTS_HEADERS:
4747
return DeepgramClient(
48-
environment=DeepgramClientEnvironment(base=base_url, production=base_url, agent=base_url),
48+
environment=DeepgramClientEnvironment(
49+
base=base_url, production=base_url, agent=base_url, agent_rest=base_url
50+
),
4951
headers=test_headers,
5052
api_key="test_api_key",
5153
)
5254

5355
return DeepgramClient(
54-
environment=DeepgramClientEnvironment(base=base_url, production=base_url, agent=base_url),
56+
environment=DeepgramClientEnvironment(base=base_url, production=base_url, agent=base_url, agent_rest=base_url),
5557
httpx_client=httpx.Client(headers=test_headers),
5658
api_key="test_api_key",
5759
)

0 commit comments

Comments
 (0)