Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(agent): enforce capability-gap skill recovery guidance

Jiayuan Zhang7eb18f47fcb1
diff --git a/packages/core/src/agent/system-prompt/sections.test.ts b/packages/core/src/agent/system-prompt/sections.test.ts
index a1d2dd5a5e..f31585fa67 100644
--- a/packages/core/src/agent/system-prompt/sections.test.ts
+++ b/packages/core/src/agent/system-prompt/sections.test.ts
@@ -218,6 +218,15 @@ describe("buildSkillsSection", () => {
expect(text).toContain("suggest activating it");
});
+ it("includes capability-gap recovery guidance", () => {
+ const result = buildSkillsSection("## commit\nDo commits.", "full");
+ const text = result.join("\n");
+ expect(text).toContain("capability gap");
+ expect(text).toContain("meta-skill-installer");
+ expect(text).toContain("explicit user confirmation");
+ expect(text).toContain("clawhub install");
+ });
+
it("returns empty in minimal mode", () => {
expect(buildSkillsSection("skills", "minimal")).toEqual([]);
});
diff --git a/packages/core/src/agent/system-prompt/sections.ts b/packages/core/src/agent/system-prompt/sections.ts
index bf935fcee9..52d7057a15 100644
--- a/packages/core/src/agent/system-prompt/sections.ts
+++ b/packages/core/src/agent/system-prompt/sections.ts
@@ -399,7 +399,10 @@ export function buildSkillsSection(
"- If exactly one skill clearly applies: follow its instructions.",
"- If multiple could apply: choose the most specific one.",
"- If none clearly apply but an **inactive skill** matches the user's intent: suggest activating it.",
- "- If no skill matches at all: skip skill invocation.",
+ "- If the request needs a capability you currently lack: do not stop at refusal. Treat it as a capability gap and propose a recovery path.",
+ "- If `meta-skill-installer` is available and no installed skill matches: proactively offer to search ClawHub for candidates and run security review before install.",
+ "- Ask for explicit user confirmation before final `clawhub install` / `clawhub update` unless the user already clearly asked you to install in this turn.",
+ "- After install/update, verify the skill path and retry the original user task.",
"",
budgeted,
"",