fix(harness): preserve empty prompt ranges · openclaw/openclaw@15f2a56
vincentkoc
·
2026-06-21
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,4 +44,23 @@ describe("resolveAgentHarnessBeforePromptBuildResult", () => {
|
44 | 44 | promptInputRange: { start: 16, end: 21 }, |
45 | 45 | }); |
46 | 46 | }); |
| 47 | + |
| 48 | +it("keeps an empty input range between prepended and appended context", async () => { |
| 49 | +const result = await resolveAgentHarnessBeforePromptBuildResult({ |
| 50 | +prompt: "", |
| 51 | +developerInstructions: "base instructions", |
| 52 | +messages: [], |
| 53 | +ctx: {}, |
| 54 | +beforeAgentStartResult: { |
| 55 | +appendContext: "appended context", |
| 56 | +prependContext: "prepended context", |
| 57 | +}, |
| 58 | +}); |
| 59 | + |
| 60 | +expect(result).toEqual({ |
| 61 | +prompt: "prepended context\n\nappended context", |
| 62 | +developerInstructions: "base instructions", |
| 63 | +promptInputRange: { start: 17, end: 17 }, |
| 64 | +}); |
| 65 | +}); |
47 | 66 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -88,7 +88,12 @@ export async function resolveAgentHarnessBeforePromptBuildResult(params: {
|
88 | 88 | ]); |
89 | 89 | const prompt = |
90 | 90 | joinPresentTextSegments([promptPrefix, params.prompt, promptSuffix]) ?? params.prompt; |
91 | | -const promptInputStart = promptPrefix ? promptPrefix.length + 2 : 0; |
| 91 | +const promptInputStart = |
| 92 | +params.prompt.length === 0 |
| 93 | + ? (promptPrefix?.length ?? 0) |
| 94 | + : promptPrefix |
| 95 | + ? promptPrefix.length + 2 |
| 96 | + : 0; |
92 | 97 | return { |
93 | 98 | prompt, |
94 | 99 | developerInstructions: |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。