mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:00:45 +00:00
fix(voice-call): scope sandbox session to agent
This commit is contained in:
@@ -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",
|
||||
}),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -318,6 +318,7 @@ export async function createVoiceCallRuntime(params: {
|
||||
cfg,
|
||||
agentRuntime,
|
||||
logger: log,
|
||||
agentId: config.agentId ?? "main",
|
||||
sessionKey: resolveVoiceCallConsultSessionKey(call),
|
||||
messageProvider: "voice",
|
||||
lane: "voice",
|
||||
|
||||
Reference in New Issue
Block a user