Skip to content

feat(regen): agent function cancellation and defer-until-EOT - #110

Merged
GregHolmes merged 9 commits into
mainfrom
gh/sdk-gen-2026-09-16
Sep 17, 2026
Merged

GregHolmes merged 9 commits into
mainfrom
gh/sdk-gen-2026-09-16

Conversation

@GregHolmes

@GregHolmes GregHolmes commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Regenerates the Java SDK with fernapi/fern-java-sdk 4.19.3.
  • Adds Agent function-cancellation events and the optional deferUntilEot function setting.
  • Retains the release-version headers, reconnect timeout and transport override behavior, streaming query serialization, V2 forward-compatible dispatch, fields-less message hashCode() fixes, FLUX_RENEE_EN, and agent provider default variants.
  • Completes peer-close handshakes so server-initiated closes move the ready state to CLOSED and invoke onDisconnected.
  • Adds a Listen V2 policy that suppresses reconnect only when the same socket successfully sent CloseStream before a no-status (1005) close.
  • Adds server-close coverage for peer-initiated closure, successful and rejected CloseStream, and stale terminal-state reset.

Follow-up

  • deepgram/deepgram-docs#1217 models Listen V2 Warning frames in AsyncAPI. The existing forward-compatible dispatcher already delivers unknown frames through onMessage(String) without calling onError; typed onWarning(...) support will ship in the next Fern regeneration cycle. This PR does not depend on #1217.

Upstreamed

Fern now supplies peer-close acknowledgement, maps local 1005 to wire-valid 1000, exposes callback-aware sends, and provides shouldReconnectAfterClose. The previous duplicate core implementation of those behaviors was not restored.

Production availability

  • Listen V2 ForceEndTurn is available on the hosted API. Self-hosted deployments may require enablement.

Validation

  • ./gradlew spotlessCheck test compileExamples
  • Targeted live integration and WebSocket E2E tests, excluding Management APIs
  • Post-regen fields-less hashCode() sweep (only the documented Nullable utility exceptions remain)

@dg-coreylweathers dg-coreylweathers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes — the regeneration landed but the re-apply step hasn't run, so all 23 hand-applied patches are currently overwritten and CI is red on all five checks.

