Skip to content

Commit f6fd3af

Browse files
fix: (regen) route think/models to env.agentRest (#59)
## Summary SDK regeneration 2026-05-15. Both temporarily frozen files reviewed; both patches re-applied (no patches dropped this cycle). ## Patches re-applied - `src/main/java/com/deepgram/core/ClientOptions.java` — restored correct `User-Agent` / `X-Fern-SDK-Name` (`com.deepgram:deepgram-java-sdk`, version `0.4.0`) and the `// x-release-please-version` markers. Generator regen still rewrites these to the wrong artifact id (`com.deepgram:deepgram-sdk` / `com.deepgram.fern:api-sdk`) and strips the markers. - `src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java` — restored `applyOptionsOverride(...)` runtime hook (used by `TransportWebSocketFactory` to apply `DeepgramTransportFactory.reconnectOptions()` without editing generated WS clients), `volatile` qualifier on option-derived fields, configurable `connectionTimeoutMs` on `ReconnectOptions` (was hardcoded 4000ms), and the `maxRetries(0)` "connect once, don't retry" semantics (`retryCount > maxRetries`, not `>=`). ## Generator changes worth flagging - `Environment` constructor signature changed from 3-arg to 4-arg with a new `agentRest` field, plus `getAgentRestURL()` and `Environment.Builder#agentRest(...)`. - `resources/agent/v1/settings/think/models/{Raw,AsyncRaw}ModelsClient.java` now route via `environment().getAgentRestURL()` instead of `getAgentURL()`. - `.fern/metadata.json` bumped `sdkVersion: 0.4.1`. ## `Environment` change — intentional fix, not a break The regen drops `Environment.AGENT` and adds a new `agentRest` slot to `Environment` (with a 4-arg constructor and corresponding builder method). 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 `agentRest` slot is the dedicated REST host for agent-served endpoints. Equivalent fix in Python SDK: deepgram/deepgram-python-sdk#715. JS SDK equivalent (deepgram-js-sdk#499) additionally needed a `src/Client.ts` patch because `client.fetch()` passthrough started defaulting to `agentRest` instead of `base`. The Java SDK has no equivalent passthrough in the hand-maintained `DeepgramClient`/`DeepgramClientBuilder`, so no analogous patch is needed here. Hand-maintained tests that referenced `Environment.AGENT` (`EnvironmentTest`'s `AGENT environment` nested class and `ClientBuilderTest#testAgentEnvironment`) were updated to build an agent-shaped environment via `Environment.custom().agentRest(...)`. ## Validation - `./gradlew test compileExamples` → BUILD SUCCESSFUL - `ReconnectingWebSocketListenerTest` covers the re-applied patches: `applyOptionsOverride`, `maxRetries(0)` initial-attempt allowance, `connectionTimeoutMs` configurability — all green - All `.bak` files deleted; `.fernignore` paths restored to originals for both still-patched files ## Test plan - [x] Re-apply manual patches after regen. - [x] Restore `.fernignore` originals; drop `.bak` shadow paths. - [x] Delete all `.bak` files. - [x] `./gradlew test compileExamples` validated. --------- Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com>
1 parent fccb3e3 commit f6fd3af

6 files changed

Lines changed: 46 additions & 16 deletions

File tree

.fern/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"enable-wire-tests": true
1313
},
14-
"originGitCommit": "0052a020a7becd03b349857664c9f4a89b6c449a",
14+
"originGitCommit": "d228f82e93aaa8aa77f978d458cf912f3daaa8c1",
1515
"originGitCommitIsDirty": true,
1616
"invokedBy": "manual",
1717
"sdkVersion": "0.4.1"

src/main/java/com/deepgram/core/Environment.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@
44
package com.deepgram.core;
55

