Skip to content

Commit d40a4e3

Browse files
committed
fix: add gateway session reset routing coverage (#44773) (thanks @Lanfei)
1 parent 3066607 commit d40a4e3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Docs: https://docs.openclaw.ai
1010
- Telegram/media downloads: thread the same direct or proxy transport policy into SSRF-guarded file fetches so inbound attachments keep working when Telegram falls back between env-proxy and direct networking. (#44639) Thanks @obviyus.
1111
- Agents/compaction: compare post-compaction token sanity checks against full-session pre-compaction totals and skip the check when token estimation fails, so sessions with large bootstrap context keep real token counts instead of falling back to unknown. (#28347) thanks @efe-arv.
1212
- Discord/gateway startup: treat plain-text and transient `/gateway/bot` metadata fetch failures as transient startup errors so Discord gateway boot no longer crashes on unhandled rejections. (#44397) Thanks @jalehman.
13+
- Gateway/session reset: preserve `lastAccountId` and `lastThreadId` across gateway session resets so replies keep routing back to the same account and thread after `/reset`. (#44773) Thanks @Lanfei.
1314

1415
## 2026.3.12
1516

src/gateway/server.sessions.gateway-server-sessions-a.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ describe("gateway server sessions", () => {
266266
lastChannel: "whatsapp",
267267
lastTo: "+1555",
268268
lastAccountId: "work",
269+
lastThreadId: "1737500000.123456",
269270
},
270271
"discord:group:dev": {
271272
sessionId: "sess-group",
@@ -336,6 +337,7 @@ describe("gateway server sessions", () => {
336337
channel: "whatsapp",
337338
to: "+1555",
338339
accountId: "work",
340+
threadId: "1737500000.123456",
339341
});
340342

341343
const active = await rpcReq<{
@@ -545,13 +547,27 @@ describe("gateway server sessions", () => {
545547
const reset = await rpcReq<{
546548
ok: true;
547549
key: string;
548-
entry: { sessionId: string; modelProvider?: string; model?: string };
550+
entry: {
551+
sessionId: string;
552+
modelProvider?: string;
553+
model?: string;
554+
lastAccountId?: string;
555+
lastThreadId?: string | number;
556+
};
549557
}>(ws, "sessions.reset", { key: "agent:main:main" });
550558
expect(reset.ok).toBe(true);
551559
expect(reset.payload?.key).toBe("agent:main:main");
552560
expect(reset.payload?.entry.sessionId).not.toBe("sess-main");
553561
expect(reset.payload?.entry.modelProvider).toBe("openai");
554562
expect(reset.payload?.entry.model).toBe("gpt-test-a");
563+
expect(reset.payload?.entry.lastAccountId).toBe("work");
564+
expect(reset.payload?.entry.lastThreadId).toBe("1737500000.123456");
565+
const storeAfterReset = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record<
566+
string,
567+
{ lastAccountId?: string; lastThreadId?: string | number }
568+
>;
569+
expect(storeAfterReset["agent:main:main"]?.lastAccountId).toBe("work");
570+
expect(storeAfterReset["agent:main:main"]?.lastThreadId).toBe("1737500000.123456");
555571
const filesAfterReset = await fs.readdir(dir);
556572
expect(filesAfterReset.some((f) => f.startsWith("sess-main.jsonl.reset."))).toBe(true);
557573

0 commit comments

Comments
 (0)