



























@@ -507,7 +507,9 @@ describe("buildAgentSystemPrompt", () => {
507507expect(prompt).toContain("If a skill's <version> differs from a previous turn");
508508expect(prompt).toContain("If several apply, choose the most specific.");
509509expect(prompt).toContain("Docs: /tmp/openclaw/docs");
510-expect(prompt).toContain("OpenClaw behavior/config/architecture: read local docs first.");
510+expect(prompt).toContain(
511+"Docs are authoritative for OpenClaw self-knowledge: before understanding how OpenClaw works (memory/daily notes, sessions, tools, Gateway, config, commands, project context), use `Read` or search local docs first; treat AGENTS.md/project context, workspace/profile/memory notes, and `memory_search` as instruction context or user memory, not OpenClaw design/implementation knowledge.",
512+);
511513});
512514513515it("includes docs guidance when docsPath is provided", () => {
@@ -520,8 +522,30 @@ describe("buildAgentSystemPrompt", () => {
520522expect(prompt).toContain("## Documentation");
521523expect(prompt).toContain("Docs: /tmp/openclaw/docs");
522524expect(prompt).toContain("Source: /tmp/openclaw");
523-expect(prompt).toContain("OpenClaw behavior/config/architecture: read local docs first.");
524-expect(prompt).toContain("If docs are stale/incomplete, inspect local source.");
525+expect(prompt).toContain(
526+"Docs are authoritative for OpenClaw self-knowledge: before understanding how OpenClaw works (memory/daily notes, sessions, tools, Gateway, config, commands, project context), use `read` or search local docs first; treat AGENTS.md/project context, workspace/profile/memory notes, and `memory_search` as instruction context or user memory, not OpenClaw design/implementation knowledge.",
527+);
528+expect(prompt).toContain("If docs are silent/stale, say so and inspect local source.");
529+});
530+531+it("keeps self-knowledge docs guidance concise and authoritative", () => {
532+const prompt = buildAgentSystemPrompt({
533+workspaceDir: "/tmp/openclaw",
534+docsPath: "/tmp/openclaw/docs",
535+sourcePath: "/tmp/openclaw",
536+toolNames: ["read", "memory_search"],
537+});
538+const docsStart = prompt.indexOf("## Documentation");
539+const nextSection = prompt.indexOf("\n## ", docsStart + 1);
540+const docsSection = prompt.slice(docsStart, nextSection);
541+542+expect(prompt).toContain(
543+"Docs are authoritative for OpenClaw self-knowledge: before understanding how OpenClaw works (memory/daily notes, sessions, tools, Gateway, config, commands, project context), use `read` or search local docs first; treat AGENTS.md/project context, workspace/profile/memory notes, and `memory_search` as instruction context or user memory, not OpenClaw design/implementation knowledge.",
544+);
545+expect(docsSection.length).toBeLessThan(840);
546+expect(prompt).not.toContain("Self-knowledge rule: for questions about");
547+expect(prompt).not.toContain("Treat questions about daily notes");
548+expect(prompt).not.toContain("never answer from AGENTS.md/project context");
525549});
526550527551it("falls back to public docs and GitHub source guidance when local docs are unavailable", () => {
@@ -531,7 +555,10 @@ describe("buildAgentSystemPrompt", () => {
531555532556expect(prompt).toContain("Docs: https://docs.openclaw.ai");
533557expect(prompt).toContain("Source: https://github.com/openclaw/openclaw");
534-expect(prompt).toContain("If docs are stale/incomplete, inspect GitHub source.");
558+expect(prompt).toContain(
559+"Docs are authoritative for OpenClaw self-knowledge: before understanding how OpenClaw works (memory/daily notes, sessions, tools, Gateway, config, commands, project context), use the docs mirror first when web tooling is available; treat AGENTS.md/project context, workspace/profile/memory notes, and `memory_search` as instruction context or user memory, not OpenClaw design/implementation knowledge.",
560+);
561+expect(prompt).toContain("If docs are silent/stale, say so and inspect GitHub source.");
535562});
536563537564it("includes workspace notes when provided", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。