66
public final class Environment {
7-
public static final Environment PRODUCTION =
8-
new Environment("https://api.deepgram.com", "wss://api.deepgram.com", "wss://agent.deepgram.com");
9-
10-
public static final Environment AGENT =
11-
new Environment("https://agent.deepgram.com", "wss://api.deepgram.com", "wss://agent.deepgram.com");
7+
public static final Environment PRODUCTION = new Environment(
8+
"https://api.deepgram.com",
9+
"wss://api.deepgram.com",
10+
"wss://agent.deepgram.com",
11+
"https://agent.deepgram.com");
1212

1313
private final String base;
1414

1515
private final String production;
1616

1717
private final String agent;
1818

19-
Environment(String base, String production, String agent) {
19+
private final String agentRest;
20+
21+
Environment(String base, String production, String agent, String agentRest) {
2022
this.base = base;
2123
this.production = production;
2224
this.agent = agent;
25+
this.agentRest = agentRest;
2326
}
2427

2528
public String getBaseURL() {
@@ -34,6 +37,10 @@ public String getAgentURL() {
3437
return this.agent;
3538
}
3639

40+
public String getAgentRestURL() {
41+
return this.agentRest;
42+
}
43+
3744
public static Builder custom() {
3845
return new Builder();
3946
}
@@ -45,6 +52,8 @@ public static class Builder {
4552

4653
private String agent;
4754

55+
private String agentRest;
56+
4857
public Builder base(String base) {
4958
this.base = base;
5059
return this;
@@ -60,8 +69,13 @@ public Builder agent(String agent) {
6069
return this;
6170
}
6271

72+
public Builder agentRest(String agentRest) {
73+
this.agentRest = agentRest;
74+
return this;
75+
}
76+
6377
public Environment build() {
64-
return new Environment(base, production, agent);
78+
return new Environment(base, production, agent, agentRest);
6579
}
6680
}
6781
}

src/main/java/com/deepgram/resources/agent/v1/settings/think/models/AsyncRawModelsClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public CompletableFuture<DeepgramApiHttpResponse<AgentThinkModelsV1Response>> li
4242
* Retrieves the available think models that can be used for AI agent processing
4343
*/
4444
public CompletableFuture<DeepgramApiHttpResponse<AgentThinkModelsV1Response>> list(RequestOptions requestOptions) {
45-
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentURL())
45+
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentRestURL())
4646
.newBuilder()
4747
.addPathSegments("v1/agent/settings/think/models");
4848
if (requestOptions != null) {

src/main/java/com/deepgram/resources/agent/v1/settings/think/models/RawModelsClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public DeepgramApiHttpResponse<AgentThinkModelsV1Response> list() {
3838
* Retrieves the available think models that can be used for AI agent processing
3939
*/
4040
public DeepgramApiHttpResponse<AgentThinkModelsV1Response> list(RequestOptions requestOptions) {
41-
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentURL())
41+
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentRestURL())
4242
.newBuilder()
4343
.addPathSegments("v1/agent/settings/think/models");
4444
if (requestOptions != null) {

src/test/java/com/deepgram/ClientBuilderTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ void testDefaultEnvironment() {
4747
}
4848

4949
@Test
50-
@DisplayName("accepts AGENT environment")
50+
@DisplayName("accepts an agent-shaped environment")
5151
void testAgentEnvironment() {
52+
Environment agent = Environment.custom()
53+
.base("https://agent.deepgram.com")
54+
.agent("wss://agent.deepgram.com")
55+
.production("wss://api.deepgram.com")
56+
.agentRest("https://agent.deepgram.com")
57+
.build();
58+
5259
DeepgramClient client = DeepgramClient.builder()
5360
.apiKey("test-key")
54-
.environment(Environment.AGENT)
61+
.environment(agent)
5562
.build();
5663

5764
assertThat(client).isNotNull();

src/test/java/com/deepgram/core/EnvironmentTest.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,34 @@ void testProductionUrl() {
3333
}
3434

3535
@Nested
36-
@DisplayName("AGENT environment")
36+
@DisplayName("Agent-shaped custom environment")
3737
class AgentEnvironment {
3838

39+
private Environment agent() {
40+
return Environment.custom()
41+
.base("https://agent.deepgram.com")
42+
.agent("wss://agent.deepgram.com")
43+
.production("wss://api.deepgram.com")
44+
.agentRest("https://agent.deepgram.com")
45+
.build();
46+
}
47+
3948
@Test
4049
@DisplayName("base URL points to agent.deepgram.com")
4150
void testBaseUrl() {
42-
assertThat(Environment.AGENT.getBaseURL()).isEqualTo("https://agent.deepgram.com");
51+
assertThat(agent().getBaseURL()).isEqualTo("https://agent.deepgram.com");
4352
}
4453

4554
@Test
4655
@DisplayName("agent URL points to wss://agent.deepgram.com")
4756
void testAgentUrl() {
48-
assertThat(Environment.AGENT.getAgentURL()).isEqualTo("wss://agent.deepgram.com");
57+
assertThat(agent().getAgentURL()).isEqualTo("wss://agent.deepgram.com");
4958
}
5059

5160
@Test
5261
@DisplayName("production URL uses wss://api.deepgram.com")
5362
void testProductionUrl() {
54-
assertThat(Environment.AGENT.getProductionURL()).isEqualTo("wss://api.deepgram.com");
63+
assertThat(agent().getProductionURL()).isEqualTo("wss://api.deepgram.com");
5564
}
5665
}
5766

0 commit comments

Comments
 (0)