fix(voice-call): reap stale pre-answer calls

This commit is contained in:
Peter Steinberger
2026-04-25 03:50:24 +01:00
parent a98a0b94d1
commit a669ba7df1
5 changed files with 32 additions and 6 deletions

View File

@@ -73,7 +73,7 @@ Docs: https://docs.openclaw.ai
- Config/doctor: reject legacy `secretref-env:<ENV_VAR>` marker strings on SecretRef credential paths and migrate valid markers to structured env SecretRefs with `openclaw doctor --fix`. Fixes #51794. Thanks @halointellicore.
- Providers/OpenAI: separate API-key and Codex sign-in onboarding groups, and avoid replaying stale OpenAI Responses reasoning blocks after a model route switch.
- Providers/ElevenLabs: omit the MP3-only `Accept` header for PCM telephony synthesis, so Voice Call requests for `pcm_22050` no longer receive MP3 audio. Fixes #67340. Thanks @marcchabot.
- Plugins/Voice Call: honor configured TTS timeouts for Twilio media-stream playback and fail empty telephony audio instead of completing as silence. Fixes #42071; supersedes #60957. Thanks @Ryce and @sliekens.
- Plugins/Voice Call: reap stale pre-answer calls by default, honor configured TTS timeouts for Twilio media-stream playback, and fail empty telephony audio instead of completing as silence. Fixes #42071; supersedes #60957. Thanks @Ryce and @sliekens.
- Skills: honor legacy `metadata.clawdbot` requirements and installer hints when `metadata.openclaw` is absent, so older skills no longer appear ready when required binaries are missing. Fixes #71323. Thanks @chen-zhang-cs-code.
- Browser/config: expand `~` in `browser.executablePath` before Chromium launch, so home-relative custom browser paths no longer fail with `ENOENT`. Fixes #67264. Thanks @Quratulain-bilal.
- Telegram/streaming: hide tool-progress status updates by default while keeping explicit `streaming.preview.toolProgress` opt-in support for edited preview messages. Fixes #71320. Thanks @neeravmakwana.

View File

@@ -226,6 +226,14 @@ describe("validateProviderConfig", () => {
});
});
describe("resolveVoiceCallConfig", () => {
it("enables the pre-answer stale call reaper by default", () => {
const config = resolveVoiceCallConfig({ enabled: true, provider: "mock" });
expect(config.staleCallReaperSeconds).toBe(120);
});
});
describe("normalizeVoiceCallConfig", () => {
it("fills nested runtime defaults from a partial config boundary", () => {
const normalized = normalizeVoiceCallConfig({

View File

@@ -331,11 +331,10 @@ export const VoiceCallConfigSchema = z
/**
* Maximum age of a call in seconds before it is automatically reaped.
* Catches calls stuck in unexpected states (e.g., notify-mode calls that
* never receive a terminal webhook). Set to 0 to disable.
* Default: 0 (disabled). Recommended: 120-300 for production.
* Catches calls stuck before answer (for example, local mock calls that
* never receive provider webhooks). Set to 0 to disable.
*/
staleCallReaperSeconds: z.number().int().nonnegative().default(0),
staleCallReaperSeconds: z.number().int().nonnegative().default(120),
/** Silence timeout for end-of-speech detection (ms) */
silenceTimeoutMs: z.number().int().positive().default(800),

View File

@@ -353,11 +353,12 @@ async function runStaleCallReaperCase(params: {
callAgeMs: number;
staleCallReaperSeconds: number;
advanceMs: number;
callOverrides?: Partial<CallRecord>;
}) {
const now = new Date("2026-02-16T00:00:00Z");
vi.setSystemTime(now);
const call = createCall(now.getTime() - params.callAgeMs);
const call = { ...createCall(now.getTime() - params.callAgeMs), ...params.callOverrides };
const { manager, endCall } = createManager([call]);
const config = createConfig({ staleCallReaperSeconds: params.staleCallReaperSeconds });
const server = new VoiceCallWebhookServer(config, manager, provider);
@@ -485,6 +486,19 @@ describe("VoiceCallWebhookServer stale call reaper", () => {
await server.stop();
}
});
it("does not reap calls that reached the answered state", async () => {
const { endCall } = await runStaleCallReaperCase({
callAgeMs: 120_000,
staleCallReaperSeconds: 60,
advanceMs: 30_000,
callOverrides: {
state: "answered",
answeredAt: new Date("2026-02-15T23:58:30Z").getTime(),
},
});
expect(endCall).not.toHaveBeenCalled();
});
});
describe("VoiceCallWebhookServer path matching", () => {

View File

@@ -1,4 +1,5 @@
import type { CallManager } from "../manager.js";
import { TerminalStates } from "../types.js";
const CHECK_INTERVAL_MS = 30_000;
@@ -15,6 +16,10 @@ export function startStaleCallReaper(params: {
const interval = setInterval(() => {
const now = Date.now();
for (const call of params.manager.getActiveCalls()) {
if (call.answeredAt || TerminalStates.has(call.state)) {
continue;
}
const age = now - call.startedAt;
if (age > maxAgeMs) {
console.log(