fix(voice-call): scope sandbox session to agent

This commit is contained in:
Peter Steinberger
2026-04-25 03:42:59 +01:00
parent 460720d0a1
commit 8f11e5ad18
6 changed files with 55 additions and 0 deletions

View File

@@ -223,6 +223,8 @@ describe("generateVoiceResponse", () => {
expect(runEmbeddedPiAgent).toHaveBeenCalledWith(
expect.objectContaining({
agentDir: "/tmp/openclaw/agents/main",
agentId: "main",
sandboxSessionKey: "agent:main:voice:15550001111",
workspaceDir: "/tmp/openclaw/workspace/main",
sessionFile: "/tmp/openclaw/main/sessions/session.jsonl",
}),
@@ -265,6 +267,8 @@ describe("generateVoiceResponse", () => {
expect(runEmbeddedPiAgent).toHaveBeenCalledWith(
expect.objectContaining({
agentDir: "/tmp/openclaw/agents/voice",
agentId: "voice",
sandboxSessionKey: "agent:voice:voice:15550001111",
workspaceDir: "/tmp/openclaw/workspace/voice",
sessionFile: "/tmp/openclaw/voice/sessions/session.jsonl",
}),

View File

@@ -172,6 +172,14 @@ function extractSpokenTextFromPayloads(payloads: VoiceResponsePayload[]): string
return spokenSegments.length > 0 ? spokenSegments.join(" ").trim() : null;
}
function resolveVoiceSandboxSessionKey(agentId: string, sessionKey: string): string {
const trimmed = sessionKey.trim();
if (trimmed.toLowerCase().startsWith("agent:")) {
return trimmed;
}
return `agent:${agentId}:${trimmed}`;
}
/**
* Generate a voice response using the embedded Pi agent with full tool support.
* Uses the same agent infrastructure as messaging for consistent behavior.
@@ -264,6 +272,8 @@ export async function generateVoiceResponse(
const result = await agentRuntime.runEmbeddedPiAgent({
sessionId,
sessionKey,
sandboxSessionKey: resolveVoiceSandboxSessionKey(agentId, sessionKey),
agentId,
messageProvider: "voice",
sessionFile,
workspaceDir,

View File

@@ -318,6 +318,7 @@ export async function createVoiceCallRuntime(params: {
cfg,
agentRuntime,
logger: log,
agentId: config.agentId ?? "main",
sessionKey: resolveVoiceCallConsultSessionKey(call),
messageProvider: "voice",
lane: "voice",