Skip to content

Commit fa44500

Browse files
authored
fix(acp): preserve streamed progress chunks (#78383)
Co-authored-by: Alex Knight <[email protected]>
1 parent 7a73b37 commit fa44500

3 files changed

Lines changed: 117 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Docs: https://docs.openclaw.ai
132132
- Discord/guilds: route plain text control commands such as `/steer` through the normal authorization and mention gate instead of silently dropping them before an agent session can see them. Fixes #78080. Thanks @ramitrkar-hash.
133133
- Control UI/Sessions: make the compaction count a compact `N Checkpoint(s)` disclosure and show expanded session-level details with modern checkpoint history cards across responsive table layouts. Thanks @BunsDev.
134134
- Control UI/performance: keep chat and channel tabs responsive while history payloads and channel probes are slow, label partial channel status, and record slow chat/config render timings in the event log. Thanks @BunsDev.
135+
- ACP: preserve streamed chunk boundaries in background-task progress summaries so CJK text, paths, URLs, and identifiers are no longer split with synthetic spaces. Fixes #78312. Thanks @amknight.
135136
- Control UI/sessions: fire the documented `/new` command and lifecycle hooks only for explicit Control UI session creation, restoring session-memory and custom hook capture without changing SDK parent-session creates. Fixes #76957. Thanks @BunsDev.
136137
- Exec approvals: fall back to a guarded copy when Windows rejects rename-overwrite for `exec-approvals.json`, while preserving symlink, hard-link, and owner-only permission safeguards. Fixes #77785. (#77907) Thanks @Alex-Alaniz and @MilleniumGenAI.
137138
- Slack: preserve Socket Mode SDK error context and structured Slack API fields in reconnect logs, so startup failures no longer collapse to a bare `unknown error`.

‎src/acp/control-plane/manager.core.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,15 @@ function summarizeBackgroundTaskText(text: string): string {
9898
}
9999

100100
function appendBackgroundTaskProgressSummary(current: string, chunk: string): string {
101-
const normalizedChunk = normalizeText(chunk)?.replace(/\s+/g, " ");
101+
const normalizedChunk = chunk.replace(/\s+/g, " ");
102102
if (!normalizedChunk) {
103103
return current;
104104
}
105-
const combined = current ? `${current} ${normalizedChunk}` : normalizedChunk;
105+
const chunkToAppend = current ? normalizedChunk : normalizedChunk.trimStart();
106+
if (!chunkToAppend) {
107+
return current;
108+
}
109+
const combined = `${current}${chunkToAppend}`.replace(/\s+/g, " ");
106110
if (combined.length <= ACP_BACKGROUND_TASK_PROGRESS_MAX_LENGTH) {
107111
return combined;
108112
}

‎src/acp/control-plane/manager.test.ts‎

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,32 @@ describe("AcpSessionManager", () => {
313313
yield {
314314
type: "text_delta" as const,
315315
stream: "output" as const,
316-
text: "Write failed: permission denied for /root/oc-acp-write-should-fail.txt.",
316+
text: "Write failed: ",
317+
};
318+
yield {
319+
type: "text_delta" as const,
320+
stream: "output" as const,
321+
text: "permission ",
322+
};
323+
yield {
324+
type: "text_delta" as const,
325+
stream: "output" as const,
326+
text: "denied for ",
327+
};
328+
yield {
329+
type: "text_delta" as const,
330+
stream: "output" as const,
331+
text: "/root/",
332+
};
333+
yield {
334+
type: "text_delta" as const,
335+
stream: "output" as const,
336+
text: "oc-acp-write-",
337+
};
338+
yield {
339+
type: "text_delta" as const,
340+
stream: "output" as const,
341+
text: "should-fail.txt.",
317342
};
318343
yield { type: "done" as const };
319344
});
@@ -374,6 +399,90 @@ describe("AcpSessionManager", () => {
374399
});
375400
}, 300_000);
376401

402+
it("preserves token-streamed ACP progress boundaries in parented task summaries", async () => {
403+
await withAcpManagerTaskStateDir(async () => {
404+
const runtimeState = createRuntime();
405+
const chunks = [
406+
"현재 ",
407+
"작업 ",
408+
"디",
409+
"렉토",
410+
"리는 ",
411+
"/home/",
412+
"by",
413+
"kim",
414+
"0119/",
415+
".open",
416+
"claw/",
417+
"workspace",
418+
"\n\t",
419+
"입니다",
420+
];
421+
runtimeState.runTurn.mockImplementation(async function* () {
422+
for (const text of chunks) {
423+
yield {
424+
type: "text_delta" as const,
425+
stream: "output" as const,
426+
text,
427+
};
428+
}
429+
yield { type: "done" as const };
430+
});
431+
hoisted.requireAcpRuntimeBackendMock.mockReturnValue({
432+
id: "acpx",
433+
runtime: runtimeState.runtime,
434+
});
435+
hoisted.readAcpSessionEntryMock.mockImplementation((paramsUnknown: unknown) => {
436+
const sessionKey = (paramsUnknown as { sessionKey?: string }).sessionKey;
437+
if (sessionKey === "agent:codex:acp:child-1") {
438+
return {
439+
sessionKey,
440+
storeSessionKey: sessionKey,
441+
entry: {
442+
sessionId: "child-1",
443+
updatedAt: Date.now(),
444+
spawnedBy: "agent:quant:telegram:quant:direct:822430204",
445+
label: "Korean path",
446+
},
447+
acp: readySessionMeta(),
448+
};
449+
}
450+
if (sessionKey === "agent:quant:telegram:quant:direct:822430204") {
451+
return {
452+
sessionKey,
453+
storeSessionKey: sessionKey,
454+
entry: {
455+
sessionId: "parent-1",
456+
updatedAt: Date.now(),
457+
},
458+
};
459+
}
460+
return null;
461+
});
462+
463+
const manager = new AcpSessionManager();
464+
await manager.runTurn({
465+
cfg: baseCfg,
466+
sessionKey: "agent:codex:acp:child-1",
467+
text: "Print the current directory in Korean",
468+
mode: "prompt",
469+
requestId: "direct-parented-korean-path-run",
470+
});
471+
await flushMicrotasks();
472+
473+
expect(findTaskByRunId("direct-parented-korean-path-run")).toMatchObject({
474+
runtime: "acp",
475+
ownerKey: "agent:quant:telegram:quant:direct:822430204",
476+
scopeKind: "session",
477+
childSessionKey: "agent:codex:acp:child-1",
478+
label: "Korean path",
479+
task: "Print the current directory in Korean",
480+
status: "succeeded",
481+
progressSummary: "현재 작업 디렉토리는 /home/bykim0119/.openclaw/workspace 입니다",
482+
});
483+
});
484+
}, 300_000);
485+
377486
it("serializes concurrent turns for the same ACP session", async () => {
378487
const runtimeState = createRuntime();
379488
hoisted.requireAcpRuntimeBackendMock.mockReturnValue({

0 commit comments

Comments
 (0)