From d79fd870774af975563a76a4d689231d3ef67955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 8 Oct 2026 04:42:06 -0400 Subject: [PATCH] Q18: every skill, the first included, must fit the skill budget Co-Authored-By: Claude Opus 5.5 --- src/main/services/skill-service.ts | 2 +- tests/unit/builtin-skills.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/services/skill-service.ts b/src/main/services/skill-service.ts index 1ec573e7..2b6bb4e4 100644 --- a/src/main/services/skill-service.ts +++ b/src/main/services/skill-service.ts @@ -284,7 +284,7 @@ export class SkillService { readFileSync(row.object_key, "utf8").trim(), ].join("\n\n"); const partTokens = estimateTokens(part); - if (compiledParts.length > 0 && compiledTokens + partTokens > input.maxTokens) { + if (compiledTokens + partTokens > input.maxTokens) { omitted.push(manifest.name); continue; } diff --git a/tests/unit/builtin-skills.test.ts b/tests/unit/builtin-skills.test.ts index 8b40a4f7..a03c9d8e 100644 --- a/tests/unit/builtin-skills.test.ts +++ b/tests/unit/builtin-skills.test.ts @@ -247,4 +247,23 @@ describe("built-in skills", () => { expect(parseFrontmatter(HUMANIZER_MD).description).toContain("sound more natural and human-written"); expect(parseFrontmatter("no frontmatter")).toEqual({}); }); + + test("no skill, not even the first forced one, may exceed the skill budget", () => { + const h = harness(); + const staged = stageBuiltinSkillsLibrary(h.sourceRoot, h.libraryRoot); + h.connection.transaction(() => importStagedSkills(h.skills, h.orgId, staged)); + let agentId = ""; + h.connection.transaction(() => { + agentId = h.organization.createAgent({ + orgId: h.orgId, name: "Ada", role: "Engineer", department: "Engineering", + modelProviderId: null, modelId: null, budgetCents: 1000, managerAgentId: null, + }); + }); + const snapshotId = h.connection.transaction(() => h.skills.resolveRuntimeSnapshot({ orgId: h.orgId, agentId, runId: "run_tiny", maxTokens: 10 })); + const prompt = (h.connection.db.prepare("select compiled_prompt from skill_runtime_snapshots where id = ?").get(snapshotId) as { compiled_prompt: string }).compiled_prompt; + expect(prompt).not.toContain("# Skill:"); + expect(prompt).toContain("# Skills omitted for size"); + expect(prompt).toContain("humanizer"); + h.connection.close(); + }); });