Skip to content

Commit f4df511

Browse files
fix(acp): a notice no longer splits the message it arrives in
The notice item closed open text streams first. When the agent kept streaming the same messageId afterwards, the next chunk started a new segment under the same item id and replaced the earlier text. A notice isn't conversation content, so the message now stays open across it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 789b99b commit f4df511

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,17 @@ const program = Effect.gen(function* () {
11721172
}
11731173

11741174
if (emitNotice) {
1175-
// fx 0.0.14's shape for a skipped skill.
1175+
// A notice in fx 0.0.14's shape for a skipped skill, between two chunks of one message.
1176+
const chunk = (text: string) =>
1177+
writeJsonRpcNotification("session/update", {
1178+
sessionId: requestedSessionId,
1179+
update: {
1180+
sessionUpdate: "agent_message_chunk",
1181+
messageId: "mock-notice-message",
1182+
content: { type: "text", text },
1183+
},
1184+
});
1185+
chunk("before the notice, ");
11761186
writeJsonRpcNotification("session/update", {
11771187
sessionId: requestedSessionId,
11781188
update: {
@@ -1181,6 +1191,8 @@ const program = Effect.gen(function* () {
11811191
title: "skill discovery warning: candidate was skipped because its metadata is invalid",
11821192
},
11831193
});
1194+
chunk("after the notice");
1195+
return yield* finishPrompt(requestedSessionId, "end_turn");
11841196
}
11851197

11861198
if (emitV2Fidelity) {

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,9 +2129,13 @@ describe("AcpAdapterV2", () => {
21292129
items.flatMap((item) => (item.type === "system_notice" ? [item.message] : [])),
21302130
[title],
21312131
);
2132-
assert.isFalse(
2133-
items.some((item) => item.type === "assistant_message" && item.text.includes(title)),
2134-
"a notice is not part of the reply",
2132+
const replies = new Map(
2133+
items.flatMap((item) => (item.type === "assistant_message" ? [[item.id, item.text]] : [])),
2134+
);
2135+
assert.deepEqual(
2136+
[...replies.values()],
2137+
["before the notice, after the notice"],
2138+
"a notice neither joins the reply nor splits it",
21352139
);
21362140
}).pipe(Effect.provide(layerTest), Effect.scoped),
21372141
);

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3878,12 +3878,14 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
38783878
yield* rearmDeferredFinalize(context);
38793879
});
38803880

3881-
/** Notices have no id; each is its own item, numbered by the turn's item count. */
3881+
/**
3882+
* Notices have no id; each is its own item, numbered by the turn's item count.
3883+
* A notice is not conversation content, so an open message keeps streaming across it.
3884+
*/
38823885
const emitNotice = Effect.fnUntraced(function* (
38833886
context: ActiveAcpTurn,
38843887
notice: { readonly title: string; readonly description?: string },
38853888
) {
3886-
yield* closeTextStreams(context);
38873889
const nativeItemId = `${context.nativeTurnId}:notice:${context.itemOrdinals.size}`;
38883890
const now = yield* DateTime.now;
38893891
yield* emitProviderEvent({

0 commit comments

Comments
 (0)