mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-11-21 16:51:28 +00:00
fix: keep built-in web-fetch and claude-code-guide agents out of the Agent picker (#1672)
Fixes #1670. ## Problem The Agent picker is meant to show only when the user has custom agents. It showed with none, listing `web-fetch` as if it were one. `supportedAgents()` returns Claude Code's built-in subagents together with the custom ones, and `AgentInfo` does not say which is which, so the adapter filters the built-ins by name (`BUILTIN_AGENT_NAMES`). Claude Code lists two built-ins that the set did not name: - `web-fetch`: listed where Claude Code's staged rollout turns it on, or with `CLAUDE_CODE_WEB_FETCH_AGENT=1`. - `claude-code-guide`: listed where the adapter's environment already sets `CLAUDE_CODE_ENTRYPOINT`. The SDK sets `sdk-ts` only when the variable is unset, and Claude Code leaves the agent out for that value. The roster integration test (`src/tests/agent-discovery.test.ts`) exists to catch this drift. It did not, because neither agent is in the roster of an account outside the rollout that runs the test from a plain shell. ## Change - Add `web-fetch` and `claude-code-guide` to `BUILTIN_AGENT_NAMES`. This covers v1 and v2: both build the picker from the same set. - The roster test sets `CLAUDE_CODE_WEB_FETCH_AGENT=1` and its own `CLAUDE_CODE_ENTRYPOINT`, so the roster it compares against no longer depends on the account or on the shell. ## Why the list is still hard-coded The issue asks to derive the built-ins from the SDK. The only SDK surface that separates them is `getContextUsage().agents`, which lists the agents that are not built in. Session setup deliberately does not wait for `getContextUsage` (see `readContextWindow` and the "does not wait for getContextUsage during session creation" tests), so the picker cannot be built from it without putting that request back on the `session/new` and `session/load` path. A built-in behind a future rollout can therefore still leak until it is added to the set and to the test. ## Testing - With CLI 2.1.328 and `CLAUDE_CODE_WEB_FETCH_AGENT=1`, `supportedAgents()` reports `web-fetch` with no custom agents configured, as in the issue. With a preset `CLAUDE_CODE_ENTRYPOINT` it reports `claude-code-guide`. - Both the roster test and the `discoverCustomAgents` unit test fail on the old set and pass with the new one. - `npm run build`, `npm run check`, and the whole suite against the real CLI (`RUN_INTEGRATION_TESTS=true`): 4406 passed, 9 skipped.
This commit is contained in:
@@ -44,12 +44,25 @@ import {
|
||||
// personas, so we filter them out and only surface the Agent picker when the
|
||||
// user (or a plugin/project) has configured custom agents. Update this set if
|
||||
// the SDK's built-in roster changes.
|
||||
//
|
||||
// The set is matched by name because `AgentInfo` does not say where an agent
|
||||
// comes from. `getContextUsage().agents` lists only the agents that are not
|
||||
// built in, but session setup does not wait for that request (see
|
||||
// `readContextWindow`).
|
||||
//
|
||||
// Claude Code does not list two of them in every session: `web-fetch` only
|
||||
// where its staged rollout or `CLAUDE_CODE_WEB_FETCH_AGENT=1` turns it on, and
|
||||
// `claude-code-guide` only where the adapter's environment sets
|
||||
// `CLAUDE_CODE_ENTRYPOINT` (the SDK sets `sdk-ts` when it is unset, and Claude
|
||||
// Code leaves the agent out for that value).
|
||||
export const BUILTIN_AGENT_NAMES = new Set([
|
||||
"claude",
|
||||
"claude-code-guide",
|
||||
"general-purpose",
|
||||
"Explore",
|
||||
"Plan",
|
||||
"statusline-setup",
|
||||
"web-fetch",
|
||||
]);
|
||||
|
||||
// Value of the synthetic "Default" entry in the agent picker, which maps to the
|
||||
|
||||
@@ -11,6 +11,13 @@ import { discoverCustomAgents, BUILTIN_AGENT_NAMES } from "../session-config-opt
|
||||
// silently if the SDK changes its default roster: a newly added built-in would
|
||||
// leak into the ACP "Agent" picker as if the user had configured it. This
|
||||
// integration test runs the real SDK so the set is flagged the moment it does.
|
||||
//
|
||||
// Claude Code does not list every built-in in every session (issue #1670):
|
||||
// `web-fetch` needs its staged rollout or `CLAUDE_CODE_WEB_FETCH_AGENT=1`, and
|
||||
// `claude-code-guide` an entrypoint other than the SDK's `sdk-ts`. The test
|
||||
// sets both variables, so the roster does not depend on the account or on the
|
||||
// shell that runs it. A built-in behind a rollout with no variable set here
|
||||
// shows up only where that rollout is on.
|
||||
describe.skipIf(!process.env.RUN_INTEGRATION_TESTS)("agent discovery (SDK)", () => {
|
||||
it("BUILTIN_AGENT_NAMES exactly covers the SDK's default agent roster", async () => {
|
||||
const input = new Pushable<SDKUserMessage>();
|
||||
@@ -24,6 +31,11 @@ describe.skipIf(!process.env.RUN_INTEGRATION_TESTS)("agent discovery (SDK)", ()
|
||||
// regardless of what the developer has in ~/.claude/agents.
|
||||
settingSources: [],
|
||||
includePartialMessages: true,
|
||||
env: {
|
||||
...process.env,
|
||||
CLAUDE_CODE_WEB_FETCH_AGENT: "1",
|
||||
CLAUDE_CODE_ENTRYPOINT: "agent-roster-test",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -30656,10 +30656,12 @@ describe("agent selection config option", () => {
|
||||
const q = {
|
||||
supportedAgents: async () => [
|
||||
{ name: "claude", description: "catch-all" },
|
||||
{ name: "claude-code-guide", description: "guide" },
|
||||
{ name: "Explore", description: "search" },
|
||||
{ name: "general-purpose", description: "gp" },
|
||||
{ name: "Plan", description: "architect" },
|
||||
{ name: "statusline-setup", description: "status" },
|
||||
{ name: "web-fetch", description: "fetch" },
|
||||
{ name: "my-reviewer", description: "Reviews code" },
|
||||
{ name: "my-writer", description: "Writes docs" },
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user