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

推荐订阅源

G
Google Developers Blog
宝玉的分享
宝玉的分享
月光博客
月光博客
B
Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
博客园_首页
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
A
About on SuperTechFans
Y
Y Combinator Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
D
Docker
爱范儿
爱范儿
博客园 - 司徒正美
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net

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: keep Discord prompt metadata structured (#82168) · o...
steipete · 2026-05-15 · via Recent Commits to openclaw:main

@@ -19,8 +19,10 @@ import {

1919

buildInboundMetaSystemPrompt,

2020

buildInboundUserContextPrefix,

2121

} from "../../../src/auto-reply/reply/inbound-meta.js";

22+

import { buildReplyPromptEnvelope } from "../../../src/auto-reply/reply/prompt-prelude.js";

2223

import type { TemplateContext } from "../../../src/auto-reply/templating.js";

2324

import { SILENT_REPLY_TOKEN } from "../../../src/auto-reply/tokens.js";

25+

import { buildCurrentTurnPrompt } from "../../../src/agents/pi-embedded-runner/run/runtime-context-prompt.js";

2426

import type { OpenClawConfig } from "../../../src/config/config.js";

2527

import { makeTempWorkspace, writeWorkspaceFile } from "../../../src/test-helpers/workspace.js";

2628

@@ -106,6 +108,23 @@ function buildAutoReplyBody(params: { ctx: TemplateContext; body: string; eventL

106108

.join("\n\n");

107109

}

108110111+

function buildAutoReplyModelPrompt(params: { ctx: TemplateContext; body: string }): string {

112+

const inboundUserContext = buildInboundUserContextPrefix(params.ctx);

113+

const envelope = buildReplyPromptEnvelope({

114+

ctx: params.ctx,

115+

sessionCtx: params.ctx,

116+

baseBody: params.body,

117+

hasUserBody: true,

118+

inboundUserContext,

119+

isBareSessionReset: false,

120+

startupAction: "new",

121+

});

122+

return buildCurrentTurnPrompt({

123+

context: envelope.currentTurnContext,

124+

prompt: envelope.queuedBody,

125+

});

126+

}

127+109128

async function readContextFiles(workspaceDir: string, fileNames: string[]) {

110129

return Promise.all(

111130

fileNames.map(async (fileName) => ({

@@ -422,6 +441,60 @@ function createGroupScenario(workspaceDir: string): PromptScenario {

422441

};

423442

}

424443444+

function createDiscordBoundaryScenario(workspaceDir: string): PromptScenario {

445+

const body = "Please summarize the deploy log.";

446+

const baseCtx: TemplateContext = {

447+

Provider: "discord",

448+

Surface: "discord",

449+

OriginatingChannel: "discord",

450+

OriginatingTo: "channel:987654321",

451+

AccountId: "A1",

452+

ChatType: "channel",

453+

GroupSubject: "#ops-bridge",

454+

GroupChannel: "#ops-bridge",

455+

GroupSpace: "guild-123",

456+

SenderId: "U3",

457+

SenderName: "Cael",

458+

MessageSid: "1503084621145964846",

459+

Body: body,

460+

BodyStripped: body,

461+

UntrustedStructuredContext: [

462+

{

463+

label: "Discord channel metadata",

464+

source: "discord",

465+

type: "channel_metadata",

466+

payload: {

467+

topic: "Deploy coordination",

468+

},

469+

},

470+

],

471+

};

472+

return {

473+

scenario: "auto-reply-discord-boundary",

474+

focus: "Discord inbound body remains one user turn while supplemental context is structured metadata",

475+

expectedStableSystemAfterTurnIds: [],

476+

turns: [

477+

{

478+

id: "t1",

479+

label: "Discord turn with channel metadata",

480+

systemPrompt: buildAutoReplySystemPrompt({

481+

workspaceDir,

482+

sessionCtx: baseCtx,

483+

includeGroupChatContext: true,

484+

}),

485+

bodyPrompt: buildAutoReplyModelPrompt({

486+

ctx: baseCtx,

487+

body,

488+

}),

489+

notes: [

490+

"Inbound body should appear once in the model-bound prompt",

491+

"Channel metadata should not use raw EXTERNAL_UNTRUSTED_CONTENT wrappers",

492+

],

493+

},

494+

],

495+

};

496+

}

497+425498

async function createToolRichScenario(workspaceDir: string): Promise<PromptScenario> {

426499

const skillsPrompt = [

427500

"<available_skills>",

@@ -701,6 +774,7 @@ export async function createPromptCompositionScenarios(): Promise<{

701774

const scenarios = [

702775

createDirectScenario(workspaceDir),

703776

createGroupScenario(workspaceDir),

777+

createDiscordBoundaryScenario(workspaceDir),

704778

await createToolRichScenario(workspaceDir),

705779

await createBootstrapWarningScenario(warningWorkspaceDir),

706780

await createMaintenanceScenario(workspaceDir),