惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
博客园 - Franky
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
IT之家
IT之家
美团技术团队
博客园 - 司徒正美
Martin Fowler
Martin Fowler
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
雷峰网
雷峰网
B
Blog
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
D
Docker
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: tighten voice call response assertions · openclaw/o...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -3,14 +3,31 @@ import { VoiceCallConfigSchema } from "./config.js";

33

import type { CoreAgentDeps, CoreConfig } from "./core-bridge.js";

44

import { generateVoiceResponse } from "./response-generator.js";

556+

type TestSessionEntry = {

7+

sessionId: string;

8+

updatedAt: number;

9+

providerOverride?: string;

10+

modelOverride?: string;

11+

modelOverrideSource?: string;

12+

};

13+14+

type EmbeddedAgentArgs = {

15+

extraSystemPrompt: string;

16+

provider?: string;

17+

model?: string;

18+

sessionKey?: string;

19+

sandboxSessionKey?: string;

20+

agentDir?: string;

21+

agentId?: string;

22+

workspaceDir?: string;

23+

sessionFile?: string;

24+

};

25+626

function createAgentRuntime(payloads: Array<Record<string, unknown>>) {

7-

const sessionStore: Record<string, { sessionId: string; updatedAt: number }> = {};

27+

const sessionStore: Record<string, TestSessionEntry> = {};

828

const saveSessionStore = vi.fn(async () => {});

929

const updateSessionStore = vi.fn(

10-

async (

11-

_storePath: string,

12-

mutator: (store: Record<string, { sessionId: string; updatedAt: number }>) => unknown,

13-

) => {

30+

async (_storePath: string, mutator: (store: Record<string, TestSessionEntry>) => unknown) => {

1431

return await mutator(sessionStore);

1532

},

1633

);

@@ -77,17 +94,11 @@ function requireEmbeddedAgentArgs(runEmbeddedPiAgent: ReturnType<typeof vi.fn>)

7794

if (!firstCall) {

7895

throw new Error("voice response generator did not invoke the embedded agent");

7996

}

80-

const args = firstCall[0] as

81-

| {

82-

extraSystemPrompt?: string;

83-

provider?: string;

84-

model?: string;

85-

}

86-

| undefined;

97+

const args = firstCall[0] as Partial<EmbeddedAgentArgs> | undefined;

8798

if (!args?.extraSystemPrompt) {

8899

throw new Error("voice response generator did not pass the spoken-output contract prompt");

89100

}

90-

return args;

101+

return args as EmbeddedAgentArgs;

91102

}

9210393104

async function runGenerateVoiceResponse(

@@ -186,21 +197,17 @@ describe("generateVoiceResponse", () => {

186197

});

187198188199

expect(result.text).toBe("Pinned model works.");

189-

expect(sessionStore["voice:15550001111"]).toMatchObject({

190-

providerOverride: "openai",

191-

modelOverride: "gpt-4.1-nano",

192-

modelOverrideSource: "auto",

193-

});

200+

const pinnedSessionEntry = sessionStore["voice:15550001111"];

201+

expect(pinnedSessionEntry?.providerOverride).toBe("openai");

202+

expect(pinnedSessionEntry?.modelOverride).toBe("gpt-4.1-nano");

203+

expect(pinnedSessionEntry?.modelOverrideSource).toBe("auto");

194204

const updateSessionStoreCall = updateSessionStore.mock.calls[0];

195205

expect(updateSessionStoreCall?.[0]).toBe("/tmp/openclaw/main/sessions.json");

196206

expect(updateSessionStoreCall?.[1]).toBeTypeOf("function");

197-

expect(runEmbeddedPiAgent).toHaveBeenCalledWith(

198-

expect.objectContaining({

199-

provider: "openai",

200-

model: "gpt-4.1-nano",

201-

sessionKey: "voice:15550001111",

202-

}),

203-

);

207+

const args = requireEmbeddedAgentArgs(runEmbeddedPiAgent);

208+

expect(args.provider).toBe("openai");

209+

expect(args.model).toBe("gpt-4.1-nano");

210+

expect(args.sessionKey).toBe("voice:15550001111");

204211

});

