feat(prompts): inject external-knowledge discipline into planner prompts (Closes #360)#361
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
代码评审报告: 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 契约;建议补充真实模型质量评估覆盖。
代码评审报告: feat(prompts): inject external-knowledge discipline into planner prompts (Closes #360)风险等级: 中 级联分析
问题发现
行级发现
Karpathy 评审
缺失覆盖
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_fetchcapability.Summary
The
web_fetchaction already exists and is mechanically described, but nothing tells the planner when to consult external docs. This adds that discipline:EXTERNAL_KNOWLEDGE_PROTOCOLinpackages/core/src/llm/prompts.ts, parallel in style/tone/format toPROGRESSIVE_EXPLORATION_PROTOCOL(Chinese protocol block, heading + numbered points). It tells the planner to consult authoritative sources (official docs / API reference) viaweb_fetchbefore 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.${EXTERNAL_KNOWLEDGE_PROTOCOL}into BOTH planner system prompts (generatePlanInTwoPhasesoutline system andgeneratePlanSinglePhasesystem) inpackages/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_fetchruntime behavior changed. No new action enums.web_searchintentionally out of scope.GitNexus Impact Summary
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 constnoopDeps; affected processesGeneratePlan → NormalizePlanandGeneratePlan → GeneratePlanInTwoPhasesat step 5 only. detect_changes reports a heuristicmediumbecause 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.pnpm --filter @frontagent/core test -- plan-generation(23 passed, incl. 4 new),pnpm typecheck(25 ok),pnpm biome checkon 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 capturedgenerateObjectsystemargs).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
pnpm quality:precommit, or explained why it could not run.pnpm quality:localfor critical skeleton changes, or explained why it could not run.🤖 Generated with Claude Code