惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
量子位
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
博客园 - 聂微东
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
U
Unit 42
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(codex): bound delivery hint prompts · openclaw/opencl...
vincentkoc · 2026-06-21 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -586,6 +586,51 @@ export function prependCodexOpenClawPromptContext(

586586

return [context?.trim(), deliverySection, promptSection].filter(Boolean).join("\n\n");

587587

}

588588
589+

/**

590+

* Maps the surviving user-request portion of an input range after delivery

591+

* metadata has been relocated before the request.

592+

*/

593+

export function resolveCodexDeliveryHintPreservedInputRange(params: {

594+

prompt: string;

595+

promptInputRange: { start: number; end: number } | undefined;

596+

decoratedPrompt: string;

597+

}): { start: number; end: number } | undefined {

598+

const { prompt, promptInputRange, decoratedPrompt } = params;

599+

const { deliveryHint, prompt: promptWithoutDeliveryHint } = splitLeadingCodexDeliveryHint(prompt);

600+

if (

601+

!deliveryHint ||

602+

!promptInputRange ||

603+

promptInputRange.start < 0 ||

604+

promptInputRange.end < promptInputRange.start ||

605+

promptInputRange.end > prompt.length ||

606+

!decoratedPrompt.endsWith(promptWithoutDeliveryHint)

607+

) {

608+

return undefined;

609+

}

610+

const promptWithoutDeliveryHintStart = prompt.length - promptWithoutDeliveryHint.length;

611+

const inputStart = Math.max(promptInputRange.start, promptWithoutDeliveryHintStart);

612+

const inputEnd = Math.max(

613+

inputStart,

614+

Math.min(

615+

promptInputRange.end,

616+

promptWithoutDeliveryHint.length + promptWithoutDeliveryHintStart,

617+

),

618+

);

619+

const decoratedPromptSuffixStart = decoratedPrompt.length - promptWithoutDeliveryHint.length;

620+

const requestHeader = "Current user request:\n";

621+

const requestHeaderStart = decoratedPromptSuffixStart - requestHeader.length;

622+

// Delivery metadata moves outside the request, so retain the remaining input

623+

// span rather than treating the original, now non-contiguous range as valid.

624+

return {

625+

start:

626+

inputStart === promptWithoutDeliveryHintStart &&

627+

decoratedPrompt.slice(requestHeaderStart, decoratedPromptSuffixStart) === requestHeader

628+

? requestHeaderStart

629+

: decoratedPromptSuffixStart + inputStart - promptWithoutDeliveryHintStart,

630+

end: decoratedPromptSuffixStart + inputEnd - promptWithoutDeliveryHintStart,

631+

};

632+

}

633+
589634

function splitLeadingCodexDeliveryHint(prompt: string): {

590635

deliveryHint?: string;

591636

prompt: string;

Original file line numberDiff line numberDiff line change

@@ -13,6 +13,7 @@ import {

1313

initializeGlobalHookRunner,

1414

resetGlobalHookRunner,

1515

} from "openclaw/plugin-sdk/hook-runtime";

16+

import { MESSAGE_TOOL_DELIVERY_HINTS } from "openclaw/plugin-sdk/message-tool-delivery-hints";

1617

import { createMockPluginRegistry } from "openclaw/plugin-sdk/plugin-test-runtime";

1718

import { registerSandboxBackend } from "openclaw/plugin-sdk/sandbox";

1819

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

@@ -567,6 +568,33 @@ describe("runCodexAppServerAttempt context-engine lifecycle", () => {

567568

await run;

568569

});

569570
571+

it("bounds hook-appended prompts after delivery metadata is relocated", async () => {

572+

initializeGlobalHookRunner(

573+

createMockPluginRegistry([

574+

{

575+

hookName: "before_prompt_build",

576+

handler: async () => ({ appendContext: `hook context ${"h".repeat(1_100_000)}` }),

577+

},

578+

]),

579+

);

580+

const sessionFile = path.join(tempDir, "session-delivery-hint.jsonl");

581+

const workspaceDir = path.join(tempDir, "workspace-delivery-hint");

582+

const harness = createStartedThreadHarness();

583+

const params = createParams(sessionFile, workspaceDir);

584+

params.prompt = `${MESSAGE_TOOL_DELIVERY_HINTS[0]}\n\ncurrent prompt survives`;

585+
586+

const run = runCodexAppServerAttempt(params);

587+

await harness.waitForMethod("turn/start");

588+
589+

const inputText = getRequestInputText(harness);

590+

expect(inputText.length).toBeLessThanOrEqual(CODEX_TURN_START_TEXT_INPUT_MAX_CHARS);

591+

expect(inputText).toContain("Current user request:\ncurrent prompt survives");

592+

expect(inputText).not.toContain("hook context");

593+
594+

await harness.completeTurn();

595+

await run;

596+

});

597+
570598

it("bounds hook-appended output for an empty prompt without an active context engine", async () => {

571599

initializeGlobalHookRunner(

572600

createMockPluginRegistry([

Original file line numberDiff line numberDiff line change

@@ -66,6 +66,7 @@ import {

6666

readContextEngineThreadBootstrapProjection,

6767

readMirroredSessionHistoryMessages,

6868

renderCodexSkillsCollaborationInstructions,

69+

resolveCodexDeliveryHintPreservedInputRange,

6970

resolveContextEngineBootstrapProjectionDecision,

7071

} from "./attempt-context.js";

7172

import {

@@ -1115,11 +1116,17 @@ export async function runCodexAppServerAttempt(

11151116

promptBuild.promptInputRange,

11161117

turnPromptText,

11171118

);

1118-

const preservedRange = resolveShiftedPromptInputRange(

1119-

promptBuild.prompt,

1120-

promptBuild.promptInputRange,

1121-

turnPromptText,

1122-

);

1119+

const preservedRange =

1120+

resolveShiftedPromptInputRange(

1121+

promptBuild.prompt,

1122+

promptBuild.promptInputRange,

1123+

turnPromptText,

1124+

) ??

1125+

resolveCodexDeliveryHintPreservedInputRange({

1126+

prompt: promptBuild.prompt,

1127+

promptInputRange: promptBuild.promptInputRange,

1128+

decoratedPrompt: turnPromptText,

1129+

});

11231130

return fitCodexProjectedContextForTurnStart({

11241131

promptText: turnPromptText,

11251132

contextRange: projectedRanges?.contextRange,