mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
chore(deadcode): inline inbound prompt prefix
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildCurrentInboundPrompt,
|
||||
buildCurrentInboundPromptContextPrefix,
|
||||
buildRuntimeContextCustomMessage,
|
||||
resolveRuntimeContextPromptParts,
|
||||
} from "./runtime-context-prompt.js";
|
||||
@@ -282,31 +281,6 @@ describe("runtime context prompt submission", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses current-turn context as prompt-local text", () => {
|
||||
expect(
|
||||
buildCurrentInboundPromptContextPrefix({
|
||||
text: "Conversation info (untrusted metadata):\n```json\n{}\n```",
|
||||
}),
|
||||
).toBe("Conversation info (untrusted metadata):\n```json\n{}\n```");
|
||||
});
|
||||
|
||||
it("can use compact current-turn context for resumable backends", () => {
|
||||
expect(
|
||||
buildCurrentInboundPromptContextPrefix(
|
||||
{
|
||||
text: "Room context:\nAlice: lunch?\n\nCurrent event:\nBob: yes",
|
||||
resumableText: "Current event:\nBob: yes",
|
||||
},
|
||||
{ preferResumableText: true },
|
||||
),
|
||||
).toBe("Current event:\nBob: yes");
|
||||
});
|
||||
|
||||
it("omits empty current-turn context", () => {
|
||||
expect(buildCurrentInboundPromptContextPrefix(undefined)).toBe("");
|
||||
expect(buildCurrentInboundPromptContextPrefix({ text: " " })).toBe("");
|
||||
});
|
||||
|
||||
it("joins current-turn context and prompt with the requested separator", () => {
|
||||
expect(
|
||||
buildCurrentInboundPrompt({
|
||||
@@ -332,6 +306,13 @@ describe("runtime context prompt submission", () => {
|
||||
preferResumableText: true,
|
||||
}),
|
||||
).toBe("Current event:\nBob: yes\n\n[OpenClaw room event]");
|
||||
|
||||
expect(
|
||||
buildCurrentInboundPrompt({
|
||||
context: { text: " " },
|
||||
prompt: "visible ask",
|
||||
}),
|
||||
).toBe("visible ask");
|
||||
});
|
||||
|
||||
it("builds runtime context as prompt-local custom context before the current user prompt", () => {
|
||||
|
||||
@@ -34,27 +34,17 @@ export type RuntimeContextCustomMessage = {
|
||||
|
||||
type EmptyTranscriptMode = "model-prompt" | "runtime-event";
|
||||
|
||||
/** Returns the visible or resumable inbound prompt prefix used before the user prompt. */
|
||||
export function buildCurrentInboundPromptContextPrefix(
|
||||
context: CurrentInboundPromptContext | undefined,
|
||||
options?: { preferResumableText?: boolean },
|
||||
): string {
|
||||
const text =
|
||||
options?.preferResumableText === true
|
||||
? (context?.resumableText ?? context?.text)
|
||||
: context?.text;
|
||||
return text?.trim() ?? "";
|
||||
}
|
||||
|
||||
/** Combines inbound context and the current prompt using the channel-provided joiner. */
|
||||
export function buildCurrentInboundPrompt(params: {
|
||||
context: CurrentInboundPromptContext | undefined;
|
||||
prompt: string;
|
||||
preferResumableText?: boolean;
|
||||
}): string {
|
||||
const prefix = buildCurrentInboundPromptContextPrefix(params.context, {
|
||||
preferResumableText: params.preferResumableText,
|
||||
});
|
||||
const contextText =
|
||||
params.preferResumableText === true
|
||||
? (params.context?.resumableText ?? params.context?.text)
|
||||
: params.context?.text;
|
||||
const prefix = contextText?.trim() ?? "";
|
||||
if (!prefix) {
|
||||
return params.prompt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user