205212206213

it("uses the persisted per-call session key for classic responses", async () => {

@@ -224,16 +231,13 @@ describe("generateVoiceResponse", () => {

224231

});

225232226233

expect(result.text).toBe("Fresh call context.");

227-

expect(sessionStore["voice:call:call-123"]).toMatchObject({

228-

sessionId: expect.stringMatching(/\S/),

229-

});

234+

const perCallSessionEntry = sessionStore["voice:call:call-123"];

235+

expect(perCallSessionEntry?.sessionId).toBeTypeOf("string");

236+

expect(perCallSessionEntry?.sessionId).not.toBe("");

230237

expect(sessionStore["voice:15550001111"]).toBeUndefined();

231-

expect(runEmbeddedPiAgent).toHaveBeenCalledWith(

232-

expect.objectContaining({

233-

sessionKey: "voice:call:call-123",

234-

sandboxSessionKey: "agent:main:voice:call:call-123",

235-

}),

236-

);

238+

const args = requireEmbeddedAgentArgs(runEmbeddedPiAgent);

239+

expect(args.sessionKey).toBe("voice:call:call-123");

240+

expect(args.sandboxSessionKey).toBe("agent:main:voice:call:call-123");

237241

});

238242239243

it("uses the main agent workspace when voice config omits agentId", async () => {

@@ -272,15 +276,12 @@ describe("generateVoiceResponse", () => {

272276

agentId: "main",

273277

},

274278

);

275-

expect(runEmbeddedPiAgent).toHaveBeenCalledWith(

276-

expect.objectContaining({

277-

agentDir: "/tmp/openclaw/agents/main",

278-

agentId: "main",

279-

sandboxSessionKey: "agent:main:voice:15550001111",

280-

workspaceDir: "/tmp/openclaw/workspace/main",

281-

sessionFile: "/tmp/openclaw/main/sessions/session.jsonl",

282-

}),

283-

);

279+

const args = requireEmbeddedAgentArgs(runEmbeddedPiAgent);

280+

expect(args.agentDir).toBe("/tmp/openclaw/agents/main");

281+

expect(args.agentId).toBe("main");

282+

expect(args.sandboxSessionKey).toBe("agent:main:voice:15550001111");

283+

expect(args.workspaceDir).toBe("/tmp/openclaw/workspace/main");

284+

expect(args.sessionFile).toBe("/tmp/openclaw/main/sessions/session.jsonl");

284285

});

285286286287

it("uses the configured voice response agent workspace", async () => {

@@ -323,14 +324,11 @@ describe("generateVoiceResponse", () => {

323324

agentId: "voice",

324325

},

325326

);

326-

expect(runEmbeddedPiAgent).toHaveBeenCalledWith(

327-

expect.objectContaining({

328-

agentDir: "/tmp/openclaw/agents/voice",

329-

agentId: "voice",

330-

sandboxSessionKey: "agent:voice:voice:15550001111",

331-

workspaceDir: "/tmp/openclaw/workspace/voice",

332-

sessionFile: "/tmp/openclaw/voice/sessions/session.jsonl",

333-

}),

334-

);

327+

const args = requireEmbeddedAgentArgs(runEmbeddedPiAgent);

328+

expect(args.agentDir).toBe("/tmp/openclaw/agents/voice");

329+

expect(args.agentId).toBe("voice");

330+

expect(args.sandboxSessionKey).toBe("agent:voice:voice:15550001111");

331+

expect(args.workspaceDir).toBe("/tmp/openclaw/workspace/voice");

332+

expect(args.sessionFile).toBe("/tmp/openclaw/voice/sessions/session.jsonl");

335333

});

336334

});