diff --git a/src/agents/embedded-agent-runner/run/runtime-context-prompt.test.ts b/src/agents/embedded-agent-runner/run/runtime-context-prompt.test.ts index 93340e8b10c0..1f8d1595e7d9 100644 --- a/src/agents/embedded-agent-runner/run/runtime-context-prompt.test.ts +++ b/src/agents/embedded-agent-runner/run/runtime-context-prompt.test.ts @@ -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", () => { diff --git a/src/agents/embedded-agent-runner/run/runtime-context-prompt.ts b/src/agents/embedded-agent-runner/run/runtime-context-prompt.ts index a7d239a69be8..5406fa52ca3b 100644 --- a/src/agents/embedded-agent-runner/run/runtime-context-prompt.ts +++ b/src/agents/embedded-agent-runner/run/runtime-context-prompt.ts @@ -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; }