SIGN IN SIGN UP

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>
G
Greg Holmes committed
ffd2e7d7e0e0ea2d72e13e1d4c91ac52e97a5ee8
Parent: 9d9a43d
Committed by GitHub <noreply@github.com> on 5/18/2026, 9:10:17 AM