Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions workers/api/migrations/0050_repo_chat_declared_tools.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Repo Chat: declare its tool allowlist as DATA (capabilities.tools) instead of
-- relying on the hardcoded `repo`-surface special-case in toolNamesFor.
--
-- This is the first agent to use the declarative tool catalog (#51 / PR #59) — the
-- "creator way" — so it doubles as the reference example a future creator copies.
-- Behavior-preserving: BASE + read-only KB is exactly what the `repo` surface already
-- resolved to; this only makes that choice explicit + data-driven. The surface stays
-- ["repo"] so the Repo tab and technical response-style are unchanged.
--
-- Idempotent: re-running re-sets the same JSON; a no-op on databases without the agent.

UPDATE agents
SET config = json_set(
COALESCE(NULLIF(config, ''), '{}'),
'$.capabilities.tools',
json('["search_knowledge","list_knowledge","read_knowledge"]')
)
WHERE slug = 'repo-chat';
19 changes: 18 additions & 1 deletion workers/api/src/agent-do-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
TOOL_CATALOG,
toolNamesFor,
} from "./agent-do-tools.js";
import type { AgentCapabilities } from "./lib/agent-capabilities.js";
import { agentCapabilities, type AgentCapabilities } from "./lib/agent-capabilities.js";

const caps = (surfaces: AgentCapabilities["surfaces"]): AgentCapabilities => ({
surfaces,
Expand Down Expand Up @@ -149,6 +149,23 @@ describe("agent tool definition helpers", () => {
expect(CREATOR_SELECTABLE_TOOLS.has("submit_job_application")).toBe(false); // legacy
});

it("repo-chat declaring its tools as data resolves identically to the repo-surface default (migration 0050 dogfood)", () => {
// The config shape migration 0050 produces: surface stays "repo", tools now
// declared explicitly. The whole point of the dogfood is that this changes NO
// behavior — it just moves the choice from a hardcoded special-case to data.
const config = JSON.stringify({
capabilities: {
surfaces: ["repo"],
runtime: null,
workflow: null,
tools: ["search_knowledge", "list_knowledge", "read_knowledge"],
},
});
const declared = [...toolNamesFor(agentCapabilities({ slug: "repo-chat", config }))].sort();
const surfaceDefault = [...toolNamesFor(caps(["repo"]))].sort();
expect(declared).toEqual(surfaceDefault);
});

it("returns the complete storage tool name set", () => {
const names = storageToolNameSet();

Expand Down
Loading