[fix] session

This commit is contained in:
zhhe committed 2026-11-17 08:17:54 +08:00
1 parent 44e203d868
commit 14b6a546d0
4 files changed
+31 -4

No files matched your search

+14 -1
View File
@@ -53,6 +53,9 @@ export class MailDeliverer {
const id = sessionId;
const live = this.ctx.agents.get(id);
if (live) {
if (this.ctx.sessions.get(id) !== live.session) {
throw new Error(`会话 ${sessionId} 未进入全局 SessionStore`);
}
const borrowed = {
agent: live,
off: this.watch(live),
@@ -67,10 +70,20 @@ export class MailDeliverer {
handle = await this.ctx.agents.resume({ resumeSessionId: id });
}
catch {
handle = await this.ctx.agents.create({ sessionId: id });
// 与 ACP 的外部会话创建路径一致:cwd 是持久会话的工作区元数据。
handle = await this.ctx.agents.create({
sessionId: id,
meta: { cwd: process.cwd() },
});
created = true;
}
this.onLog?.(`[mail] ${sessionId} 会话已${created ? '创建' : '恢复'}`);
// DeepSeek 请求扩展通过全局 SessionStore 上传 dsh_session_log。若这里不可见,
// 继续 followup 只会让服务端按 sessionId 加载一份不存在的历史。
if (this.ctx.sessions.get(id) !== handle.agent.session) {
await handle.dispose();
throw new Error(`会话 ${sessionId} 创建后未进入全局 SessionStore`);
}
const owned = {
agent: handle.agent,
off: this.watch(handle.agent),