mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 11:02:26 +00:00
fix(codex): bound inbound projected context
This commit is contained in:
@@ -525,6 +525,7 @@ describe("runCodexAppServerAttempt context-engine lifecycle", () => {
|
||||
params.contextEngine = contextEngine;
|
||||
params.contextTokenBudget = 300_000;
|
||||
params.prompt = "current prompt survives";
|
||||
params.currentInboundContext = { text: "current inbound context survives" };
|
||||
|
||||
const run = runCodexAppServerAttempt(params);
|
||||
await harness.waitForMethod("turn/start");
|
||||
@@ -532,6 +533,7 @@ describe("runCodexAppServerAttempt context-engine lifecycle", () => {
|
||||
const inputText = getRequestInputText(harness);
|
||||
expect(inputText.length).toBeLessThanOrEqual(CODEX_TURN_START_TEXT_INPUT_MAX_CHARS);
|
||||
expect(inputText).toContain("recent anchor");
|
||||
expect(inputText).toContain("current inbound context survives");
|
||||
expect(inputText).toContain("current prompt survives");
|
||||
|
||||
await harness.completeTurn();
|
||||
|
||||
@@ -1033,13 +1033,18 @@ export async function runCodexAppServerAttempt(
|
||||
promptInputRange: { start: number; end: number } | undefined,
|
||||
turnPromptText: string,
|
||||
): CodexProjectedContextRange | undefined => {
|
||||
const promptTextInputOffset = promptInputRange
|
||||
? promptInputRange.end - promptText.length
|
||||
: undefined;
|
||||
if (
|
||||
!promptContextRange ||
|
||||
!promptInputRange ||
|
||||
promptTextInputOffset === undefined ||
|
||||
promptInputRange.start < 0 ||
|
||||
promptInputRange.end < promptInputRange.start ||
|
||||
promptInputRange.end > prompt.length ||
|
||||
prompt.slice(promptInputRange.start, promptInputRange.end) !== promptText ||
|
||||
promptTextInputOffset < promptInputRange.start ||
|
||||
prompt.slice(promptTextInputOffset, promptInputRange.end) !== promptText ||
|
||||
!turnPromptText.endsWith(prompt)
|
||||
) {
|
||||
return undefined;
|
||||
@@ -1049,7 +1054,7 @@ export async function runCodexAppServerAttempt(
|
||||
// earlier input span. The exact input range still covers prepend-only hooks.
|
||||
const promptTextOffset = prompt.endsWith(promptText)
|
||||
? prompt.length - promptText.length
|
||||
: promptInputRange.end - promptText.length;
|
||||
: promptTextInputOffset;
|
||||
if (promptTextOffset < 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user