
























@@ -7,29 +7,7 @@ import {
7788describe("buildEmbeddedCompactionRuntimeContext", () => {
99it("preserves sender and current message routing for compaction", () => {
10-expect(
11-buildEmbeddedCompactionRuntimeContext({
12-sessionKey: "agent:main:thread:1",
13-messageChannel: "slack",
14-messageProvider: "slack",
15-agentAccountId: "acct-1",
16-currentChannelId: "C123",
17-currentThreadTs: "thread-9",
18-currentMessageId: "msg-42",
19-authProfileId: "openai:p1",
20-workspaceDir: "/tmp/workspace",
21-agentDir: "/tmp/agent",
22-config: {} as OpenClawConfig,
23-senderIsOwner: true,
24-senderId: "user-123",
25-provider: "openai-codex",
26-modelId: "gpt-5.4",
27-thinkLevel: "off",
28-reasoningLevel: "on",
29-extraSystemPrompt: "extra",
30-ownerNumbers: ["+15555550123"],
31-}),
32-).toMatchObject({
10+const result = buildEmbeddedCompactionRuntimeContext({
3311sessionKey: "agent:main:thread:1",
3412messageChannel: "slack",
3513messageProvider: "slack",
@@ -40,42 +18,58 @@ describe("buildEmbeddedCompactionRuntimeContext", () => {
4018authProfileId: "openai:p1",
4119workspaceDir: "/tmp/workspace",
4220agentDir: "/tmp/agent",
21+config: {} as OpenClawConfig,
22+senderIsOwner: true,
4323senderId: "user-123",
4424provider: "openai-codex",
45-model: "gpt-5.4",
25+modelId: "gpt-5.4",
26+thinkLevel: "off",
27+reasoningLevel: "on",
28+extraSystemPrompt: "extra",
29+ownerNumbers: ["+15555550123"],
4630});
31+expect(result.sessionKey).toBe("agent:main:thread:1");
32+expect(result.messageChannel).toBe("slack");
33+expect(result.messageProvider).toBe("slack");
34+expect(result.agentAccountId).toBe("acct-1");
35+expect(result.currentChannelId).toBe("C123");
36+expect(result.currentThreadTs).toBe("thread-9");
37+expect(result.currentMessageId).toBe("msg-42");
38+expect(result.authProfileId).toBe("openai:p1");
39+expect(result.workspaceDir).toBe("/tmp/workspace");
40+expect(result.agentDir).toBe("/tmp/agent");
41+expect(result.senderId).toBe("user-123");
42+expect(result.provider).toBe("openai-codex");
43+expect(result.model).toBe("gpt-5.4");
4744});
48454946it("normalizes nullable compaction routing fields to undefined", () => {
50-expect(
51-buildEmbeddedCompactionRuntimeContext({
52-sessionKey: null,
53-messageChannel: null,
54-messageProvider: null,
55-agentAccountId: null,
56-currentChannelId: null,
57-currentThreadTs: null,
58-currentMessageId: null,
59-authProfileId: null,
60-workspaceDir: "/tmp/workspace",
61-agentDir: "/tmp/agent",
62-senderId: null,
63-provider: null,
64-modelId: null,
65-}),
66-).toMatchObject({
67-sessionKey: undefined,
68-messageChannel: undefined,
69-messageProvider: undefined,
70-agentAccountId: undefined,
71-currentChannelId: undefined,
72-currentThreadTs: undefined,
73-currentMessageId: undefined,
74-authProfileId: undefined,
75-senderId: undefined,
76-provider: undefined,
77-model: undefined,
47+const result = buildEmbeddedCompactionRuntimeContext({
48+sessionKey: null,
49+messageChannel: null,
50+messageProvider: null,
51+agentAccountId: null,
52+currentChannelId: null,
53+currentThreadTs: null,
54+currentMessageId: null,
55+authProfileId: null,
56+workspaceDir: "/tmp/workspace",
57+agentDir: "/tmp/agent",
58+senderId: null,
59+provider: null,
60+modelId: null,
7861});
62+expect(result.sessionKey).toBeUndefined();
63+expect(result.messageChannel).toBeUndefined();
64+expect(result.messageProvider).toBeUndefined();
65+expect(result.agentAccountId).toBeUndefined();
66+expect(result.currentChannelId).toBeUndefined();
67+expect(result.currentThreadTs).toBeUndefined();
68+expect(result.currentMessageId).toBeUndefined();
69+expect(result.authProfileId).toBeUndefined();
70+expect(result.senderId).toBeUndefined();
71+expect(result.provider).toBeUndefined();
72+expect(result.model).toBeUndefined();
7973});
80748175it("applies compaction.model override with provider/model format", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。