fix: include available_skills in isolated cron agentTurn sessions (closes #24888)

buildSkillsSection() had an early-return guard on isMinimal that silently
dropped the entire <available_skills> block for any session using
promptMode="minimal" — which includes all isolated cron agentTurn sessions
(isCronSessionKey → promptMode="minimal" in attempt.ts:497-500).

Fix: remove the isMinimal guard from buildSkillsSection so that skills are
emitted whenever a non-empty skillsPrompt is provided, regardless of mode.
Memory, docs, reply-tags, and other verbose sections remain gated on isMinimal.

Tests added:
- "includes skills in minimal prompt mode when skillsPrompt is provided (cron regression)"
- "omits skills in minimal prompt mode when skillsPrompt is absent"
- Updated existing minimal-mode test expectation to match corrected behaviour.
This commit is contained in:
User
2026-02-24 09:59:44 +08:00
parent 223d7dc23d
commit 66af86e7ee
2 changed files with 25 additions and 4 deletions

View File

@@ -108,7 +108,8 @@ describe("buildAgentSystemPrompt", () => {
});
expect(prompt).not.toContain("## Authorized Senders");
expect(prompt).not.toContain("## Skills");
// Skills are included even in minimal mode when skillsPrompt is provided (cron sessions need them)
expect(prompt).toContain("## Skills");
expect(prompt).not.toContain("## Memory Recall");
expect(prompt).not.toContain("## Documentation");
expect(prompt).not.toContain("## Reply Tags");
@@ -131,6 +132,29 @@ describe("buildAgentSystemPrompt", () => {
expect(prompt).toContain("Subagent details");
});
it("includes skills in minimal prompt mode when skillsPrompt is provided (cron regression)", () => {
// Isolated cron sessions use promptMode="minimal" but must still receive skills.
const skillsPrompt =
"<available_skills>\n <skill>\n <name>demo</name>\n </skill>\n</available_skills>";
const prompt = buildAgentSystemPrompt({
workspaceDir: "/tmp/openclaw",
promptMode: "minimal",
skillsPrompt,
});
expect(prompt).toContain("## Skills (mandatory)");
expect(prompt).toContain("<available_skills>");
});
it("omits skills in minimal prompt mode when skillsPrompt is absent", () => {
const prompt = buildAgentSystemPrompt({
workspaceDir: "/tmp/openclaw",
promptMode: "minimal",
});
expect(prompt).not.toContain("## Skills");
});
it("includes safety guardrails in full prompts", () => {
const prompt = buildAgentSystemPrompt({
workspaceDir: "/tmp/openclaw",

View File

@@ -22,9 +22,6 @@ function buildSkillsSection(params: {
isMinimal: boolean;
readToolName: string;
}) {
if (params.isMinimal) {
return [];
}
const trimmed = params.skillsPrompt?.trim();
if (!trimmed) {
return [];