I verified the re-apply is the only thing missing: in an isolated clone, restoring the 23 files from their .bak copies and deleting the backups produced BUILD SUCCESSFUL on ./gradlew compileJava test, with all 27 guard tests passing. On this branch those guards never execute, because compileJava fails first (and RegenTypesTest wouldn't compile either — it references DeepgramModel.FLUX_RENEE_EN, which this regen deleted).

Blocking:

  1. Build is broken. TransportWebSocketFactory.java:39 calls applyOptionsOverride(ReconnectOptions), removed with the ReconnectingWebSocketListener patch. Fails on Java 11/17/21.

  2. Streaming escape hatch gone. The additionalProperties block is missing from the listen v1/v2 and speak v1/v2 connect builders, so .additionalProperty("no_delay", true) never reaches the upgrade URL. Straight regression of PR #86.

  3. Array query params silently corrupted. keyterm/keywords/replace/search/tag/extra/language_hint now go through String.valueOf(...), emitting Java's List.toString(). Confirmed against prod using search, which echoes queries back:

    • repeated (search=bandersnatch&search=syndrome) -> 200, 2 entries: ['bandersnatch', 'syndrome']
    • bracketed (search=[bandersnatch, syndrome]) -> 200, 1 entry: ['[bandersnatch, syndrome]']
      The API accepts it with 200 and reads the whole bracketed string as one literal term, so customers get no error — just silently worse results. keyterm/keywords have no echo at all.
  4. FLUX_RENEE_EN removed while the voice is live. POST /v2/speak?model=flux-renee-en returns 200 with 14,688 bytes of audio/mpeg in prod. Note: generator 4.19.3 added zero new constants to DeepgramModel this cycle, so a wholesale .bak restore is safe here — contrary to the usual caution in the .fernignore comment, but please confirm.

  5. Union defaults reverted. AgentV1UpdateListenListenProvider, AgentV1SettingsAgentListenProvider, and AgentV1SettingsAgentContextListenProvider are back to defaultImpl = _UnknownValue, so a provider payload without "version" re-serializes as {"provider": null} and the session drops.

  6. ClientOptions lost its release-please markers. Both // x-release-please-version comments are gone from a file that .github/release-please-config.json is configured to update, so the next release won't touch it. The User-Agent also changed from com.deepgram:deepgram-java-sdk/0.10.0 to com.deepgram.deepgram-java-sdk/... (colon -> dot), which breaks Java SDK traffic attribution. And getSdkVersion() falls back to a hardcoded "0.10.1" whenever getImplementationVersion() is null (unpacked classes, shaded/fat jars, many Android builds).

  7. .fernignore freezes the backups, not the sources. All 23 entries now end in .java.bak. An entry for X.java.bak does not protect X.java, so merging this leaves the freeze list inert and the NEXT regen wipes all 23 patches again — even if the source files are repaired first. This is the one that outlives the immediate fix. Revert .fernignore to the version on main; the comment blocks are unchanged and still accurate.

  8. 23 .java.bak files committed under src/main/java/ (6,356 of the PR's additions). main carries zero. Please delete them and add *.bak to .gitignore so the workflow can't commit them again.

Should-fix:

  1. hashCode() patches dropped on 13 fields-less message types (ListenV2CloseStream, SpeakV2Flush, AgentV1KeepAlive, etc.). The generated equals() reports all instances equal with no matching hashCode(), violating the Object contract in any HashSet/HashMap.

  2. Title fails commitlint on subject-case, and chore: means release-please cuts no release — so FunctionCallCancelled and defer_until_eot would ship with no changelog entry and no version bump. The previous regen used feat(regen)!: (#96). Suggest feat(regen): agent function-call cancellation and defer_until_eot.

Nits: .fern/metadata.json sdkVersion is hand-set to 0.10.1 while build.gradle says 0.10.0 (release-please manages both), and the file lost its trailing newline.

All live probes ran in throwaway Docker containers against production, key passed as an inherited env var.

One question before this moves: is this branch a WIP snapshot ahead of the re-apply commit, or intended to merge as-is? If the re-apply is still coming, treat the above as the checklist for it.

@GregHolmes GregHolmes changed the title chore: SDK regeneration 2026-09-16 feat(regen): agent function cancellation and defer-until-EOT Sep 16, 2026
@GregHolmes

Copy link
Copy Markdown
Collaborator Author

Requesting changes — the regeneration landed but the re-apply step hasn't run, so all 23 hand-applied patches are currently overwritten and CI is red on all five checks.

I verified the re-apply is the only thing missing: in an isolated clone, restoring the 23 files from their .bak copies and deleting the backups produced BUILD SUCCESSFUL on ./gradlew compileJava test, with all 27 guard tests passing. On this branch those guards never execute, because compileJava fails first (and RegenTypesTest wouldn't compile either — it references DeepgramModel.FLUX_RENEE_EN, which this regen deleted).

Blocking:

  1. Build is broken. TransportWebSocketFactory.java:39 calls applyOptionsOverride(ReconnectOptions), removed with the ReconnectingWebSocketListener patch. Fails on Java 11/17/21.

  2. Streaming escape hatch gone. The additionalProperties block is missing from the listen v1/v2 and speak v1/v2 connect builders, so .additionalProperty("no_delay", true) never reaches the upgrade URL. Straight regression of PR fix: emit additionalProperties as query params on streaming connect #86.

  3. Array query params silently corrupted. keyterm/keywords/replace/search/tag/extra/language_hint now go through String.valueOf(...), emitting Java's List.toString(). Confirmed against prod using search, which echoes queries back:

    • repeated (search=bandersnatch&search=syndrome) -> 200, 2 entries: ['bandersnatch', 'syndrome']
    • bracketed (search=[bandersnatch, syndrome]) -> 200, 1 entry: ['[bandersnatch, syndrome]']
      The API accepts it with 200 and reads the whole bracketed string as one literal term, so customers get no error — just silently worse results. keyterm/keywords have no echo at all.
  4. FLUX_RENEE_EN removed while the voice is live. POST /v2/speak?model=flux-renee-en returns 200 with 14,688 bytes of audio/mpeg in prod. Note: generator 4.19.3 added zero new constants to DeepgramModel this cycle, so a wholesale .bak restore is safe here — contrary to the usual caution in the .fernignore comment, but please confirm.

  5. Union defaults reverted. AgentV1UpdateListenListenProvider, AgentV1SettingsAgentListenProvider, and AgentV1SettingsAgentContextListenProvider are back to defaultImpl = _UnknownValue, so a provider payload without "version" re-serializes as {"provider": null} and the session drops.

  6. ClientOptions lost its release-please markers. Both // x-release-please-version comments are gone from a file that .github/release-please-config.json is configured to update, so the next release won't touch it. The User-Agent also changed from com.deepgram:deepgram-java-sdk/0.10.0 to com.deepgram.deepgram-java-sdk/... (colon -> dot), which breaks Java SDK traffic attribution. And getSdkVersion() falls back to a hardcoded "0.10.1" whenever getImplementationVersion() is null (unpacked classes, shaded/fat jars, many Android builds).

  7. .fernignore freezes the backups, not the sources. All 23 entries now end in .java.bak. An entry for X.java.bak does not protect X.java, so merging this leaves the freeze list inert and the NEXT regen wipes all 23 patches again — even if the source files are repaired first. This is the one that outlives the immediate fix. Revert .fernignore to the version on main; the comment blocks are unchanged and still accurate.

  8. 23 .java.bak files committed under src/main/java/ (6,356 of the PR's additions). main carries zero. Please delete them and add *.bak to .gitignore so the workflow can't commit them again.

Should-fix:

  1. hashCode() patches dropped on 13 fields-less message types (ListenV2CloseStream, SpeakV2Flush, AgentV1KeepAlive, etc.). The generated equals() reports all instances equal with no matching hashCode(), violating the Object contract in any HashSet/HashMap.
  2. Title fails commitlint on subject-case, and chore: means release-please cuts no release — so FunctionCallCancelled and defer_until_eot would ship with no changelog entry and no version bump. The previous regen used feat(regen)!: (feat(regen)!: listen v2 force-end-turn + diarize metadata; rename provider/agent-history types #96). Suggest feat(regen): agent function-call cancellation and defer_until_eot.

Nits: .fern/metadata.json sdkVersion is hand-set to 0.10.1 while build.gradle says 0.10.0 (release-please manages both), and the file lost its trailing newline.

All live probes ran in throwaway Docker containers against production, key passed as an inherited env var.

One question before this moves: is this branch a WIP snapshot ahead of the re-apply commit, or intended to merge as-is? If the re-apply is still coming, treat the above as the checklist for it.

I believe these comments were made before I'd finished the regen process. Could you review please @dg-coreylweathers

@dg-coreylweathers dg-coreylweathers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the re-apply commit. All eight blockers from my previous review are resolved and the gate is clean. Requesting changes on two items.

What this PR does

Regenerates the SDK on Fern 4.19.3 and adds two Voice Agent capabilities: a FunctionCallCancelled server event with an onFunctionCallCancelled(...) handler, which tells an agent that a function call it was asked to make is no longer valid, and defer_until_eot on a think.functions entry, which holds a function call until the user's turn is confirmed and discards it if the turn resumes — the setting to use for actions that cannot be undone.

Prior findings: all resolved

cleanTest spotlessCheck test compileExamples in eclipse-temurin:17-jdk gives BUILD SUCCESSFUL with 124 tests passed, 0 failed, and every guard test for the 23 patches executed: StreamingAdditionalPropertiesWireTest 4/4, AgentSettingsProviderDefaultTest 3/3, RegenTypesTest 18, both forward-compat tests, ListenV2ControlFrameWireTest 3, ListenV2ServerCloseTest 4. The AGENTS.md fields-less hashCode() sweep returns only the two documented Nullable utility classes. DeepgramModel has 100 constants on both this branch and main, so the wholesale restore lost no voices. .fernignore is back to real paths and the .bak files are gone.

One correction to my previous review: I said the stray 0.10.1 should go back to 0.10.0 because a feat would release 0.11.0. The config sets bump-patch-for-minor-pre-major: true, so a non-breaking feat here releases as a patch — 0.10.1 is the right value. See B1; the problem is the lockstep, not the number.

Blocking

B1 — The SDK reports a version string that does not match the artifact it ships in

Two of the five files release-please owns were hand-bumped and three were not.

Expected: all five carry one identical version, moved only by release-please — pom.xml, build.gradle, README.md, .fern/metadata.json, src/main/java/com/deepgram/core/ClientOptions.java — reconciled against .github/.release-please-manifest.json.

Observed: ClientOptions.java:53,56 and .fern/metadata.json:18 say 0.10.1; pom.xml:9, build.gradle:16, README.md and the manifest say 0.10.0. A build from main after this merge sends X-Fern-SDK-Version: 0.10.1 and User-Agent: com.deepgram:deepgram-java-sdk/0.10.1 from an artifact whose Maven coordinates are 0.10.0. Our own Java-SDK traffic attribution reads those headers, so for every build made between this merge and the next release, usage is filed under a version that is not on Maven Central.

Fix (minimal, preferred): set ClientOptions.java:53,56 and .fern/metadata.json:18 back to 0.10.0 and let the release PR move all five together — the mechanism AGENTS.md line 50 describes, and the reason ClientOptions.java is in extra-files at all. Robust alternative, only if the pre-bump is deliberate: bump pom.xml, build.gradle, README.md and the manifest to 0.10.1 in the same commit. Either way, please don't leave the split.

B2 — Listen V2 sends a Warning event that no SDK can receive

Expected: a Warning from Listen V2 reaches a typed handler, the way it does on the three sibling surfaces that model it.

Observed: api/specs/asyncapi/operations/listen.v2.yml on deepgram-docs origin/main declares exactly nine messages — Media, CloseStream, ForceEndTurn, Configure, Connected, TurnInfo, ConfigureSuccess, ConfigureFailure, FatalError — and "warning" appears zero times across all four Listen v1/v2 spec files. The live endpoint sends one anyway: a ForceEndTurn with no active turn is answered with {"type":"Warning","code":"FORCE_END_TURN_NO_ACTIVE_TURN","description":"Received ForceEndTurn while no turn was active; the request was ignored."}. There is no ListenV2Warning type and no onWarning(...) on the Listen V2 client, so the frame lands in the forward-compat no-op branch at the end of handleIncomingMessage and reaches developers only as a raw string via onMessage(String).

I checked whether this is a generator problem or a spec problem: zero hits for a Listen V2 warning type in the Python, JS, Go, .NET and Rust SDKs, while Python and JS — generated by Fern from these same specs — both carry SpeakV2Warning. Fern emits a typed warning wherever the spec declares one, so the gap is in the spec. SpeakV1Warning (operations/speak.v1.yml:77), SpeakV2Warning (operations/speak.v2.yml:146) and AgentV1Warning are all declared and all generate typed events.

Fix: a spec change in deepgram-docs, not in this repo — add a ListenV2Warning message to operations/listen.v2.yml and a ListenV2WarningEvent schema registered in asyncapi.yml alongside the existing ListenV2FatalErrorEvent; operations/speak.v2.yml:146 is the pattern to copy. Then regenerate.

Why this blocks rather than trails: this PR is the regeneration, so it's the cheapest vehicle for carrying the fix. Landing it first means waiting for the next regen cycle before any developer can receive a Listen V2 warning — and this same PR removes the javadoc that was the only place warning them to expect anything at all. Greg, could you also confirm with the server team which warning codes Listen V2 emits, so the enum is complete rather than just FORCE_END_TURN_NO_ACTIVE_TURN?

Should-fix

S1 — The commit body does not describe the change in server-close behavior. On 0.10.0 the listener never acknowledged a peer close, so the handshake never completed, onClosed never ran, and onDisconnected never fired on a server-initiated close. On this version all five WebSocket clients complete the handshake and notify. A consumer whose onDisconnected handler logs an error or raises an alert will start seeing it fire on normal stream completion. The "Upstreamed" section describes this only as internal Fern plumbing, and this body is what release-please turns into the changelog. Please add an Additions bullet saying server-initiated closes now invoke onDisconnected and move the ready state to CLOSED, plus a Production availability section recording that Listen V2 ForceEndTurn is live on the hosted API — matching the shape of the 0.10.0 body.

S2 — Removing the ForceEndTurn caveat leaves three shipped docs contradicting it. The caveat is gone from listen/v2/websocket/V2WebSocketClient.java (main carries it at line 271), and removing it was correct — I sent ForceEndTurn to production and the server processed it rather than rejecting it. But docs/Migrating-v0.9-to-v0.10.md:54, docs/Migrating-v0.8-to-v0.9.md:217,269 and examples/listen/ForceEndTurn.java:30 all still tell developers the feature may be rejected with UNPARSABLE_CLIENT_MESSAGE. Update the v0.9-to-v0.10 guide and the example to say it's live on the hosted API, and scope the remaining warning to self-hosted deployments, which my probe does not cover.

S3 — Neither new feature has a test or an example. Zero hits for FunctionCallCancelled or deferUntilEot under src/test/ or examples/. #100 shipped ForceEndTurn with an example, a control-frame wire test and an integration path. Suggest a wire test that feeds a {"type":"FunctionCallCancelled","functions":[...]} frame and asserts onFunctionCallCancelled receives it, plus a RegenTypesTest case for deferUntilEot. The dispatch ordering is correct today — FunctionCallRequest at line 709 checks its own type, so a cancellation frame falls through to its own branch at 723 — but nothing would catch a future regen reordering those two.

S4 — The re-apply carried the patched behavior forward but not its documentation. Every // Manual patch - see .fernignore. breadcrumb is gone: 21 files carry it on main, zero on this branch. ReconnectingWebSocketListener also lost the javadoc documenting the patch contracts — the maxRetries(0) semantics ("connect once, don't retry", not "refuse to connect"), the 4000ms connectionTimeoutMs default, and the thread-safety rationale for holding options behind one volatile reference. Behavior is intact and tested and AGENTS.md still records all of it, so nothing is permanently lost, but the next regen loses its in-file signposts. Please restore the markers and those javadoc blocks, then re-run spotlessApply.

Nits

  • core/ReconnectingWebSocketListener.java:102 — the timeout message lost its closing paren and reads ... (retry attempt #3 unbalanced. Restore the + ")" that main has.
  • core/ReconnectingWebSocketListener.java:551 — the build() javadoc no longer lists connectionTimeoutMs is positive, while the check is still enforced at line 575.
  • .gitignore — still no *.bak rule, so the regen workflow can commit backups into src/main/java/ again.
  • .fern/metadata.json:19 — still missing its trailing newline.

Also verified

defer_until_eot: true returned SettingsApplied from the production Agent API, and the same payload with the field renamed to defer_until_eot_bogus returned UNPARSABLE_CLIENT_MESSAGE ("Check the agent.think field against the API spec") — the API does reject unknown fields there, so acceptance means the field is genuinely recognized.

The new Listen V2 reconnect suppression is necessary and correctly scoped: /v2/listen closes with an empty frame after CloseStream, which OkHttp reports as 1005, so without the suppression the SDK would dial back in after a deliberate shutdown. /v1/listen after CloseStream and /v2/speak after Close both close with 1000, which the default code != 1000 rule already treats as terminal — so no equivalent is needed there.

Two smaller judgment calls for you: whether to update the shipped migration guides (S2 means editing history, my recommendation is yes for the v0.9-to-v0.10 guide since developers read it as current guidance), and whether the suppression is safe keyed to one endpoint's close code. maxRetries defaults to Integer.MAX_VALUE, so if any endpoint later ends a clean session with a non-1000 code, consumers get an unbounded reconnect loop capped at a 10s backoff. Worth confirming with the server team whether these close codes are contractual, or generalizing the suppression to any client-initiated terminal message.

All probes ran in throwaway Docker containers with the key inherited as an env var, never on a command line. Production only.

@GregHolmes

Copy link
Copy Markdown
Collaborator Author

Follow-up: deepgram-docs #1217 models Listen V2 Warning frames in AsyncAPI. #110 deliberately remains independent: unknown frames already reach onMessage(String) and do not call onError. Typed onWarning(...) support will land with the next Fern regeneration cycle, after the source spec merges.

@dg-coreylweathers dg-coreylweathers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after 608c1e9 / 264a4a7 / fff4fdd. B1 and S1–S4 are all resolved and verified, 3 of 4 nits are fixed, and nothing new blocks. Build is green in Docker at 134 tests / 0 failures, all 21 // Manual patch files survived the regen and are listed in .fernignore, and CI is green on the head commit.

B2: withdrawn — I accept the deferral

Typed onWarning(...) can land in the next Fern regeneration cycle once deepgram-docs #1217 merges. I confirmed #1217 is still open, and your mechanics argument holds: hand-writing the type now creates a 24th hand-maintained patch in a repo that already carries a documented re-apply ritual, and it would freeze a shape that may not match what Fern eventually generates from the spec. The cost of waiting is bounded — I verified an unrecognized frame doesn't crash and doesn't fire onError; it reaches onMessage(String) verbatim (ListenV2ForwardCompatTest:26).

One condition before I approve. The developer-facing half of B2 needs no spec and should ship here:

sendForceEndTurn(...) at V2WebSocketClient.java:284 lost its javadoc caveat in this PR — correctly, since the old text about server enablement is no longer true — but nothing replaced it. As it stands, a developer who force-ends a turn that isn't running gets no explanation from anywhere: the javadoc says only "Sends a ListenV2ForceEndTurn message to the server asynchronously," the server answers with a Warning frame, and with no typed handler that frame is visible only to someone who happened to register onMessage(String). Suggested addition at 279-283:

 * <p>Sending this with no turn in progress is not an error. The server answers with a
 * {@code Warning} frame carrying code {@code FORCE_END_TURN_NO_ACTIVE_TURN} and ignores the
 * request. Listen V2 has no typed warning event yet, so that frame is delivered as raw JSON
 * to {@link #onMessage(java.util.function.Consumer)}.

Changelog: the server-close note will be dropped as things stand

I checked how the prose in past entries actually gets there, and it isn't automatic. release-please (release-type: simple) will emit one Features line built from your commit subject — feat(regen): agent function cancellation and defer-until-EOT — which says nothing about onDisconnected. The narrative paragraph and the detailed bullets in the 0.10.0 entry came from your own hand-edit on the release PR (64d668a1, "docs(changelog): clarify 0.10.0 release notes"), and the ### Compatibility section in 0.8.0 got there the same way. Squash message is PR_BODY, so your Summary bullet lands in the commit body, but release-please only lifts BREAKING CHANGE: footers out of it — plain prose isn't rendered.

That matters because the close-handshake change is the most likely upgrade surprise in this release: onDisconnected now fires on server-initiated closes where 0.10.0 stayed silent, so anyone whose handler alerts, logs an error, or kicks off their own reconnect will start seeing it at the end of every normal stream. I'm fine with this going out as a patch at 0.x, but not with it going out unannounced. Either add a BREAKING CHANGE:-style footer now, or plan the same docs(changelog): edit on the release PR with a ### Compatibility entry.

Nits, all optional, one commit alongside S5

  • .gitignore still has no *.bak rule, so the regen workflow can commit backup files into src/main/java/ again. No stray .bak files today. (Carried from last round.)
  • ReconnectingWebSocketListener.java:549 — the connectionTimeoutMs(long) setter javadoc documenting the 4000ms default is still deleted. Nothing is lost to a reader since connect() still documents it; this is the one piece of S4 not restored.
  • V2WebSocketClient.java:276 — if CloseStream is queued rather than sent directly, onSent never runs and closeStreamSocket is never set, so a following no-status close would reconnect instead of staying down. Fails safe; worth a comment saying the queued path is intentionally uncovered.
  • V2WebSocketClient.java:216 — after a deliberate CloseStream, onDisconnected reports 1005, not 1000, because that's what the server's empty close frame maps to. Accurate to the wire, but anyone checking getCode() == 1000 for "clean shutdown" will get it wrong. One javadoc line on onDisconnected would cover it.

Push S5 plus whichever nits you want and I'll approve.

What I verified this pass

  • All five release-please files plus the manifest read 0.10.0.
  • AgentV1ForceEndTurn-style fieldless hashCode() sweep returns only the two documented Jackson utility exceptions.
  • The 1005→1000 mapping at ReconnectingWebSocketListener.java:350 is complete — OkHttp's reader rejects every other reserved code with a ProtocolException before onClosing runs, so there's no unhandled path.
  • Reconnect suppression is correctly scoped to one socket: closeStreamSocket is cleared on connect() and onWebSocketOpen and compared by identity, so a stale flag can't suppress a later connection's reconnect.
  • FunctionCallRequest and FunctionCallCancelled each guard on their own type string, so neither dispatch path can swallow the other.
  • Listen V1 / Speak V2 changes are formatter line-rewrapping only, no logic change.

@GregHolmes

Copy link
Copy Markdown
Collaborator Author

@dg-coreylweathers Addressed the B2 acceptance condition and applicable nits in ee4af6a: sendForceEndTurn now documents the no-active-turn Warning and raw onMessage fallback; connectionTimeoutMs and 1005 peer-close behavior are documented; and queued CloseStream reconnect behavior is explicit. The PR body now carries a BREAKING CHANGE: compatibility footer for release-please. I intentionally did not add *.bak to .gitignore: .bak files must be committed during the prepare-regen phase so Fern preserves patched sources, and none remain after this review.

@dg-coreylweathers dg-coreylweathers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. S5 landed verbatim in ee4af6a5, and B2 is withdrawn as discussed — typed onWarning(...) follows in the next regeneration cycle once deepgram-docs #1217 merges.

Re-verified on ee4af6a5 in Docker (eclipse-temurin:17-jdk, ./gradlew --no-daemon cleanTest spotlessCheck test compileExamples): BUILD SUCCESSFUL in 50s, 134 tests, 0 failures, 0 errors, 8 skipped — identical to the previous pass, so no regression.

The thing I most wanted to confirm: ee4af6a5 is comment-only. Diffed against the previously reviewed state, it's 14 insertions across two files and every one is a javadoc or comment line — zero logic change. So all of last pass's verification carries forward intact: the 1005→1000 mapping completeness, the per-socket scoping of closeStreamSocket, the dispatch guards keeping FunctionCallRequest and FunctionCallCancelled from swallowing each other, the 21 // Manual patch files, and the version lockstep across all five release-please files.

You also picked up two nits I'd marked optional — the queued-CloseStream comment on sendCloseStream, and the 1005-vs-1000 note on onDisconnected. Both are the right call; the second in particular saves someone from checking getCode() == 1000 and getting it wrong.

The BREAKING CHANGE: footer resolves my changelog concern. Since the squash message is PR_BODY, that footer reaches the commit body and release-please lifts it into a ⚠ BREAKING CHANGES entry automatically — no hand-edit on the release PR needed this time. Worth knowing it also changes the version you'll cut: bump-minor-pre-major: true means a breaking footer pre-1.0 bumps the minor, so this releases as 0.11.0, not 0.10.1. That's the more honest number for a change that makes onDisconnected start firing on every normal stream completion.

Two nits remain, neither worth holding this for — grab them whenever you're next in the file:

  • .gitignore still has no *.bak rule, so the regen workflow can drop backup files into src/main/java/ again. Nothing stray today.
  • ReconnectingWebSocketListener.java:549 — the connectionTimeoutMs(long) setter javadoc documenting the 4000ms default is still missing. connect() still documents it, so no reader is left guessing.

Nice work on the cancellation and defer-until-EOT coverage — defer_until_eot on irreversible actions is the detail most people will need and least expect to find.

@GregHolmes
GregHolmes merged commit be27248 into main Sep 17, 2026
9 checks passed
GregHolmes added a commit that referenced this pull request Sep 21, 2026
🤖 I have created a release *beep* *boop*
---

##
[0.10.1](v0.10.0...v0.10.1)
(2026-09-18)

### Features

* **Agent:** add `V1WebSocketClient#onFunctionCallCancelled(...)` for
cancelled function-call events. Function settings also support
`deferUntilEot(true)` to defer irreversible actions until the user's
turn is confirmed.
([#110](#110))
([be27248](be27248))

### Bug Fixes

* **WebSockets:** complete peer-initiated close handshakes, set the
ready state to `CLOSED`, and invoke `onDisconnected(...)` when the
server closes a connection.
* **Listen v2:** suppress automatic reconnect only after the active
connection successfully sends `CloseStream` and receives a no-status
(`1005`) close; server-initiated closes continue to follow the
configured reconnect policy.

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Greg Holmes <greg.holmes@deepgram.com>
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.

2 participants