fix(codex): bound inbound projected context · openclaw/openclaw@43e8c29
vincentkoc
·
2026-06-21
·
via Recent Commits to openclaw:main
File tree
extensions/codex/src/app-server
| Original file line number | Diff line number | Diff line change |
|---|
@@ -525,13 +525,15 @@ describe("runCodexAppServerAttempt context-engine lifecycle", () => {
|
525 | 525 | params.contextEngine = contextEngine; |
526 | 526 | params.contextTokenBudget = 300_000; |
527 | 527 | params.prompt = "current prompt survives"; |
| 528 | +params.currentInboundContext = { text: "current inbound context survives" }; |
528 | 529 | |
529 | 530 | const run = runCodexAppServerAttempt(params); |
530 | 531 | await harness.waitForMethod("turn/start"); |
531 | 532 | |
532 | 533 | const inputText = getRequestInputText(harness); |
533 | 534 | expect(inputText.length).toBeLessThanOrEqual(CODEX_TURN_START_TEXT_INPUT_MAX_CHARS); |
534 | 535 | expect(inputText).toContain("recent anchor"); |
| 536 | +expect(inputText).toContain("current inbound context survives"); |
535 | 537 | expect(inputText).toContain("current prompt survives"); |
536 | 538 | |
537 | 539 | await harness.completeTurn(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1033,13 +1033,18 @@ export async function runCodexAppServerAttempt(
|
1033 | 1033 | promptInputRange: { start: number; end: number } | undefined, |
1034 | 1034 | turnPromptText: string, |
1035 | 1035 | ): CodexProjectedContextRange | undefined => { |
| 1036 | +const promptTextInputOffset = promptInputRange |
| 1037 | + ? promptInputRange.end - promptText.length |
| 1038 | + : undefined; |
1036 | 1039 | if ( |
1037 | 1040 | !promptContextRange || |
1038 | 1041 | !promptInputRange || |
| 1042 | +promptTextInputOffset === undefined || |
1039 | 1043 | promptInputRange.start < 0 || |
1040 | 1044 | promptInputRange.end < promptInputRange.start || |
1041 | 1045 | promptInputRange.end > prompt.length || |
1042 | | -prompt.slice(promptInputRange.start, promptInputRange.end) !== promptText || |
| 1046 | +promptTextInputOffset < promptInputRange.start || |
| 1047 | +prompt.slice(promptTextInputOffset, promptInputRange.end) !== promptText || |
1043 | 1048 | !turnPromptText.endsWith(prompt) |
1044 | 1049 | ) { |
1045 | 1050 | return undefined; |
@@ -1049,7 +1054,7 @@ export async function runCodexAppServerAttempt(
|
1049 | 1054 | // earlier input span. The exact input range still covers prepend-only hooks. |
1050 | 1055 | const promptTextOffset = prompt.endsWith(promptText) |
1051 | 1056 | ? prompt.length - promptText.length |
1052 | | - : promptInputRange.end - promptText.length; |
| 1057 | + : promptTextInputOffset; |
1053 | 1058 | if (promptTextOffset < 0) { |
1054 | 1059 | return undefined; |
1055 | 1060 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。