Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"packages/react": "0.1.0"
"packages/react": "0.2.0"
}
98 changes: 98 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Migration Guide

## 0.1 to 0.2

`@deepgram/react` 0.2.0 adds runtime Voice Agent controls and updates the package for `@deepgram/agents` 0.1.2 and `@deepgram/sdk` 5.9.0.

Install the new release:

```bash
npm install @deepgram/react@^0.2.0
```

### Handle the `thinking` mode

`AgentMode` now includes `"thinking"`. Update exhaustive mode switches and any mode-to-label maps.

```ts
switch (mode) {
case "idle":
case "listening":
case "thinking":
case "speaking":
break;
}
```

### Update typed context and hook wrappers

`AgentContextValue` and hook result types now include required members for the new controls and state. Components that consume the hooks do not need a source change, but typed mocks, wrappers, and objects that implement these interfaces must provide the new members.

### Keep the client-tool unsubscribe function

`registerClientTool()` now returns an unsubscribe function. Existing calls that ignore its return value still work. Store and call the result when registering outside a component lifecycle:

```tsx
import { useAgentContext } from "@deepgram/react";

function MapControls() {
const { registerClientTool } = useAgentContext();
const unregister = registerClientTool("get_location", () => {
return JSON.stringify({ latitude: 0, longitude: 0 });
});

// Later, when the handler is no longer needed:
unregister();
}
```

`useAgentClientTool()` remains the preferred option inside React components and unregisters automatically on unmount.

### Treat standalone `start()` as a fresh session

`useDeepgramAgent().start()` now clears `conversation` before connecting. Keep any transcript that must survive a restart outside the hook, or restore it after the new session starts.

Manual `start()` calls reject on failure. Handle the returned promise:

```tsx
import { useAgentControls } from "@deepgram/react";

function ConnectButton() {
const { start } = useAgentControls();

async function handleStart() {
try {
await start();
} catch (error) {
console.error("Failed to start the Voice Agent", error);
}
}

return <button onClick={handleStart}>Connect</button>;
}
```

Automatic start failures, including microphone failures during auto-start and reconnect, call `onSdkError` when it is provided.

### Use the new runtime controls

Use the controls from `useAgentControls()`, `useAgentConversation()`, or `useDeepgramAgent()` to update a connected agent without recreating the provider:

```tsx
import { useAgentControls } from "@deepgram/react";

function TakeoverButton() {
const { sendAgentMessage, updatePrompt } = useAgentControls();

function takeOver() {
updatePrompt("Keep responses concise.");
sendAgentMessage("I will take it from here.", "interrupt");
}

return <button onClick={takeOver}>Take over</button>;
}
```

Use `onListenUpdated`, `onPromptUpdated`, `onSpeakUpdated`, and `onThinkUpdated` on `AgentProvider` or `useDeepgramAgent()` to observe the matching server confirmation.

See the [package README](packages/react/README.md) for the complete API surface.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function VoiceAgent() {
| `useAgentSession` | Direct access to the underlying `AgentSession` (escape hatch) |
| `useDeepgramAgent` | Standalone hook -- no provider needed |

See the [package README](packages/react/README.md) for full API documentation.
See the [package README](packages/react/README.md) for full API documentation. See the [migration guide](MIGRATION.md) when upgrading from 0.1 to 0.2.

## Related Packages

Expand All @@ -84,6 +84,7 @@ See the [package README](packages/react/README.md) for full API documentation.

- [Deepgram Voice Agent docs](https://developers.deepgram.com/docs/voice-agent)
- [API reference](https://developers.deepgram.com/reference)
- [Migration guide](MIGRATION.md)
- [`@deepgram/ui` -- pre-built components](https://github.com/deepgram/ui)

## Development
Expand Down
25 changes: 25 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## [0.2.0](https://github.com/deepgram/react/compare/react-v0.1.0...react-v0.2.0) (2026-09-10)


### ⚠ BREAKING CHANGES

* **react:** `AgentMode` now includes `"thinking"`.
* **react:** Public context and hook result types add required members for the new agent controls and state.
* **react:** `registerClientTool()` now returns an unsubscribe function.
* **react:** `useDeepgramAgent().start()` begins a fresh session and clears `conversation`.

### Features

* **react:** Add `"thinking"` mode and `isThinking` state.
* **react:** Add `sendAgentMessage()` with `"default"`, `"queue"`, and `"interrupt"` behavior.
* **react:** Add `updateListen()`, `updateThink()`, `updateSpeak()`, and `updatePrompt()` for runtime agent settings changes.
* **react:** Add typed callbacks for protocol notifications, including settings update confirmations.
* **react:** Expose the new controls and state through `AgentProvider`, focused hooks, and `useDeepgramAgent`.


### Bug Fixes

* **react:** Harden starts, stops, reconnects, and StrictMode replay so canceled or failed sessions cannot retain stale microphone, playback, or client-tool resources.
* **react:** Report automatic start failures, including microphone failures during auto-start and reconnect, through `onSdkError` or `console.error` when no callback is set. Manual `start()` rejects instead.
* **react:** Publish portable declarations that resolve agent types from `@deepgram/agents` in consumer projects.

## 0.1.0 (2026-04-30)


Expand Down
4 changes: 4 additions & 0 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ export type {
};
```

## Migration

See the [0.1 to 0.2 migration guide](https://github.com/deepgram/react/blob/main/MIGRATION.md) when upgrading an existing integration.

## License

MIT
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deepgram/react",
"version": "0.1.0",
"version": "0.2.0",
"description": "React hooks and components for @deepgram/agents",
"type": "module",
"main": "dist/index.cjs",
Expand Down