mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
chore(deadcode): inline runtime context builders
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
||||
buildCurrentInboundPrompt,
|
||||
buildCurrentInboundPromptContextPrefix,
|
||||
buildRuntimeContextCustomMessage,
|
||||
buildRuntimeContextSystemContext,
|
||||
resolveRuntimeContextPromptParts,
|
||||
} from "./runtime-context-prompt.js";
|
||||
|
||||
@@ -352,20 +351,14 @@ describe("runtime context prompt submission", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("labels next-turn runtime context only when used as prompt-local system context", () => {
|
||||
const systemContext = buildRuntimeContextSystemContext("secret runtime context");
|
||||
it("labels runtime-only events as system context", () => {
|
||||
const parts = resolveRuntimeContextPromptParts({
|
||||
effectivePrompt: "internal event",
|
||||
transcriptPrompt: "",
|
||||
});
|
||||
|
||||
expect(systemContext).toContain(
|
||||
"OpenClaw runtime context for the immediately preceding user message.",
|
||||
);
|
||||
expect(systemContext).toContain("not user-authored");
|
||||
expect(systemContext).toContain("secret runtime context");
|
||||
});
|
||||
|
||||
it("labels runtime-only events as system context", async () => {
|
||||
const { buildRuntimeEventSystemContext } = await import("./runtime-context-prompt.js");
|
||||
|
||||
expect(buildRuntimeEventSystemContext("internal event")).toContain("OpenClaw runtime event.");
|
||||
expect(buildRuntimeEventSystemContext("internal event")).toContain("not user-authored");
|
||||
expect(parts.runtimeSystemContext).toContain("OpenClaw runtime event.");
|
||||
expect(parts.runtimeSystemContext).toContain("not user-authored");
|
||||
expect(parts.runtimeSystemContext).toContain("internal event");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,7 +133,10 @@ export function resolveRuntimeContextPromptParts(params: {
|
||||
: {}),
|
||||
runtimeContext,
|
||||
runtimeOnly: true,
|
||||
runtimeSystemContext: buildRuntimeEventSystemContext(runtimeContext),
|
||||
runtimeSystemContext: buildRuntimeContextMessageContent({
|
||||
runtimeContext,
|
||||
kind: "runtime-event",
|
||||
}),
|
||||
}
|
||||
: {
|
||||
prompt: "",
|
||||
@@ -169,16 +172,6 @@ function buildRuntimeContextMessageContent(params: {
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
/** Builds the hidden next-turn system context payload for model conversion. */
|
||||
export function buildRuntimeContextSystemContext(runtimeContext: string): string {
|
||||
return buildRuntimeContextMessageContent({ runtimeContext, kind: "next-turn" });
|
||||
}
|
||||
|
||||
/** Builds the hidden runtime-event system context payload for empty runtime-only turns. */
|
||||
export function buildRuntimeEventSystemContext(runtimeContext: string): string {
|
||||
return buildRuntimeContextMessageContent({ runtimeContext, kind: "runtime-event" });
|
||||
}
|
||||
|
||||
/** Creates a non-displayed custom transcript message for runtime context, if any exists. */
|
||||
export function buildRuntimeContextCustomMessage(
|
||||
runtimeContext: string | undefined,
|
||||
@@ -190,7 +183,10 @@ export function buildRuntimeContextCustomMessage(
|
||||
return {
|
||||
role: "custom",
|
||||
customType: OPENCLAW_RUNTIME_CONTEXT_CUSTOM_TYPE,
|
||||
content: buildRuntimeContextSystemContext(trimmedRuntimeContext),
|
||||
content: buildRuntimeContextMessageContent({
|
||||
runtimeContext: trimmedRuntimeContext,
|
||||
kind: "next-turn",
|
||||
}),
|
||||
display: false,
|
||||
details: { source: "openclaw-runtime-context" },
|
||||
timestamp: Date.now(),
|
||||
|
||||
Reference in New Issue
Block a user