Skip to content

Commit 378e45a

Browse files
Alix-007steipete
andauthored
fix(skills): show byte-aware errors for long descriptions (#128594)
* fix(skills): surface description byte limit errors * fix(skills): preserve byte-aware collection validation Co-authored-by: Alix-007 <[email protected]> * test(skills): isolate description limit regression coverage Co-authored-by: Alix-007 <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent a63cfce commit 378e45a

3 files changed

Lines changed: 82 additions & 2 deletions

File tree

‎src/agents/tools/skill-workshop-tool-collection.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const skillCollectionPlanSchema = Type.Optional(
7171
{
7272
action: stringEnum(["write", "drop"] as const),
7373
name: Type.String(),
74-
description: Type.Optional(Type.String({ maxLength: 160 })),
74+
description: Type.Optional(Type.String()),
7575
content: Type.Optional(Type.String()),
7676
reason: Type.Optional(Type.String()),
7777
},

‎src/agents/tools/skill-workshop-tool-schema.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export function buildSkillWorkshopToolSchema(collectionOnly: boolean, proposalRe
9494
),
9595
description: Type.Optional(
9696
Type.String({
97-
maxLength: 160,
9897
description:
9998
"Skill description for create/update/revise; max 160 bytes. On update, concise text shortens the proposal listing entry.",
10099
}),
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import fs from "node:fs/promises";
2+
import path from "node:path";
3+
import { validateToolArguments } from "openclaw/plugin-sdk/llm";
4+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
5+
import {
6+
createOpenClawTestState,
7+
type OpenClawTestState,
8+
} from "../../test-utils/openclaw-test-state.js";
9+
import { createTrackedTempDirs } from "../../test-utils/tracked-temp-dirs.js";
10+
import { createSkillWorkshopTool } from "./skill-workshop-tool.js";
11+
12+
const tempDirs = createTrackedTempDirs();
13+
let testState: OpenClawTestState;
14+
15+
beforeEach(async () => {
16+
testState = await createOpenClawTestState({
17+
layout: "state-only",
18+
prefix: "openclaw-skill-workshop-description-state-",
19+
});
20+
});
21+
22+
afterEach(async () => {
23+
await testState.cleanup();
24+
await tempDirs.cleanup();
25+
});
26+
27+
describe("skill_workshop description validation", () => {
28+
it("lets the proposal service explain overlong descriptions", async () => {
29+
const workspaceDir = await tempDirs.make("openclaw-skill-workshop-description-limit-");
30+
const tool = createSkillWorkshopTool({ workspaceDir, env: testState.env });
31+
const args = {
32+
action: "create" as const,
33+
name: "Long Description",
34+
description: "x".repeat(161),
35+
proposal_content: "# Long Description\n",
36+
};
37+
const call = {
38+
type: "toolCall" as const,
39+
id: "call-long-description",
40+
name: "skill_workshop",
41+
arguments: args,
42+
};
43+
expect(validateToolArguments(tool, call)).toEqual(args);
44+
45+
await expect(tool.execute(call.id, args)).rejects.toThrow(
46+
"Skill proposal description is too large (161 bytes, max 160).",
47+
);
48+
});
49+
50+
it("lets the proposal service explain overlong collection descriptions", async () => {
51+
const workspaceDir = await tempDirs.make("openclaw-skill-collection-description-limit-");
52+
const collectionReconcile = {};
53+
const tool = createSkillWorkshopTool({ workspaceDir, env: testState.env, collectionReconcile });
54+
const args = {
55+
action: "reconcile" as const,
56+
collection: [
57+
{
58+
action: "write" as const,
59+
name: "long-description",
60+
description: "x".repeat(161),
61+
content: "# Long Description\n",
62+
},
63+
],
64+
};
65+
const call = {
66+
type: "toolCall" as const,
67+
id: "call-long-collection-description",
68+
name: "skill_workshop",
69+
arguments: args,
70+
};
71+
expect(validateToolArguments(tool, call)).toEqual(args);
72+
73+
await expect(tool.execute(call.id, args)).rejects.toThrow(
74+
"Skill proposal description is too large (161 bytes, max 160).",
75+
);
76+
await expect(
77+
fs.access(path.join(workspaceDir, "skills", "long-description", "SKILL.md")),
78+
).rejects.toThrow();
79+
expect(collectionReconcile).not.toHaveProperty("result");
80+
});
81+
});

0 commit comments

Comments
 (0)