> This page is for SDKs, version Legacy.
> For other versions, use one of these documentation indexes:
> - Current (default): https://buildwithfern.com/learn/sdks/current/llms.txt
> - Legacy: https://buildwithfern.com/learn/sdks/legacy/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

## 4.0.3

**`(fix):`** Fix WebSocket `handleIncomingMessage()` using Fern-internal message IDs
(e.g. `AgentV1Welcome`, `ListenV1Results`) instead of the wire discriminant
values from the spec (e.g. `Welcome`, `Results`). This caused all incoming
message handlers to never fire, falling through to the unknown type handler.

The generator now extracts wire discriminant values from each message body's
`type` property — resolving literal values (e.g. `literal<"Welcome">`) and
enum values (e.g. `enum[Flushed, Cleared]`) — and dispatches via a `switch`
statement on those values. This aligns with the approach used by the Python
generator.

**`(fix):`** WebSocket handler registration methods and field names now use
wire discriminant values instead of Fern-internal prefixed names. For example,
`onAgentV1Welcome(handler)` is now `onWelcome(handler)`, and
`onAgentV1PromptUpdated(handler)` is now `onPromptUpdated(handler)`. Methods
that were already backed by a custom `x-fern-sdk-method-name` (e.g.
`onFunctionCallResponse`) are unchanged.

**`(chore):`** Improve generated WebSocket client code quality: use a string literal for
static URL paths instead of `StringBuilder`, remove dead if/else branches in
async `sendMessage()`, consolidate redundant catch blocks in message dispatch,
and correct Javadoc articles ("a" vs "an") for type names starting with vowels.