Skip to content

Commit 7b9ddbd

Browse files
committed
chore(deadcode): inline inbound prompt prefix
1 parent 0f83051 commit 7b9ddbd

2 files changed

Lines changed: 12 additions & 41 deletions

File tree

src/agents/embedded-agent-runner/run/runtime-context-prompt.test.ts

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { describe, expect, it } from "vitest";
44
import {
55
buildCurrentInboundPrompt,
6-
buildCurrentInboundPromptContextPrefix,
76
buildRuntimeContextCustomMessage,
87
resolveRuntimeContextPromptParts,
98
} from "./runtime-context-prompt.js";
@@ -282,31 +281,6 @@ describe("runtime context prompt submission", () => {
282281
});
283282
});
284283

285-
it("uses current-turn context as prompt-local text", () => {
286-
expect(
287-
buildCurrentInboundPromptContextPrefix({
288-
text: "Conversation info (untrusted metadata):\n```json\n{}\n```",
289-
}),
290-
).toBe("Conversation info (untrusted metadata):\n```json\n{}\n```");
291-
});
292-
293-
it("can use compact current-turn context for resumable backends", () => {
294-
expect(
295-
buildCurrentInboundPromptContextPrefix(
296-
{
297-
text: "Room context:\nAlice: lunch?\n\nCurrent event:\nBob: yes",
298-
resumableText: "Current event:\nBob: yes",
299-
},
300-
{ preferResumableText: true },
301-
),
302-
).toBe("Current event:\nBob: yes");
303-
});
304-
305-
it("omits empty current-turn context", () => {
306-
expect(buildCurrentInboundPromptContextPrefix(undefined)).toBe("");
307-
expect(buildCurrentInboundPromptContextPrefix({ text: " " })).toBe("");
308-
});
309-
310284
it("joins current-turn context and prompt with the requested separator", () => {
311285
expect(
312286
buildCurrentInboundPrompt({
@@ -332,6 +306,13 @@ describe("runtime context prompt submission", () => {
332306
preferResumableText: true,
333307
}),
334308
).toBe("Current event:\nBob: yes\n\n[OpenClaw room event]");
309+
310+
expect(
311+
buildCurrentInboundPrompt({
312+
context: { text: " " },
313+
prompt: "visible ask",
314+
}),
315+
).toBe("visible ask");
335316
});
336317

337318
it("builds runtime context as prompt-local custom context before the current user prompt", () => {

src/agents/embedded-agent-runner/run/runtime-context-prompt.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,17 @@ export type RuntimeContextCustomMessage = {
3434

3535
type EmptyTranscriptMode = "model-prompt" | "runtime-event";
3636

37-
/** Returns the visible or resumable inbound prompt prefix used before the user prompt. */
38-
export function buildCurrentInboundPromptContextPrefix(
39-
context: CurrentInboundPromptContext | undefined,
40-
options?: { preferResumableText?: boolean },
41-
): string {
42-
const text =
43-
options?.preferResumableText === true
44-
? (context?.resumableText ?? context?.text)
45-
: context?.text;
46-
return text?.trim() ?? "";
47-
}
48-
4937
/** Combines inbound context and the current prompt using the channel-provided joiner. */
5038
export function buildCurrentInboundPrompt(params: {
5139
context: CurrentInboundPromptContext | undefined;
5240
prompt: string;
5341
preferResumableText?: boolean;
5442
}): string {
55-
const prefix = buildCurrentInboundPromptContextPrefix(params.context, {
56-
preferResumableText: params.preferResumableText,
57-
});
43+
const contextText =
44+
params.preferResumableText === true
45+
? (params.context?.resumableText ?? params.context?.text)
46+
: params.context?.text;
47+
const prefix = contextText?.trim() ?? "";
5848
if (!prefix) {
5949
return params.prompt;
6050
}

0 commit comments

Comments
 (0)