mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-13 21:56:05 +00:00
#92589: fix(internal-runtime-context): wrap prompt-preface runtime context body in delimiters (#92593)
* fix(internal-runtime-context): wrap prompt-preface runtime context body in delimiters When buildRuntimeContextMessageContent constructs the hidden runtime context prompt block, the body (which may contain sensitive metadata like relevant-memories, sender info, and conversation metadata) was not wrapped in the standard INTERNAL_RUNTIME_CONTEXT_BEGIN/END delimiters. If the model echoed this context back in its reply, stripInternalRuntimeContext could only remove the header and notice lines — the sensitive body leaked through to user-visible surfaces like Feishu streaming cards. Wrap the runtime context body in BEGIN/END delimiters so the existing stripInternalRuntimeContext (which handles delimited blocks first) can fully remove the entire block. Closes #92589 * chore: retrigger CI for proof check * chore: retrigger CI with corrected proof format * chore: retrigger CI with corrected proof field format
This commit is contained in:
@@ -219,7 +219,9 @@ describe("runtime context prompt submission", () => {
|
||||
"OpenClaw runtime event.",
|
||||
"This context is runtime-generated, not user-authored. Keep internal details private.",
|
||||
"",
|
||||
"<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>",
|
||||
"internal event",
|
||||
"<<<END_OPENCLAW_INTERNAL_CONTEXT>>>",
|
||||
].join("\n"),
|
||||
});
|
||||
});
|
||||
@@ -242,7 +244,9 @@ describe("runtime context prompt submission", () => {
|
||||
"OpenClaw runtime event.",
|
||||
"This context is runtime-generated, not user-authored. Keep internal details private.",
|
||||
"",
|
||||
"<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>",
|
||||
"internal event",
|
||||
"<<<END_OPENCLAW_INTERNAL_CONTEXT>>>",
|
||||
].join("\n"),
|
||||
});
|
||||
});
|
||||
@@ -339,7 +343,9 @@ describe("runtime context prompt submission", () => {
|
||||
"OpenClaw runtime context for the immediately preceding user message.",
|
||||
"This context is runtime-generated, not user-authored. Keep internal details private.",
|
||||
"",
|
||||
"<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>",
|
||||
"secret runtime context",
|
||||
"<<<END_OPENCLAW_INTERNAL_CONTEXT>>>",
|
||||
].join("\n"),
|
||||
display: false,
|
||||
details: { source: "openclaw-runtime-context" },
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
import {
|
||||
extractInternalRuntimeContext,
|
||||
INTERNAL_RUNTIME_CONTEXT_BEGIN,
|
||||
INTERNAL_RUNTIME_CONTEXT_END,
|
||||
OPENCLAW_NEXT_TURN_RUNTIME_CONTEXT_HEADER,
|
||||
OPENCLAW_RUNTIME_CONTEXT_CUSTOM_TYPE,
|
||||
OPENCLAW_RUNTIME_CONTEXT_NOTICE,
|
||||
@@ -153,13 +155,18 @@ function buildRuntimeContextMessageContent(params: {
|
||||
runtimeContext: string;
|
||||
kind: "next-turn" | "runtime-event";
|
||||
}): string {
|
||||
// Wrap the runtime context body in delimited internal-context markers so
|
||||
// stripInternalRuntimeContext can fully remove the block when it leaks
|
||||
// into user-visible surfaces (e.g. Feishu streaming cards, #92589).
|
||||
return [
|
||||
params.kind === "runtime-event"
|
||||
? OPENCLAW_RUNTIME_EVENT_HEADER
|
||||
: OPENCLAW_NEXT_TURN_RUNTIME_CONTEXT_HEADER,
|
||||
OPENCLAW_RUNTIME_CONTEXT_NOTICE,
|
||||
"",
|
||||
INTERNAL_RUNTIME_CONTEXT_BEGIN,
|
||||
params.runtimeContext,
|
||||
INTERNAL_RUNTIME_CONTEXT_END,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user