Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

List every skill under a size budget, name connector token variables, remove pinned skills (#2532)

Joshua France3761d0bde2ef
diff --git a/src/api/agent-api-catalog.ts b/src/api/agent-api-catalog.ts
index ecd758bff..213fefacd 100644
--- a/src/api/agent-api-catalog.ts
+++ b/src/api/agent-api-catalog.ts
@@ -415,17 +415,6 @@ const FAMILIES: AgentApiFamily[] = [
},
],
},
- {
- routes: [
- { method: "GET", path: "/v1/pinned-skills", summary: "list the skills pinned to this conversation's scope" },
- {
- method: "PUT",
- path: "/v1/pinned-skills",
- summary:
- "replace this scope's pinned skills — body {names: string[]} in display order (max 6; [] clears); they always lead the per-turn skills shortlist. Personal pins apply to that person's DMs, channel pins to that channel. Live person turns only",
- },
- ],
- },
{
when: (v) => !!v.claims.memory,
guidance: "Memory bodies and curation rules are documented in the memory skill.",
diff --git a/src/api/routes/surface.ts b/src/api/routes/surface.ts
index 57b385eeb..0e15d230e 100644
--- a/src/api/routes/surface.ts
+++ b/src/api/routes/surface.ts
@@ -20,7 +20,6 @@ import {
import { builtInModelCatalog, selectableCatalogForHarness, selectableModelCatalog } from "../../model/model-catalog.ts";
import { errMessage } from "../../util/errors.ts";
import { SoulUpdateDeniedError, type SessionPageStatus } from "../app-types.ts";
-import { parsePinnedSkills } from "../../skills/materialize.ts";
import { renderAgentApis } from "../agent-api-catalog.ts";
import { mintCapabilityToken, CAPABILITY_TTL_MS } from "../../auth/capability-token.ts";
import { contentTypeWithUtf8Charset, pipeToResponse, sendJson } from "../http.ts";
@@ -1388,34 +1387,6 @@ export async function postSoul(ctx: ApiCtx): Promise<void> {
}
}
-async function getPinnedSkills(ctx: ApiCtx): Promise<void> {
- if (!ctx.deps.config) return sendJson(ctx.res, 404, { error: "not_found" });
- const target = await runtimeTarget(ctx);
- if (!target) return sendJson(ctx.res, 403, { error: "forbidden" });
- return sendJson(ctx.res, 200, {
- scopeId: target.scope,
- names: await ctx.deps.config.getPinnedSkillsDurable(target.scope),
- });
-}
-
-async function putPinnedSkills(ctx: ApiCtx): Promise<void> {
- if (!ctx.deps.config || !isObj(ctx.body)) return sendJson(ctx.res, 400, { error: "bad_request" });
- if (ctx.capability && !livePersonCapability(ctx.capability))
- return sendJson(ctx.res, 403, { error: "live_actor_required" });
- const target = await runtimeTarget(ctx);
- if (!target) return sendJson(ctx.res, 403, { error: "forbidden" });
- const parsed = parsePinnedSkills(ctx.body.names);
- if ("error" in parsed) return sendJson(ctx.res, 400, { error: "bad_request", message: parsed.error });
- await ctx.deps.config.setPinnedSkills(target.scope, parsed.value);
- audit(ctx.deps, {
- principalId: target.actorId,
- action: "pinned-skills.update",
- resource: `pinned-skills: ${parsed.value.join(", ")}`,
- scopeLabel: target.scope,
- });
- return sendJson(ctx.res, 200, { scopeId: target.scope, names: parsed.value });
-}
-
export const surfaceRoutes: ReadonlyArray<Route<ApiCtx>> = [
...sessionSharingRoutes,
...suggestedActivityRoutes,
@@ -1441,8 +1412,6 @@ export const surfaceRoutes: ReadonlyArray<Route<ApiCtx>> = [
{ method: "PUT", path: "/v1/channel-header-pin", auth: "either", handle: putChannelHeaderPin },
{ method: "GET", path: "/v1/soul", auth: "either", handle: getSoul },
{ method: "POST", path: "/v1/soul", actor: "body.actorId", auth: "either", handle: postSoul },
- { method: "GET", path: "/v1/pinned-skills", auth: "either", handle: getPinnedSkills },
- { method: "PUT", path: "/v1/pinned-skills", auth: "either", handle: putPinnedSkills },
...withActor("body.principalId", [
{ method: "POST", path: "/v1/sessions/:id/title", auth: "source", handle: regenerateSessionTitle },
{ method: "POST", path: "/v1/sessions/:id/fork", auth: "source", handle: forkSession },
diff --git a/src/core/environment-facts.ts b/src/core/environment-facts.ts
index 4bbc0333f..32a825ba5 100644
--- a/src/core/environment-facts.ts
+++ b/src/core/environment-facts.ts
@@ -72,7 +72,9 @@ export function renderConnectedAppsBlock(
}
}
if (connected.length) {
- lines.push(`Connected: ${connected.join(", ")}. Use them directly; their auth is wired.`);
+ lines.push(
+ `Connected: ${connected.join(", ")}. Use their tools directly; for API calls, select the app's credential in execute.credentials and send its token yourself.`,
+ );
}
if (reconnect.length) {
lines.push(`Needs reconnect: ${reconnect.join(", ")}. Do not use these apps until the user reconnects them.`);
diff --git a/src/core/orchestrator.ts b/src/core/orchestrator.ts
index 91850053a..22d024649 100644
--- a/src/core/orchestrator.ts
+++ b/src/core/orchestrator.ts
@@ -57,7 +57,7 @@ import { supportsProcessSessions, supportsScopeProfile } from "../sandbox/sandbo
import { createBackgroundBroker } from "../connectors/background-exec-broker.ts";
import { createMonitorBroker, readBackgroundOutputTail } from "../monitors/monitor-broker.ts";
import { isPollSurface } from "../triggers/run-trigger.ts";
-import { envKey } from "../credentials/connector-token.ts";
+import { connectorTokenNote, envKey } from "../credentials/connector-token.ts";
import {
credentialHandle,
renderKeychainManifest,
@@ -154,7 +154,7 @@ import {
selectOverheardToImport,
type OverheardEntryPayload,
} from "../harness/replay.ts";
-import { errMessage, reportFailure, reportFailureAs, swallow, swallowAs } from "../util/errors.ts";
+import { errMessage, reportFailure, swallow, swallowAs } from "../util/errors.ts";
import { isObj } from "../util/objects.ts";
import { absoluteAppLinks, jsonbSafeStringify } from "../util/text.ts";
import {
@@ -1244,8 +1244,6 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {
if (!external && deps.deploymentLayer?.hints.length) {
systemPrompt += `\n\n## Deployment tool hints\n${deps.deploymentLayer.hints.map((hint) => `- ${hint}`).join("\n")}`;
}
- systemPrompt +=
- "\n\n## Skills\nThe per-turn shortlist is not exhaustive. Use skills action list to browse all or search with query to find omitted or new skills. Read a skill before relying on it.";
const gatewayBlock = renderGatewayContext(input.surface, input.gatewayContext);
if (gatewayBlock) turnContextBlocks["Where you are"] = gatewayBlock;
const homeChannel =
@@ -1536,9 +1534,11 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {
return { env: [{ key: envKey(host), value: token }] };
},
},
- !healthy && operatorFallback
- ? `${host}, configured operator fallback; availability checked on use`
- : `${host} connector, account ${accountType ?? "default"}`,
+ `${
+ !healthy && operatorFallback
+ ? `${host}, configured operator fallback; availability checked on use`
+ : `${host} connector, account ${accountType ?? "default"}`
+ }; ${connectorTokenNote(host)}`,
healthy && status && "credentialId" in status ? status.credentialId : undefined,
actor.id,
healthy && status && "credentialId" in status ? status.credentialId : undefined,
@@ -2952,16 +2952,7 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {
? [p.name]
: [];
});
- const pinnedSkills = deps.config
- ? await deps.config.getPinnedSkillsDurable(scopeId).catch(reportFailureAs("orchestrator: pinned skills", []))
- : [];
- turnContextBlocks["Skills"] = skillsIndex(
- nativeSkills,
- [scopeId, resolution.orgScopeId],
- input.text,
- usedSkills,
- pinnedSkills,
- );
+ turnContextBlocks["Skills"] = skillsIndex(nativeSkills, [scopeId, resolution.orgScopeId], usedSkills);
const turnEnvironmentContents = [
manifest,
principalDelivered,
diff --git a/src/credentials/connector-token.ts b/src/credentials/connector-token.ts
index 7b86c3dd0..bf0264c75 100644
--- a/src/credentials/connector-token.ts
+++ b/src/credentials/connector-token.ts
@@ -10,6 +10,10 @@ export function envKey(host: string, principalId?: string): string {
return `VAULT_TOKEN_${normalizedHost}__${normalizedPrincipal}_${tag}`;
}
+export function connectorTokenNote(host: string): string {
+ return `token in \`$${envKey(host)}\`; send it yourself as \`Authorization: Bearer\`; nothing adds it for you`;
+}
+
export function withOperatorTokenFallback(
store: ConnectorTokenStore,
serviceHosts: string[],
diff --git a/src/credentials/keychain.ts b/src/credentials/keychain.ts
index 884dc2bc3..eb8df9bf8 100644
--- a/src/credentials/keychain.ts
+++ b/src/credentials/keychain.ts
@@ -12,7 +12,7 @@ import { cronIdOf } from "../sessions/session-store.ts";
import { hashId } from "../util/crypto.ts";
import { shq } from "../util/shell.ts";
import { homeRelativePath } from "./paths.ts";
-import { envKey } from "./connector-token.ts";
+import { connectorTokenNote, envKey } from "./connector-token.ts";
const COMPOSIO_ENV_KEY = "COMPOSIO_API_KEY";
@@ -1712,7 +1712,7 @@ function connectorMeta(rec: KeychainCredentialMeta, t: number, oauthSkew = 60_00
function connectorDescription(cm: ConnectorMeta): string {
return `connected app ${cm.host}, account ${cm.accountType ?? "default"}${
cm.needsReconnect ? ", NEEDS RECONNECT — owner must reconnect the app before use" : ""
- }${typeof cm.expiresAt === "number" ? `, token expires at ${new Date(cm.expiresAt).toISOString()}` : ""}`;
+ }${typeof cm.expiresAt === "number" ? `, token expires at ${new Date(cm.expiresAt).toISOString()}` : ""}; ${connectorTokenNote(cm.host)}`;
}
export const MAX_CREDENTIAL_FILES = 500;
diff --git a/src/harness/agent-tools.ts b/src/harness/agent-tools.ts
index fd2a74956..70c2c6230 100644
--- a/src/harness/agent-tools.ts
+++ b/src/harness/agent-tools.ts
@@ -1052,9 +1052,9 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):
name: "skill",
label: "skill",
description:
- "Load a skill by name before relying on it; use list or search to discover names outside the shortlist. Returns its SKILL.md instructions (or the relative file named by `path`) straight from the published source, without starting a sandbox. When the skill ships scripts or supporting files, this call also syncs them into a stable directory on the computer and reports it; run and read them there with execute and files action read. Reading the skill again refreshes that copy.",
+ "Load a skill by name before relying on it; use list or search for any left out of the per-turn index. Returns its SKILL.md instructions (or the relative file named by `path`) straight from the published source, without starting a sandbox. When the skill ships scripts or supporting files, this call also syncs them into a stable directory on the computer and reports it; run and read them there with execute and files action read. Reading the skill again refreshes that copy.",
parameters: Type.Object({
- name: Type.String({ description: "Skill name from the shortlist, list, or search." }),
+ name: Type.String({ description: "Skill name from the skills index, list, or search." }),
source: Type.Optional(
Type.String({ description: "Use the same source as the discovery call to read that exact skill." }),
),
@@ -2949,9 +2949,7 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):
"context it is shared by ALL of that person's sessions, not tied to the session that " +
"wrote it. Never store session pins or 'for this session' notes here: ALL pinning goes " +
"through the pins self-API (POST /v1/pins), which routes by context — the session's own " +
- "pins in the web UI, native pinning in Slack. To keep a skill in this scope's per-turn skills shortlist, " +
- 'pin it instead of writing guidance: PUT $AGENT_API_URL/v1/pinned-skills with header "x-agent-capability: $AGENT_API_TOKEN" ' +
- 'and body {"names": [...]}, the full list. `edit` swaps one exact passage `old` for `new` ' +
+ "pins in the web UI, native pinning in Slack. `edit` swaps one exact passage `old` for `new` " +
"and fails unless `old` appears exactly once in that scope's guidance; prefer it for small changes. " +
"`replace` REPLACES that scope's entire guidance with `content` — include everything that " +
"should remain. Org-wide policy is always layered above and " +
diff --git a/src/resolution/config-store.ts b/src/resolution/config-store.ts
index 866895df4..64596c76c 100644
--- a/src/resolution/config-store.ts
+++ b/src/resolution/config-store.ts
@@ -110,10 +110,6 @@ export interface PersistedAckEmoji {
scopeId: ScopeId;
names: string[];
}
-export interface PersistedPinnedSkills {
- scopeId: ScopeId;
- names: string[];
-}
export interface PersistedSlackEmojiCatalog {
scopeId: ScopeId;
emoji: Record<string, string>;
@@ -241,8 +237,6 @@ export interface ScopedConfigStore {
getAckEmoji(id: ScopeId): string[] | null;
setAckEmoji(id: ScopeId, names: string[] | null): Promise<void>;
getAckEmojiDurable(id: ScopeId): Promise<string[] | null>;
- getPinnedSkillsDurable(id: ScopeId): Promise<string[]>;
- setPinnedSkills(id: ScopeId, names: string[]): Promise<void>;
setSlackEmojiCatalog(id: ScopeId, emoji: Record<string, string>): Promise<void>;
getSlackEmojiCatalogDurable(id: ScopeId): Promise<PersistedSlackEmojiCatalog | null>;
getPeopleDirectoryUrl(id: ScopeId): string | null;
@@ -290,7 +284,6 @@ export function createMemoryConfigStore(
webuiModels?: DurableMap<PersistedWebuiModels>;
peopleDirectoryUrls?: DurableMap<PersistedPeopleDirectoryUrl>;
ackEmoji?: DurableMap<PersistedAckEmoji>;
- pinnedSkills?: DurableMap<PersistedPinnedSkills>;
slackEmojiCatalog?: DurableMap<PersistedSlackEmojiCatalog>;
branding?: DurableMap<PersistedBranding>;
browseMaxSteps?: DurableMap<PersistedBrowseMaxSteps>;
@@ -346,7 +339,6 @@ export function createMemoryConfigStore(
const webuiModelStore = opts.webuiModels ?? createMemoryMap<PersistedWebuiModels>();
const peopleDirectoryUrlStore = opts.peopleDirectoryUrls ?? createMemoryMap<PersistedPeopleDirectoryUrl>();
const ackEmojiStore = opts.ackEmoji ?? createMemoryMap<PersistedAckEmoji>();
- const pinnedSkillsStore = opts.pinnedSkills ?? createMemoryMap<PersistedPinnedSkills>();
const slackEmojiCatalogStore = opts.slackEmojiCatalog ?? createMemoryMap<PersistedSlackEmojiCatalog>();
const brandingStore = opts.branding ?? createMemoryMap<PersistedBranding>();
const browseMaxStepsStore = opts.browseMaxSteps ?? createMemoryMap<PersistedBrowseMaxSteps>();
@@ -964,11 +956,6 @@ export function createMemoryConfigStore(
);
},
getAckEmojiDurable: async (id) => (await ackEmojiStore.get(id))?.names ?? null,
- getPinnedSkillsDurable: async (id) => (await pinnedSkillsStore.get(id))?.names ?? [],
- setPinnedSkills: (id, names) =>
- writeQueue(`pinnedSkills:${id}`, () =>
- names.length ? pinnedSkillsStore.put(id, { scopeId: id, names }) : pinnedSkillsStore.delete(id),
- ),
async setSlackEmojiCatalog(id, emoji) {
await writeQueue(`slackEmojiCatalog:${id}`, () =>
slackEmojiCatalogStore.put(id, { scopeId: id, emoji, updatedAt: Date.now() }),
diff --git a/src/skills/materialize.ts b/src/skills/materialize.ts
index a5dca0501..1997579ed 100644
--- a/src/skills/materialize.ts
+++ b/src/skills/materialize.ts
@@ -2,7 +2,7 @@ import { CapabilityUnsupportedError, type Sandbox, type SandboxHandle } from "..
import { safeSkillFilePath, type SkillFile, type SkillResolution } from "./skill-store.ts";
import type { SkillBundle } from "./skill-bundle-store.ts";
import { swallow } from "../util/errors.ts";
-import { assertSafeSkillName, isSafeSkillName } from "./skill-name.ts";
+import { assertSafeSkillName } from "./skill-name.ts";
import type { ScopeId } from "../types.ts";
export const SKILLS_DIR = "skills";
@@ -134,40 +134,55 @@ export function rankedSkills(
.map(({ entry }) => entry);
}
-const SHORTLIST_SIZE = 12;
-const MAX_PINNED_SKILLS = SHORTLIST_SIZE / 2;
+const SKILLS_INDEX_BUDGET = 12_000;
+const MIN_DESCRIPTION = 60;
-export function parsePinnedSkills(raw: unknown): { value: string[] } | { error: string } {
- if (!Array.isArray(raw) || !raw.every((name) => typeof name === "string"))
- return { error: "pinned skills require { names: string[] } (an empty list clears them)" };
- const names = [...new Set(raw.map((name) => name.trim()).filter(Boolean))];
- const bad = names.find((name) => !isSafeSkillName(name));
- if (bad) return { error: `not a valid skill name: ${bad}` };
- if (names.length > MAX_PINNED_SKILLS) return { error: `at most ${MAX_PINNED_SKILLS} skills can be pinned` };
- return { value: names };
+function fitDescriptions(heads: string[], descriptions: string[], budget: number): number {
+ const size = (cap: number) =>
+ heads.reduce((sum, head, i) => sum + head.length + 1 + Math.min(descriptions[i]!.length, cap) + 4, 0);
+ let low = 0;
+ let high = Math.max(0, ...descriptions.map((d) => d.length));
+ while (low < high) {
+ const mid = Math.ceil((low + high) / 2);
+ if (size(mid) <= budget) low = mid;
+ else high = mid - 1;
+ }
+ return low;
}
export function skillsIndex(
resolved: SkillResolution[],
provenanceScopes: readonly ScopeId[] = [],
- query = "",
usedNames: readonly string[] = [],
- pinnedNames: readonly string[] = [],
+ budget = SKILLS_INDEX_BUDGET,
): string {
const provenance = new Set(provenanceScopes);
- const ranked = rankedSkills(resolved, query, usedNames);
- const byName = new Map(ranked.map((r) => [r.skill!.manifest.name, r]));
- const pinned = pinnedNames.flatMap((name) => byName.get(name) ?? []);
- const items = [...new Set([...pinned, ...ranked])].slice(0, SHORTLIST_SIZE);
+ const items = rankedSkills(resolved, "", usedNames);
if (!items.length) return "";
- const lines = items.map((r) => {
- const m = r.skill!.manifest;
+ const heads = items.map((r) => {
const source = provenance.has(r.skill!.scopeId) ? ` [from ${r.skill!.scopeId}]` : "";
- return `- **${m.name}**${source} — ${m.description}`;
+ return `- **${r.skill!.manifest.name}**${source}`;
});
+ const descriptions = items.map((r) => r.skill!.manifest.description.trim());
+ const cap = fitDescriptions(heads, descriptions, budget);
+ let lines: string[];
+ let note = "";
+ const shortened = descriptions.filter((d) => d.length > cap).length;
+ if (cap >= MIN_DESCRIPTION || !shortened) {
+ lines = heads.map((head, i) => {
+ const d = descriptions[i]!;
+ return `${head} — ${d.length > cap ? `${d.slice(0, cap).trimEnd()}…` : d}`;
+ });
+ if (shortened) note = ` ${shortened} descriptions are shortened; skills action read shows the full text.`;
+ } else {
+ let used = 0;
+ lines = heads.filter((head) => (used += head.length + 1) <= budget);
+ const omitted = items.length - lines.length;
+ note = ` Descriptions are omitted to fit the list${omitted ? `, and ${omitted} skills are left out; find them with skills action search` : ""}.`;
+ }
return [
"## Skills",
- `Showing ${items.length} of ${ranked.length} available skills. Use skills action list or search for the rest.`,
+ `If the task matches a skill's description, or uses a connected app or service a skill covers, read that skill in full with skills action read before acting.${note}`,
...lines,
].join("\n");
}
diff --git a/src/wiring.ts b/src/wiring.ts
index bace567a1..8726b121c 100644
--- a/src/wiring.ts
+++ b/src/wiring.ts
@@ -104,7 +104,6 @@ import {
type PersistedWebuiModels,
type PersistedPeopleDirectoryUrl,
type PersistedAckEmoji,
- type PersistedPinnedSkills,
type PersistedSlackEmojiCatalog,
type PersistedBranding,
type PersistedBrowseMaxSteps,
@@ -703,7 +702,6 @@ export function buildApp(
webuiModels: artifactMap<PersistedWebuiModels>("webui_model_configs"),
peopleDirectoryUrls: artifactMap<PersistedPeopleDirectoryUrl>("people_directory_urls"),
ackEmoji: artifactMap<PersistedAckEmoji>("ack_emoji"),
- pinnedSkills: artifactMap<PersistedPinnedSkills>("pinned_skills"),
slackEmojiCatalog: artifactMap<PersistedSlackEmojiCatalog>("slack_emoji_catalog"),
branding: artifactMap<PersistedBranding>("branding_configs"),
browseMaxSteps: artifactMap<PersistedBrowseMaxSteps>("browse_max_steps_configs"),
@@ -1961,6 +1959,10 @@ export function buildApp(
"DELETE FROM durable_map_versions WHERE tbl = 'turn_wall_clock_configs'",
],
});
+ pgArtifactMap?.pool.registerMigration({
+ id: "durable-map/pinned_skills/0002-drop",
+ statements: ["DROP TABLE IF EXISTS pinned_skills", "DELETE FROM durable_map_versions WHERE tbl = 'pinned_skills'"],
+ });
pgArtifactMap?.pool.registerMigration(LEGACY_HARNESS_MIGRATION);
pgArtifactMap?.pool.registerMigration({
id: "durable-map/suggested_activity_profiles/0001-nightly-on-use",
diff --git a/test/capability-routes.test.ts b/test/capability-routes.test.ts
index 9afb33050..99d3552e4 100644
--- a/test/capability-routes.test.ts
+++ b/test/capability-routes.test.ts
@@ -363,36 +363,6 @@ describe("capability-token control plane (crons + webhooks + SOUL)", () => {
);
});
- it("sets pinned skills on the live speaker's own scope only", async () => {
- const put = async (body: unknown, token: string) =>
- fetch(`${base}/v1/pinned-skills`, {
- method: "PUT",
- headers: { "content-type": "application/json", "x-agent-capability": token },
- body: JSON.stringify(body),
- });
- const live = { liveActor: true };
- const mine = await put(
- { names: ["voice", "drafts"], scopeId: "org:default-org" },
- await capFor("U3", undefined, live),
- );
- assert.equal(mine.status, 200);
- assert.deepEqual(await built.config.getPinnedSkillsDurable(scopeId("personal", "U3")), ["voice", "drafts"]);
- assert.deepEqual(await built.config.getPinnedSkillsDurable(scopeId("org", "default-org")), []);
- const read = await get("/v1/pinned-skills", { "x-agent-capability": await capFor("U3") });
- assert.deepEqual(((await read.json()) as { names: string[] }).names, ["voice", "drafts"]);
-
- assert.equal((await put({ names: ["voice"] }, await capChannel("U8", live))).status, 200);
- assert.deepEqual(await built.config.getPinnedSkillsDurable(scopeId("channel", "C")), ["voice"]);
-
- assert.equal((await put({ names: ["x"] }, await capFor("U3"))).status, 403, "background turns cannot change pins");
- assert.equal((await put({}, await capFor("U3", undefined, live))).status, 400, "a missing list does not clear");
- assert.equal((await put({ names: ["x"] }, await capFor("U3", scopeId("org", "default-org"), live))).status, 403);
- assert.deepEqual(await built.config.getPinnedSkillsDurable(scopeId("personal", "U3")), ["voice", "drafts"]);
-
- assert.equal((await put({ names: [] }, await capFor("U3", undefined, live))).status, 200);
- assert.deepEqual(await built.config.getPinnedSkillsDurable(scopeId("personal", "U3")), []);
- });
-
it("updates only the caller's OWN personal SOUL, ignoring body scope/actor", async () => {
const orgVerBefore = built.config.soulVersion(scopeId("org", "default-org"));
const res = await post(
diff --git a/test/keychain.test.ts b/test/keychain.test.ts
index 5ae112012..c666b0fb5 100644
--- a/test/keychain.test.ts
+++ b/test/keychain.test.ts
@@ -1650,6 +1650,7 @@ test("manifest merges credential representations without conflating login identi
assert.match(rendered, /`connector:gmail\.googleapis\.com:default`(?! \(execute scope)/);
assert.match(rendered, /NEEDS RECONNECT/);
assert.match(rendered, /token expires at/);
+ assert.ok(rendered.includes("token in `$VAULT_TOKEN_GMAIL_GOOGLEAPIS_COM`"));
assert.match(rendered, /account work, EXPIRED/);
assert.match(rendered, /account personal, expires at/);
assert.notEqual(credentialHandle(first), credentialHandle(second));
diff --git a/test/skills-callable.test.ts b/test/skills-callable.test.ts
index cf9029597..cae6fab6f 100644
--- a/test/skills-callable.test.ts
+++ b/test/skills-callable.test.ts
@@ -63,46 +63,6 @@ test("a published personal skill is advertised and loads in the owner's DM", asy
assert.match(read.reply ?? "", /Step 1: gather/);
});
-test("a skill pinned to the person's scope is listed in their DM shortlist even when the message doesn't mention it", async () => {
- const { app, skills, config } = freshApp();
- for (let i = 0; i < 13; i++) {
- const sk = await skills.create({
- scopeId: scopeId("personal", "U1"),
- manifest: {
- name: `aa-filler-${i}`,
- description: "filler",
- requiredCapabilities: [],
- body: "# filler",
- },
- createdBy: "U1",
- });
- await skills.review(sk.id, "reviewer-1", []);
- await skills.publish(sk.id);
- }
- const sk = await skills.create({
- scopeId: scopeId("personal", "U1"),
- manifest: { name: "zz-voice", description: "write in my voice", requiredCapabilities: [], body: "# voice" },
- createdBy: "U1",
- });
- await skills.review(sk.id, "reviewer-1", []);
- await skills.publish(sk.id);
- const shortlist = async (thread: string) =>
- (
- await app.turn({
- surface: "test",
- actor,
- conversation: { kind: "dm", threadRef: thread },
- text: "!sysprompt",
- } as TurnRequest)
- ).reply ?? "";
-
- assert.doesNotMatch(await shortlist("dm:U1:p1"), /zz-voice/);
- await config.setPinnedSkills(scopeId("personal", "U1"), ["zz-voice", "not-a-real-skill"]);
- const pinned = await shortlist("dm:U1:p2");
- assert.match(pinned, /Showing 12 of \d+ available skills\.[^\n]*\n- \*\*zz-voice\*\*/);
- assert.doesNotMatch(pinned, /not-a-real-skill/);
-});
-
test("a channel session does NOT see a personal skill (scope boundary)", async () => {
const { app, skills } = freshApp();
await publishPersonalSkill(skills);
@@ -176,7 +136,7 @@ test("skill files stay on the computer across turns", async () => {
assert.match((await app.turn({ ...request, text: "!skill helper" } as TurnRequest)).reply ?? "", /no skill file/);
});
-test("shortlist uses visible history, resets with compaction, and leaves the system prefix stable", async () => {
+test("skills index order uses visible history, resets with compaction, and leaves the system prefix stable", async () => {
const built = freshApp();
for (let i = 0; i < 20; i++) {
const skill = await built.skills.create({
@@ -198,8 +158,9 @@ test("shortlist uses visible history, resets with compaction, and leaves the sys
conversation: { kind: "dm" as const, threadRef: "shortlist-history" },
text: "!sysprompt",
};
+ const promoted = (prompt: string) => prompt.indexOf("**helper-19**") < prompt.indexOf("**helper-00**");
const first = await built.app.turn(request);
- assert.doesNotMatch(first.reply ?? "", /\*\*helper-19\*\*/);
+ assert.ok(!promoted(first.reply ?? ""));
const sessionId = first.sessionId!;
const { lease } = await built.sessions.acquireLease(sessionId, "turn");
assert.ok(lease);
@@ -210,9 +171,9 @@ test("shortlist uses visible history, resets with compaction, and leaves the sys
});
await built.sessions.releaseLease(lease);
const second = await built.app.turn(request);
- assert.match(second.reply ?? "", /\*\*helper-19\*\*/);
+ assert.ok(promoted(second.reply ?? ""));
const unchanged = await built.app.turn(request);
- assert.doesNotMatch(unchanged.reply ?? "", /Showing 12 of/);
+ assert.doesNotMatch(unchanged.reply ?? "", /\*\*helper-00\*\*/);
const entries = await built.sessions.getEntries(sessionId);
const reset = await built.sessions.acquireLease(sessionId, "compaction");
assert.ok(reset.lease);
@@ -223,7 +184,7 @@ test("shortlist uses visible history, resets with compaction, and leaves the sys
});
await built.sessions.releaseLease(reset.lease);
const third = await built.app.turn(request);
- assert.doesNotMatch(third.reply ?? "", /\*\*helper-19\*\*/);
+ assert.ok(!promoted(third.reply ?? ""));
const recorded = (await built.sessions.listLlmRequests(sessionId)).filter((r) => r.model === "mock");
const systems = recorded.map((r) => (r.promptEnvelope as { system: string }).system);
assert.equal(systems.length, 4);
diff --git a/test/skills-materialize.test.ts b/test/skills-materialize.test.ts
index 8f1fac46b..f71798614 100644
--- a/test/skills-materialize.test.ts
+++ b/test/skills-materialize.test.ts
@@ -6,7 +6,6 @@ import { CapabilityUnsupportedError, type Sandbox, type SandboxHandle } from "..
import type { SkillFile, SkillResolution } from "../src/skills/skill-store.ts";
import {
materializeSkillTree,
- parsePinnedSkills,
rankedSkills,
renderSkillBody,
safeSkillDirName,
@@ -158,7 +157,9 @@ test("a pack bundle may ship a root SKILL.md of its own", async () => {
assert.equal(files.get(`${root}/.packs/s1/SKILL.md`), "pack readme");
});
-test("skill shortlist favors relevant and visibly used skills without global usage signals", () => {
+const names = (index: string) => [...index.matchAll(/\*\*([^*]+)\*\*/g)].map((m) => m[1]);
+
+test("skills index lists every skill in a message-independent order, visibly used ones first", () => {
const skills = Array.from({ length: 20 }, (_, i) => res(`skill-${String(i).padStart(2, "0")}`, "body"));
for (const r of skills) r.skill!.manifest.description = "General task";
skills[19]!.skill!.manifest.description = "Prepare telescope observations";
@@ -166,11 +167,13 @@ test("skill shortlist favors relevant and visibly used skills without global usa
const duplicate = structuredClone(skills[0]!);
duplicate.skill!.manifest.description = "shadowed description";
const visible = [...skills, duplicate, { skill: null, shadowed: [] }];
- const index = skillsIndex(visible, [], "telescope", ["skill-17"]);
- assert.match(index, /Showing 12 of 20/);
- assert.ok(index.indexOf("**skill-19**") < index.indexOf("**skill-17**"));
- assert.doesNotMatch(index, /skill-18|shadowed description|lastUsedAt/);
- assert.match(index, /skills action list/);
+ const index = skillsIndex(visible, [], ["skill-17"]);
+ const shown = names(index);
+ assert.equal(shown.length, 20);
+ assert.deepEqual(shown.slice(0, 3), ["skill-17", "skill-00", "skill-01"]);
+ assert.doesNotMatch(index, /shadowed description|lastUsedAt|shortened|omitted/);
+ assert.match(index, /- \*\*skill-19\*\* — Prepare telescope observations/);
+ assert.match(index, /skills action read/);
assert.equal(rankedSkills(visible).length, 20);
assert.deepEqual(
rankedSkills(visible, "telescope", [], true).map((r) => r.skill!.manifest.name),
@@ -180,36 +183,34 @@ test("skill shortlist favors relevant and visibly used skills without global usa
assert.equal(skillsIndex([{ skill: null, shadowed: [] }]), "");
});
-test("pinned skills lead the shortlist regardless of the message and count toward the cap", () => {
- const skills = Array.from({ length: 20 }, (_, i) => {
+test("an index over budget shortens descriptions, then drops them, then leaves trailing skills out", () => {
+ const skills = Array.from({ length: 30 }, (_, i) => {
const r = res(`skill-${String(i).padStart(2, "0")}`, "body");
- r.skill!.manifest.description = i === 5 ? "drafting telescope notes" : "something else";
+ r.skill!.manifest.description = `${"word ".repeat(40)}end`;
return r;
});
- const names = (index: string) => [...index.matchAll(/\*\*([^*]+)\*\*/g)].map((m) => m[1]);
-
- const unpinned = names(skillsIndex(skills, [], "telescope"));
- assert.ok(!unpinned.includes("skill-19"), "a non-matching skill falls past the cap without a pin");
-
- const index = skillsIndex(skills, [], "telescope", [], ["skill-19", "missing-skill", "skill-18"]);
- assert.match(index, /Showing 12 of 20/);
- const shown = names(index);
- assert.deepEqual(
- shown.slice(0, 2),
- ["skill-19", "skill-18"],
- "pins lead in their configured order; unknown names are ignored",
- );
- assert.equal(shown[2], "skill-05", "ranking resumes after the pins");
- assert.equal(shown.length, 12);
- assert.equal(new Set(shown).size, 12, "a pinned skill is not listed twice");
-
- assert.deepEqual(parsePinnedSkills([" voice ", "voice", "drafts"]), { value: ["voice", "drafts"] });
- assert.ok("error" in parsePinnedSkills(undefined), "a missing list is an error, not a clear");
- assert.ok("error" in parsePinnedSkills(["../etc"]));
- assert.ok("error" in parsePinnedSkills(["a", "b", "c", "d", "e", "f", "g"]), "pins leave room for ranked skills");
+ const body = (index: string) => index.split("\n").slice(2);
+ const full = skillsIndex(skills);
+ assert.doesNotMatch(full, /shortened|omitted/);
+
+ const shortened = skillsIndex(skills, [], [], 4_000);
+ assert.ok(body(shortened).join("\n").length <= 4_000);
+ assert.match(shortened, /30 descriptions are shortened/);
+ assert.deepEqual(names(shortened), names(full));
+ assert.ok(body(shortened).every((line) => /^- \*\*skill-\d+\*\* — word.*…$/.test(line)));
+
+ const namesOnly = skillsIndex(skills, [], [], 1_000);
+ assert.match(namesOnly, /Descriptions are omitted to fit the list\./);
+ assert.deepEqual(names(namesOnly), names(full));
+ assert.ok(body(namesOnly).every((line) => /^- \*\*skill-\d+\*\*$/.test(line)));
+
+ const truncated = skillsIndex(skills, [], ["skill-29"], 200);
+ assert.match(truncated, /and 17 skills are left out; find them with skills action search/);
+ assert.deepEqual(names(truncated).slice(0, 2), ["skill-29", "skill-00"]);
+ assert.equal(names(truncated).length, 13);
});
-test("a natural-language Gmail request keeps its relevant bundled skill in the shortlist", () => {
+test("the bundled skills fit the default index budget with full descriptions", () => {
const entries = readdirSync(new URL("../skills-seed/", import.meta.url), { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.flatMap((entry) => {
@@ -224,6 +225,8 @@ test("a natural-language Gmail request keeps its relevant bundled skill in the s
throw error;
}
});
- const shortlist = skillsIndex(entries, [], "Please check my Gmail inbox and tell me what I need to do today");
- assert.match(shortlist, /\*\*google-workspace\*\*/);
+ const index = skillsIndex(entries);
+ assert.equal(names(index).length, entries.length);
+ assert.match(index, /\*\*google-workspace\*\*/);
+ assert.doesNotMatch(index, /shortened|omitted|left out/);
});
diff --git a/test/system-prompt-order.test.ts b/test/system-prompt-order.test.ts
index 190fe3696..41b5b637d 100644
--- a/test/system-prompt-order.test.ts
+++ b/test/system-prompt-order.test.ts
@@ -187,7 +187,6 @@ test("system prompt is ordered cached-prefix → volatile tail, with memory LAST
};
const ordered = [
- "Skills",
"Where you are",
"Where scheduled tasks post",
"Sandbox environment profile",
@@ -496,7 +495,7 @@ test("the system prompt is byte-identical across two turns a minute apart; the c
!environmentOf(second.reply ?? "").includes(`\n## ${title}\n`),
`unchanged "## ${title}" must not repeat`,
);
- if (title !== "Skills") assert.ok(!systemOf(first.reply ?? "").includes(`\n## ${title}\n`));
+ assert.ok(!systemOf(first.reply ?? "").includes(`\n## ${title}\n`));
}
for (const title of ["Sandbox environment profile", "The user's local time", "What you remember", "Your logins"]) {
assert.ok(