Skip to content

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

Tell a caller why the voice service did not start the call (#654)

kevind94171cd5403
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 544c7755..f37d8968 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -220,6 +220,14 @@ resolved `docker`, and the directory holding what it points at when it is a syml
to the PATH the engine is invoked with. Appended, so an existing helper still wins, and the inherited
PATH is now kept rather than replaced, which it was not before.
+### A voice call that cannot start says why
+
+When the voice service turned a call down, the provider wrote a message for the caller, such as
+"The voice service is busy. Please retry shortly." when it answered 429, and the call route replaced
+every one with "The voice service could not start a call. Please retry." The route now passes those
+fixed messages on, as the dictation route already does. Any other failure still reads the generic
+line, so nothing from an upstream response reaches the browser.
+
### OpenBot starts only on the Bun it pins
An installed or cached Bun that is not the pinned version is no longer accepted, on install and on
diff --git a/server/src/voice/routes.ts b/server/src/voice/routes.ts
index c9452aa1..fcdcdab1 100644
--- a/server/src/voice/routes.ts
+++ b/server/src/voice/routes.ts
@@ -7,6 +7,7 @@ import {
isVoiceSdp,
MAX_VOICE_SDP_BYTES,
type VoiceConnection,
+ VoiceError,
type VoiceProvider,
} from "./provider";
import {
@@ -170,7 +171,7 @@ export function createVoiceRoutes(
signal,
});
return context.json(connection);
- } catch {
+ } catch (error) {
return signal.aborted
? context.json(
{
@@ -181,8 +182,12 @@ export function createVoiceRoutes(
)
: context.json(
{
+ // VoiceError carries only fixed text written for the caller, such as the service
+ // being busy; anything else may hold an upstream body and stays generic.
error:
- "The voice service could not start a call. Please retry.",
+ error instanceof VoiceError
+ ? error.message
+ : "The voice service could not start a call. Please retry.",
},
502,
);
diff --git a/server/tests/voice-routes.test.ts b/server/tests/voice-routes.test.ts
index 63f0bd3f..dd6c9fd0 100644
--- a/server/tests/voice-routes.test.ts
+++ b/server/tests/voice-routes.test.ts
@@ -3,7 +3,11 @@ import type { MiddlewareHandler } from "hono";
import type { AgentProfile } from "../src/agents/profile-types";
import type { AppVariables } from "../src/auth/guards";
import type { AgentChannel, ChannelStore } from "../src/channels/routes";
-import type { VoiceConnection, VoiceProvider } from "../src/voice/provider";
+import {
+ type VoiceConnection,
+ VoiceError,
+ type VoiceProvider,
+} from "../src/voice/provider";
import { createVoiceRoutes as voiceRoutes } from "../src/voice/routes";
const profile: AgentProfile = {
@@ -267,6 +271,26 @@ test("provider errors do not leak secrets; attempts are bounded", async () => {
expect((await app.request("/calls", request())).status).toBe(429);
});
+test("a caller is told what the voice service said when it gave a safe reason", async () => {
+ const app = createVoiceRoutes(
+ user,
+ {
+ transport: "webrtc",
+ connect: async () => {
+ throw new VoiceError(
+ "The voice service is busy. Please retry shortly.",
+ );
+ },
+ },
+ channels,
+ );
+ const response = await app.request("/calls", request());
+ expect(response.status).toBe(502);
+ expect(await response.json()).toEqual({
+ error: "The voice service is busy. Please retry shortly.",
+ });
+});
+
test("allows one handshake per user, propagates cancellation, and releases its slot", async () => {
const started = Promise.withResolvers<void>();
const controller = new AbortController();