Skip to content

feat(prompts): inject external-knowledge discipline into planner prompts (Closes #360)#361

Merged
ceilf6 merged 2 commits into
developfrom
improve/planner-external-knowledge-protocol
Jun 15, 2026
Merged

feat(prompts): inject external-knowledge discipline into planner prompts (Closes #360)#361
ceilf6 merged 2 commits into
developfrom
improve/planner-external-knowledge-protocol

Conversation

@ceilf6

@ceilf6 ceilf6 commented Jun 14, 2026

Copy link
Copy Markdown
Member

Linked Issue Or Context

Closes #360 — feat(prompts): inject a "verify before assume" external-knowledge discipline into the planner so it knows WHEN to use the already-existing web_fetch capability.

Summary

The web_fetch action already exists and is mechanically described, but nothing tells the planner when to consult external docs. This adds that discipline:

  • New exported constant EXTERNAL_KNOWLEDGE_PROTOCOL in packages/core/src/llm/prompts.ts, parallel in style/tone/format to PROGRESSIVE_EXPLORATION_PROTOCOL (Chinese protocol block, heading + numbered points). It tells the planner to consult authoritative sources (official docs / API reference) via web_fetch before planning or writing code when facing 不熟悉 / 版本特定 / 最近才出现 libraries, frameworks, or APIs — instead of guessing API shape or default behavior — and includes a reverse guard so 已经熟知且稳定 knowledge is not needlessly fetched.
  • Wired ${EXTERNAL_KNOWLEDGE_PROTOCOL} into BOTH planner system prompts (generatePlanInTwoPhases outline system and generatePlanSinglePhase system) in packages/core/src/llm/plan-generation.ts, immediately after the existing ${PROGRESSIVE_EXPLORATION_PROTOCOL} interpolation; imported alongside it.

Impact Scope

Prompt-only. No executor, schemas, tool routing, or web_fetch runtime behavior changed. No new action enums. web_search intentionally out of scope.

GitNexus Impact Summary

  • Risk level: LOW
  • Critical skeleton changes: None. Additive prompt-string content only; no function signatures, return types, control flow, schemas, or tool routing changed.
  • GitNexus impact: impact(generatePlanInTwoPhases, upstream) → risk LOW, 0 direct callers broken (impactedCount 0). impact(generatePlanSinglePhase, upstream) → risk LOW, 1 direct caller (generatePlan, CALLS), no signature change so nothing breaks. detect_changes (worktree) → changed symbols: generatePlanInTwoPhases, generatePlanSinglePhase (both prompt-string edits) plus the test const noopDeps; affected processes GeneratePlan → NormalizePlan and GeneratePlan → GeneratePlanInTwoPhases at step 5 only. detect_changes reports a heuristic medium because the two planner functions sit on execution flows, but the edits are additive prompt text with no behavioral/contract change, so the effective risk is LOW.
  • Verification: pnpm --filter @frontagent/core test -- plan-generation (23 passed, incl. 4 new), pnpm typecheck (25 ok), pnpm biome check on the 3 touched files (clean), pnpm quality:precommit (green).

Verification

  • pnpm --filter @frontagent/core test -- plan-generation → 23 passed (4 new: constant semantics + both planner system prompts inject the protocol, asserted via captured generateObject system args).
  • pnpm typecheck → 25 tasks successful.
  • pnpm biome check packages/core/src/llm/{prompts,plan-generation,plan-generation.test}.ts → clean.
  • pnpm quality:precommit → green (ran via pre-commit hook).
  • pnpm quality:local → green (ran via pre-push hook).

Checklist

  • I have linked an issue or explained why this PR stands alone.
  • I have kept the diff focused on the stated change.
  • I have run pnpm quality:precommit, or explained why it could not run.
  • I have run pnpm quality:local for critical skeleton changes, or explained why it could not run.
  • I have updated docs or tests when behavior, public APIs, or Harness contracts changed.
  • For critical skeleton changes, I have filled the GitNexus impact summary with concrete results.

🤖 Generated with Claude Code

Add EXTERNAL_KNOWLEDGE_PROTOCOL, a "verify before assume" protocol parallel
in style to PROGRESSIVE_EXPLORATION_PROTOCOL, telling the planner WHEN to use
web_fetch: for unfamiliar / version-specific / recently-introduced
libraries, frameworks, and APIs, consult authoritative sources (official
docs / API reference) before planning or writing code, instead of guessing
API shape or default behavior. Includes a reverse guard so stable, well-known
knowledge is not needlessly fetched.

Wire the protocol into both planner system prompts (generatePlanInTwoPhases
outline system and generatePlanSinglePhase system), immediately after the
existing PROGRESSIVE_EXPLORATION_PROTOCOL interpolation.

Prompt-only change: no executor, schema, tool routing, or web_fetch runtime
behavior is touched. Adds focused unit tests asserting the constant's
semantics and that both planner system prompts inject the protocol.

Closes #360

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ ceilf6/repo-guard

代码评审报告: feat(prompts): inject external-knowledge discipline into planner prompts (Closes #360)

风险等级:
处理建议: 需要人工判断
决策摘要: ** 没有发现明确的代码缺陷,但这是影响共享 planner system prompt 的行为变更,静态测试只能证明文本已注入,不能直接证明模型会按新纪律选择 web_fetch,建议人工确认后再合并。

级联分析

  • 变更符号: 原始模型未提供结构化级联字段。
  • 受影响流程: 原始模型未提供结构化级联字段。
  • 变更集外调用方: unknown
  • 置信度: degraded

问题发现

模型未返回可结构化的问题发现;已提取可用的决策字段,原始非契约内容未附在评论中。

行级发现

  • 无明确变更行归属。

Karpathy 评审

  • 假设: 模型输出需要归一化为固定 Markdown 契约。
  • 简洁性: 已提取 summary、finding、evidence 与 fix;原始 prose 不再附在评论中,避免占用下游解析与代理上下文。
  • 变更范围: 原始模型未提供结构化范围字段。
  • 验证: 需要查看 CI、测试或人工 CR 证据补强合并信心。

缺失覆盖

  • 输出未命中 Repo Guard Markdown 契约;建议补充真实模型质量评估覆盖。

@github-actions

Copy link
Copy Markdown

🛡️ ceilf6/repo-guard

代码评审报告: feat(prompts): inject external-knowledge discipline into planner prompts (Closes #360)

风险等级:
处理建议: 批准
决策摘要: ** 可合并;变更严格匹配 #360 的 prompt-only 验收标准,未发现调用方契约、工具路由或结构质量风险,剩余风险主要是提示词实际行为效果需靠后续端到端观察验证。

级联分析

  • 变更符号: 原始模型未提供结构化级联字段。
  • 受影响流程: 原始模型未提供结构化级联字段。
  • 变更集外调用方: unknown
  • 置信度: degraded

问题发现

  1. [低] 未发现 blocking findings

行级发现

  • 无明确变更行归属。

Karpathy 评审

  • 假设: 模型输出需要归一化为固定 Markdown 契约。
  • 简洁性: 已提取 summary、finding、evidence 与 fix;原始 prose 不再附在评论中,避免占用下游解析与代理上下文。
  • 变更范围: 原始模型未提供结构化范围字段。
  • 验证: 需要查看 CI、测试或人工 CR 证据补强合并信心。

缺失覆盖

  • 输出未命中 Repo Guard Markdown 契约;建议补充真实模型质量评估覆盖。

@ceilf6 ceilf6 merged commit b4b113f into develop Jun 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(prompts): 为 planner 注入"先核实再假设"的外部知识纪律(从 CLAUDE-FABLE-5 学习 web_fetch when-to-use)

1 participant