Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

feat(skills): raise skill import and prompt index limits to 100

AdityaUmale5c56058b702e
diff --git a/apps/docs/content/docs/features/skills.mdx b/apps/docs/content/docs/features/skills.mdx
index caa6e8336e..35c9843b56 100644
--- a/apps/docs/content/docs/features/skills.mdx
+++ b/apps/docs/content/docs/features/skills.mdx
@@ -19,7 +19,7 @@ Skills are reference material, and the bot is told to treat them that way: it is
- **A bot's skills** live in its profile, under **Skills**. Each row can be switched on or off, opened to read the full text, or deleted. Switching one off keeps its files; deleting removes them for good. A skill imported into a bot's profile arrives switched off, so you can read it first.
- **The skills library** is in **App settings → Skills**, on an installation where the skills library is switched on with `"features": { "skillsLibrary": true }` in `~/.openmausbot/config.json` — there is no switch for it in the settings themselves. Import a skill by pasting its `SKILL.md` exactly as it is on disk: nothing is fetched from the network during the import, and a pasted import keeps only the text of `SKILL.md`, so a skill that reads files from its `references/` folder needs to be brought in from its folder on this computer instead, which keeps the files beside it. Then switch the skill on and assign it to one bot, several, or every current and future bot. A library skill starts out switched off: open it to read the text, then switch it on. Only a library skill that is switched on reaches the bots it is assigned to, and changing its text does not send it back to review — a skill that is switched on keeps reaching its bots with the new text, and one that is switched off stays off.
-The index a bot sees each turn lists at most 30 skills and at most 4,000 bytes, so a long list is trimmed, and the bot gets a note saying how many were left out and why — the skill cap or the byte cap. The names of the skills left out go to the server log rather than into the note. The skills are still there — it is only the index that is trimmed.
+The index a bot sees each turn lists at most 100 skills and at most 32,000 bytes, so a long list is trimmed, and the bot gets a note saying how many were left out and why — the skill cap or the byte cap. The names of the skills left out go to the server log rather than into the note. The skills are still there — it is only the index that is trimmed.
## Writing one
diff --git a/server/skill-fetch.test.ts b/server/skill-fetch.test.ts
index ee47d89e01..083f8df0ce 100644
--- a/server/skill-fetch.test.ts
+++ b/server/skill-fetch.test.ts
@@ -1,7 +1,7 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { githubToken, provideGithubSignIn } from "./github/token.ts";
-import { fetchSkillFromSource, githubSkillLink, latestSkillCommit, parseSkillSource, skillImportToken } from "./skill-fetch.ts";
+import { fetchSkillFromSource, githubSkillLink, latestSkillCommit, MAX_SKILLS_PER_IMPORT, parseSkillSource, skillImportToken } from "./skill-fetch.ts";
import { SKILL_FOLDER_LIMITS } from "./skill-folder.ts";
import { fakeGitHub, type FakeRepoEntry } from "./testing/fake-github.ts";
@@ -350,9 +350,9 @@ describe("importing a skill's whole folder", () => {
});
describe("skill import budget", () => {
- it("imports a complete 30-skill collection without unbounded parallel downloads", async () => {
+ it("imports a complete 100-skill collection without unbounded parallel downloads", async () => {
const entries: Record<string, FakeRepoEntry> = {};
- for (let i = 0; i < 30; i++) Object.assign(entries, { [`skills/skill-${i}/SKILL.md`]: SKILL(`skill-${i}`), [`skills/skill-${i}/help.md`]: "# Help" });
+ for (let i = 0; i < 100; i++) Object.assign(entries, { [`skills/skill-${i}/SKILL.md`]: SKILL(`skill-${i}`), [`skills/skill-${i}/help.md`]: "# Help" });
const github = fakeGitHub({ "a/b": entries });
let active = 0;
let peak = 0;
@@ -364,11 +364,19 @@ describe("skill import budget", () => {
return github.fetch(input, init);
}) as typeof fetch;
const skills = ok(await fetchSkillFromSource("a/b", fetcher));
- expect(skills).toHaveLength(30);
+ expect(skills).toHaveLength(100);
expect(skills.every((skill) => skill.files.length === 2)).toBe(true);
expect(peak).toBeLessThanOrEqual(4);
});
+ it("stops a larger collection at the per-import cap", async () => {
+ const entries: Record<string, FakeRepoEntry> = {};
+ for (let i = 0; i < MAX_SKILLS_PER_IMPORT + 5; i++) entries[`skills/skill-${i}/SKILL.md`] = SKILL(`skill-${i}`);
+ const skills = ok(await fetchSkillFromSource("a/b", fakeGitHub({ "a/b": entries }).fetch));
+ expect(MAX_SKILLS_PER_IMPORT).toBe(100);
+ expect(skills).toHaveLength(MAX_SKILLS_PER_IMPORT);
+ });
+
it("caps the entire directory walk rather than multiplying per-directory caps", async () => {
const fetcher = vi.fn(async (input: string | URL | Request) => {
if (String(input).includes("/commits/")) return new Response("c".repeat(40));
@@ -377,7 +385,7 @@ describe("skill import budget", () => {
}) as typeof fetch;
const result = await fetchSkillFromSource("a/b", fetcher);
expect(result).toEqual({ error: expect.stringContaining("request limit") });
- expect(fetcher).toHaveBeenCalledTimes(128);
+ expect(fetcher).toHaveBeenCalledTimes(256);
});
it("stops reading an oversized file before buffering the whole download", async () => {
diff --git a/server/skill-fetch.ts b/server/skill-fetch.ts
index 6c4a20eee3..930082fb8d 100644
--- a/server/skill-fetch.ts
+++ b/server/skill-fetch.ts
@@ -11,7 +11,7 @@ const RAW_HOST = "raw.githubusercontent.com";
const USER_AGENT = "OpenMausBot-skills";
const LISTING_MAX_BYTES = 1_048_576;
// GitHub allows 60 API requests an hour without sign-in; downloads from the raw host are not counted against it.
-const IMPORT_LIMITS = { apiRequests: 128, downloads: 1_000, bytes: 64 * 1_048_576, ms: 120_000 };
+const IMPORT_LIMITS = { apiRequests: 256, downloads: 1_000, bytes: 64 * 1_048_576, ms: 120_000 };
const PARALLEL_DOWNLOADS = 4;
class ImportLimitError extends Error {}
class GitHubApiError extends Error {}
@@ -302,9 +302,9 @@ async function fetchBytes(url: string, fetcher: typeof fetch): Promise<Buffer> {
return Buffer.from(await response.arrayBuffer());
}
-export const MAX_SKILLS_PER_IMPORT = 30;
+export const MAX_SKILLS_PER_IMPORT = 100;
const MAX_FOLDERS_WALKED = 24;
-const MAX_CHILDREN_PER_FOLDER = 60;
+const MAX_CHILDREN_PER_FOLDER = 100;
const passThrough = (error: unknown) => error instanceof ImportLimitError || (error instanceof Error && error.name === "TimeoutError");
diff --git a/server/skills.test.ts b/server/skills.test.ts
index 3d079f034f..3985d2a9b0 100644
--- a/server/skills.test.ts
+++ b/server/skills.test.ts
@@ -23,6 +23,7 @@ import {
applySkillWriteWithReceipt,
installSkill,
INDEX_MAX_BYTES,
+ INDEX_MAX_SKILLS,
listSkills,
listStagedSkillWrites,
parseSkillMd,
@@ -103,7 +104,8 @@ describe("skills prompt index budget", () => {
});
it("reports byte omissions in the prompt and logs omitted names once per skill set", () => {
- manifestSkills({ alpha: "a".repeat(2500), bravo: "b".repeat(2500), charlie: "c".repeat(2500) });
+ const long = Math.ceil(INDEX_MAX_BYTES * 0.6);
+ manifestSkills({ alpha: "a".repeat(long), bravo: "b".repeat(long), charlie: "c".repeat(long) });
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
try {
const prompt = skillsSystemPrompt(bot);
@@ -116,29 +118,43 @@ describe("skills prompt index budget", () => {
expect(warn).toHaveBeenCalledWith(expect.stringContaining("bravo, charlie"));
skillsSystemPrompt(bot);
expect(warn).toHaveBeenCalledTimes(1);
- manifestSkills({ aardvark: "a".repeat(2500), bravo: "b".repeat(2500), charlie: "c".repeat(2500) });
+ manifestSkills({ aardvark: "a".repeat(long), bravo: "b".repeat(long), charlie: "c".repeat(long) });
skillsSystemPrompt(bot);
expect(warn).toHaveBeenCalledTimes(1);
- manifestSkills({ alpha: "a".repeat(2500), bravo: "b".repeat(2500), charlie: "c".repeat(2500), delta: "d" });
+ manifestSkills({ alpha: "a".repeat(long), bravo: "b".repeat(long), charlie: "c".repeat(long), delta: "d" });
expect(skillsSystemPrompt(bot)).toContain("3 enabled skills omitted");
expect(warn).toHaveBeenCalledTimes(2);
} finally { warn.mockRestore(); }
});
it("reports the applicable entry or byte limit and excludes disabled skills", () => {
- const descriptions = Object.fromEntries(Array.from({ length: 32 }, (_, i) => [`skill-${String(i).padStart(2, "0")}`, "x"]));
- manifestSkills(descriptions, ["skill-31"]);
+ const last = `skill-${INDEX_MAX_SKILLS + 1}`;
+ const descriptions = Object.fromEntries(Array.from({ length: INDEX_MAX_SKILLS + 2 }, (_, i) => [`skill-${String(i).padStart(3, "0")}`, "x"]));
+ manifestSkills(descriptions, [last]);
const prompt = skillsSystemPrompt(bot);
- const indexed = prompt.match(/^- skill-\d{2}:/gm) ?? [];
- const omitted = 31 - indexed.length;
+ const indexed = prompt.match(/^- skill-\d{3}:/gm) ?? [];
+ const omitted = INDEX_MAX_SKILLS + 1 - indexed.length;
expect(Buffer.byteLength(prompt, "utf8")).toBeLessThanOrEqual(INDEX_MAX_BYTES);
expect(prompt).toContain(`${omitted} enabled skill${omitted === 1 ? "" : "s"} omitted`);
- expect(prompt).toContain(indexed.length === 30 ? "30-skill cap" : "4000-byte cap");
- expect(prompt).not.toContain("skill-31");
+ expect(prompt).toContain(indexed.length === INDEX_MAX_SKILLS ? `${INDEX_MAX_SKILLS}-skill cap` : `${INDEX_MAX_BYTES}-byte cap`);
+ expect(prompt).not.toContain(last);
+ });
+
+ it("lists up to 100 short skills and names the skill cap past that", () => {
+ expect(INDEX_MAX_SKILLS).toBe(100);
+ const names = (count: number) => Object.fromEntries(Array.from({ length: count }, (_, i) => [`s${String(i).padStart(3, "0")}`, "x"]));
+ manifestSkills(names(100));
+ const all = skillsSystemPrompt(bot);
+ expect(all.match(/^- s\d{3}:/gm)).toHaveLength(100);
+ expect(all).not.toContain("omitted");
+ manifestSkills(names(101));
+ const capped = skillsSystemPrompt(bot);
+ expect(capped.match(/^- s\d{3}:/gm)).toHaveLength(100);
+ expect(capped).toContain("1 enabled skill omitted from this prompt index (100-skill cap)");
});
it("explains when even the first entry cannot fit", () => {
- manifestSkills({ alpha: "🐈".repeat(1200) });
+ manifestSkills({ alpha: "🐈".repeat(Math.ceil(INDEX_MAX_BYTES / 4)) });
const prompt = skillsSystemPrompt(bot);
expect(Buffer.byteLength(prompt, "utf8")).toBeLessThanOrEqual(INDEX_MAX_BYTES);
expect(prompt).toContain("1 enabled skill omitted");
diff --git a/server/skills.ts b/server/skills.ts
index f9eae584ae..ce54cb9ef8 100644
--- a/server/skills.ts
+++ b/server/skills.ts
@@ -39,8 +39,8 @@ import { isSkillName, parseSkillMd, scanSkillText, SKILL_FILE_MAX_BYTES, type Pa
export { DESCRIPTION_MAX, isSkillName, parseSkillMd, scanSkillText, SKILL_FILE_MAX_BYTES, SKILL_NAME_MAX, type ParsedSkill } from "../shared/skill-md.ts";
export { STAGED_SKILL_FILE_MAX_BYTES } from "./skill-storage.ts";
-export const INDEX_MAX_SKILLS = 30;
-export const INDEX_MAX_BYTES = 4_000;
+export const INDEX_MAX_SKILLS = 100;
+export const INDEX_MAX_BYTES = 32_000;
const loggedIndexOmissions = new Map<string, string>();
export const MAX_STAGED_SKILLS = 20;
export const STAGED_GIST_MAX = 240;