Skip to content

Commit 47a2efe

Browse files
committed
fix: hide display-hidden chat transcript messages
1 parent 9da0f80 commit 47a2efe

5 files changed

Lines changed: 109 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Docs: https://docs.openclaw.ai
2929
### Fixes
3030

3131
- Mac app: keep app-level menu commands and Dashboard failure states reachable when the remote Gateway is disconnected, and keep the Settings sidebar toggle in the leading titlebar area.
32+
- Gateway/webchat: hide internal runtime-context and other `display: false` transcript messages from Chat history and live message events. Fixes #83216. Thanks @EmpireCreator.
3233
- Mac app: align the Sessions settings pane with the standard Settings page gutter and row spacing.
3334
- OpenAI/Codex: stop rejecting available `openai-codex` GPT-5.1, GPT-5.2, and GPT-5.3 model refs during config validation, while keeping removed Spark aliases suppressed. Fixes #83303.
3435
- Codex app-server: preserve streamed native command output in mirrored transcripts and trajectory exports when final snapshots omit aggregated output. (#83200) Thanks @rozmiarD.

‎src/gateway/chat-display-projection.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createHash } from "node:crypto";
2+
import { OPENCLAW_RUNTIME_CONTEXT_CUSTOM_TYPE } from "../agents/internal-runtime-context.js";
23
import { isHeartbeatOkResponse, isHeartbeatUserMessage } from "../auto-reply/heartbeat-filter.js";
34
import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js";
45
import {
@@ -680,7 +681,17 @@ function isSubagentAnnounceInterSessionUserMessage(message: Record<string, unkno
680681
);
681682
}
682683

684+
function isDisplayHiddenProjectedMessage(message: Record<string, unknown>): boolean {
685+
if (message.display === false) {
686+
return true;
687+
}
688+
return message.role === "custom" && message.customType === OPENCLAW_RUNTIME_CONTEXT_CUSTOM_TYPE;
689+
}
690+
683691
function shouldHideProjectedHistoryMessage(message: Record<string, unknown>): boolean {
692+
if (isDisplayHiddenProjectedMessage(message)) {
693+
return true;
694+
}
684695
const roleContent = asRoleContentMessage(message);
685696
if (!roleContent) {
686697
return false;

‎src/gateway/server-methods/server-methods.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,13 @@ describe("projectRecentChatDisplayMessages", () => {
589589
{ role: "assistant", content: "older answer", timestamp: 2 },
590590
{ role: "assistant", content: "NO_REPLY", timestamp: 3 },
591591
{ role: "assistant", content: "ANNOUNCE_SKIP", timestamp: 4 },
592+
{
593+
role: "custom",
594+
customType: "openclaw.runtime-context",
595+
content: "hidden runtime context",
596+
display: false,
597+
timestamp: 5,
598+
},
592599
],
593600
{ maxMessages: 1 },
594601
);

‎src/gateway/session-history-state.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,34 @@ describe("SessionHistorySseState", () => {
310310
]);
311311
});
312312

313+
test("drops hidden runtime-context custom messages from projected history", () => {
314+
const snapshot = buildSessionHistorySnapshot({
315+
rawMessages: [
316+
{
317+
role: "custom",
318+
customType: "openclaw.runtime-context",
319+
content: "secret runtime context",
320+
display: false,
321+
__openclaw: { seq: 1 },
322+
},
323+
{
324+
role: "assistant",
325+
content: [{ type: "text", text: "visible answer" }],
326+
__openclaw: { seq: 2 },
327+
},
328+
],
329+
});
330+
331+
expect(snapshot.history.messages).toEqual([
332+
{
333+
role: "assistant",
334+
content: [{ type: "text", text: "visible answer" }],
335+
__openclaw: { seq: 2 },
336+
},
337+
]);
338+
expect(snapshot.rawTranscriptSeq).toBe(2);
339+
});
340+
313341
test("drops subagent announce inter-session user messages from projected history", () => {
314342
const snapshot = buildSessionHistorySnapshot({
315343
rawMessages: [
@@ -415,6 +443,16 @@ describe("SessionHistorySseState", () => {
415443
},
416444
}),
417445
).toBeNull();
446+
expect(
447+
state.appendInlineMessage({
448+
message: {
449+
role: "custom",
450+
customType: "openclaw.runtime-context",
451+
content: "secret runtime context",
452+
display: false,
453+
},
454+
}),
455+
).toBeNull();
418456
expect(
419457
state.appendInlineMessage({
420458
message: {

‎src/gateway/session-message-events.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,58 @@ describe("session.message websocket events", () => {
389389
});
390390
});
391391

392+
test("does not broadcast hidden runtime-context custom messages as live chat messages", async () => {
393+
const storePath = await createSessionStoreFile();
394+
await writeSessionStore({
395+
entries: {
396+
"hidden-runtime": {
397+
sessionId: "sess-hidden-runtime",
398+
updatedAt: Date.now(),
399+
},
400+
},
401+
storePath,
402+
});
403+
404+
await withOperatorSessionSubscriber(async (ws) => {
405+
const changedEventPromise = waitForSessionsChangedMessagePhase(
406+
ws,
407+
"agent:main:hidden-runtime",
408+
);
409+
await expectNoMessageWithin({
410+
watch: (timeoutMs) =>
411+
onceMessage(
412+
ws,
413+
(message) =>
414+
message.type === "event" &&
415+
message.event === "session.message" &&
416+
(message.payload as { sessionKey?: string } | undefined)?.sessionKey ===
417+
"agent:main:hidden-runtime",
418+
timeoutMs,
419+
),
420+
action: () => {
421+
emitSessionTranscriptUpdate({
422+
sessionFile: path.join(path.dirname(storePath), "sess-hidden-runtime.jsonl"),
423+
sessionKey: "agent:main:hidden-runtime",
424+
messageId: "runtime-context-1",
425+
messageSeq: 1,
426+
message: {
427+
role: "custom",
428+
customType: "openclaw.runtime-context",
429+
content: "secret runtime context",
430+
display: false,
431+
},
432+
});
433+
},
434+
});
435+
436+
const changedEvent = await changedEventPromise;
437+
expectRecordFields(changedEvent.payload, {
438+
sessionKey: "agent:main:hidden-runtime",
439+
phase: "message",
440+
});
441+
});
442+
});
443+
392444
test("includes live usage metadata on session.message and sessions.changed transcript events", async () => {
393445
const storePath = await createSessionStoreFile();
394446
await writeSessionStore({

0 commit comments

Comments
 (0)