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

推荐订阅源

有赞技术团队
有赞技术团队
G
Google Developers Blog
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
P
Proofpoint News Feed
V
Visual Studio Blog
爱范儿
爱范儿
The Cloudflare Blog
博客园 - 叶小钗
V
V2EX
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
H
Help Net Security
B
Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
量子位
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

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
refactor(gateway): finish async session read paths (#7589...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -1,7 +1,7 @@

11

import { randomUUID } from "node:crypto";

22

import fs from "node:fs";

33

import path from "node:path";

4-

import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";

4+

import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent";

55

import { resolveAgentRuntimeMetadata } from "../../agents/agent-runtime-metadata.js";

66

import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";

77

import {

@@ -66,6 +66,7 @@ import {

6666

} from "../protocol/index.js";

6767

import { resolveSessionKeyForRun } from "../server-session-key.js";

6868

import {

69+

forkCompactionCheckpointTranscriptAsync,

6970

getSessionCompactionCheckpoint,

7071

listSessionCompactionCheckpoints,

7172

} from "../session-compaction-checkpoints.js";

@@ -1089,26 +1090,11 @@ export const sessionsHandlers: GatewayRequestHandlers = {

10891090

);

10901091

return;

10911092

}

1092-

if (!fs.existsSync(checkpoint.preCompaction.sessionFile)) {

1093-

respond(

1094-

false,

1095-

undefined,

1096-

errorShape(ErrorCodes.UNAVAILABLE, "checkpoint snapshot transcript is missing"),

1097-

);

1098-

return;

1099-

}

1100-1101-

const snapshotSession = SessionManager.open(

1102-

checkpoint.preCompaction.sessionFile,

1103-

path.dirname(checkpoint.preCompaction.sessionFile),

1104-

);

1105-

const branchedSession = SessionManager.forkFrom(

1106-

checkpoint.preCompaction.sessionFile,

1107-

snapshotSession.getCwd(),

1108-

path.dirname(checkpoint.preCompaction.sessionFile),

1109-

);

1110-

const branchedSessionFile = branchedSession.getSessionFile();

1111-

if (!branchedSessionFile) {

1093+

const branchedSession = await forkCompactionCheckpointTranscriptAsync({

1094+

sourceFile: checkpoint.preCompaction.sessionFile,

1095+

sessionDir: path.dirname(checkpoint.preCompaction.sessionFile),

1096+

});

1097+

if (!branchedSession?.sessionFile) {

11121098

respond(

11131099

false,

11141100

undefined,

@@ -1120,8 +1106,8 @@ export const sessionsHandlers: GatewayRequestHandlers = {

11201106

const label = entry.label?.trim() ? `${entry.label.trim()} (checkpoint)` : "Checkpoint branch";

11211107

const nextEntry = cloneCheckpointSessionEntry({

11221108

currentEntry: entry,

1123-

nextSessionId: branchedSession.getSessionId(),

1124-

nextSessionFile: branchedSessionFile,

1109+

nextSessionId: branchedSession.sessionId,

1110+

nextSessionFile: branchedSession.sessionFile,

11251111

label,

11261112

parentSessionKey: canonicalKey,

11271113

totalTokens: checkpoint.tokensBefore,

@@ -1203,15 +1189,6 @@ export const sessionsHandlers: GatewayRequestHandlers = {

12031189

);

12041190

return;

12051191

}

1206-

if (!fs.existsSync(checkpoint.preCompaction.sessionFile)) {

1207-

respond(

1208-

false,

1209-

undefined,

1210-

errorShape(ErrorCodes.UNAVAILABLE, "checkpoint snapshot transcript is missing"),

1211-

);

1212-

return;

1213-

}

1214-12151192

const interruptResult = await interruptSessionRunIfActive({

12161193

req,

12171194

context,

@@ -1226,17 +1203,11 @@ export const sessionsHandlers: GatewayRequestHandlers = {

12261203

return;

12271204

}

122812051229-

const snapshotSession = SessionManager.open(

1230-

checkpoint.preCompaction.sessionFile,

1231-

path.dirname(checkpoint.preCompaction.sessionFile),

1232-

);

1233-

const restoredSession = SessionManager.forkFrom(

1234-

checkpoint.preCompaction.sessionFile,

1235-

snapshotSession.getCwd(),

1236-

path.dirname(checkpoint.preCompaction.sessionFile),

1237-

);

1238-

const restoredSessionFile = restoredSession.getSessionFile();

1239-

if (!restoredSessionFile) {

1206+

const restoredSession = await forkCompactionCheckpointTranscriptAsync({

1207+

sourceFile: checkpoint.preCompaction.sessionFile,

1208+

sessionDir: path.dirname(checkpoint.preCompaction.sessionFile),

1209+

});

1210+

if (!restoredSession?.sessionFile) {

12401211

respond(

12411212

false,

12421213

undefined,

@@ -1246,8 +1217,8 @@ export const sessionsHandlers: GatewayRequestHandlers = {

12461217

}

12471218

const nextEntry = cloneCheckpointSessionEntry({

12481219

currentEntry: entry,

1249-

nextSessionId: restoredSession.getSessionId(),

1250-

nextSessionFile: restoredSessionFile,

1220+

nextSessionId: restoredSession.sessionId,

1221+

nextSessionFile: restoredSession.sessionFile,

12511222

totalTokens: checkpoint.tokensBefore,

12521223

preserveCompactionCheckpoints: true,

12531224

});