Skip to content

Commit 496ef22

Browse files
committed
fix(codex): classify silent finals with the delivery payload predicate
Token-only matching missed JSON and reasoning-wrapped NO_REPLY payloads, so a trailing control envelope could join into the visible answer. Use the shared payload-level predicate.
1 parent 075865c commit 496ef22

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

‎extensions/codex/src/app-server/event-projector-assistant.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { EmbeddedRunAttemptParamsV2 as EmbeddedRunAttemptParams } from "openclaw/plugin-sdk/agent-harness-runtime";
22
import type { AssistantMessage } from "openclaw/plugin-sdk/llm";
3-
import { isSilentReplyText } from "openclaw/plugin-sdk/reply-runtime";
3+
import { isSilentReplyPayloadText } from "openclaw/plugin-sdk/reply-chunking";
44
import { readStringField as readString } from "openclaw/plugin-sdk/string-coerce-runtime";
55
import {
66
createAssistantCommentaryMessage as buildAssistantCommentaryMessage,
@@ -314,7 +314,7 @@ export class CodexAssistantProjection {
314314

315315
collectAssistantTexts(): string[] {
316316
const afterHandoff = this.collectPersistableAssistantTexts(this.persistableAssistantBarrier);
317-
const audibleAfterHandoff = afterHandoff.filter((text) => !isSilentReplyText(text));
317+
const audibleAfterHandoff = afterHandoff.filter((text) => !isSilentReplyPayloadText(text));
318318
if (audibleAfterHandoff.length > 0) {
319319
return audibleAfterHandoff;
320320
}
@@ -324,7 +324,7 @@ export class CodexAssistantProjection {
324324
return afterHandoff.slice(-1);
325325
}
326326
const recoveredAudible = this.collectPersistableAssistantTexts(0).filter(
327-
(text) => !isSilentReplyText(text),
327+
(text) => !isSilentReplyPayloadText(text),
328328
);
329329
if (recoveredAudible.length > 0) {
330330
return recoveredAudible.slice(-1);

‎extensions/codex/src/app-server/event-projector.assistant.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,53 @@ describe("CodexAppServerEventProjector assistant projection", () => {
354354
expect(JSON.stringify(result.messagesSnapshot)).not.toContain("NO_REPLY");
355355
});
356356

357+
it("drops a trailing JSON silent payload when an earlier audible final remains", async () => {
358+
const projector = await createProjector(await createParams());
359+
const jsonSilent = '{"action":"NO_REPLY"}';
360+
361+
await projector.handleNotification(
362+
forCurrentTurn("item/started", {
363+
item: { type: "agentMessage", id: "answer-1", phase: "final_answer", text: "" },
364+
}),
365+
);
366+
await projector.handleNotification(agentMessageDelta("Keep this answer", "answer-1"));
367+
await projector.handleNotification(
368+
forCurrentTurn("item/completed", {
369+
item: {
370+
type: "agentMessage",
371+
id: "answer-1",
372+
phase: "final_answer",
373+
text: "Keep this answer",
374+
},
375+
}),
376+
);
377+
await projector.handleNotification(
378+
forCurrentTurn("item/started", {
379+
item: { type: "agentMessage", id: "answer-2", phase: "final_answer", text: "" },
380+
}),
381+
);
382+
await projector.handleNotification(agentMessageDelta(jsonSilent, "answer-2"));
383+
await projector.handleNotification(
384+
forCurrentTurn("item/completed", {
385+
item: {
386+
type: "agentMessage",
387+
id: "answer-2",
388+
phase: "final_answer",
389+
text: jsonSilent,
390+
},
391+
}),
392+
);
393+
await projector.handleNotification(
394+
turnCompleted([
395+
{ type: "agentMessage", id: "answer-2", phase: "final_answer", text: jsonSilent },
396+
]),
397+
);
398+
399+
const result = projector.buildResult(buildEmptyToolTelemetry());
400+
expect(result.assistantTexts).toEqual(["Keep this answer"]);
401+
expect(JSON.stringify(result.messagesSnapshot)).not.toContain(jsonSilent);
402+
});
403+
357404
it("keeps a final answer that arrives while an earlier native tool is still active", async () => {
358405
const projector = await createProjector(await createParams());
359406

0 commit comments

Comments
 (0)