Repository navigation
feat: add configurable tool catalog and mode availability - #4797
Draft
liruifengv wants to merge 6 commits into
Draft
liruifengv wants to merge 6 commits into
liruifengv wants to merge 6 commits into
Conversation
🦋 Changeset detectedLatest commit: b91c13b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate active issues remain: task-tool guidance incorrectly disappears when only one tool is disabled, and connected clients can receive stale tool-availability state after session policy changes.
2 open issues
What changed in this PR
This PR makes [tools] a session-scoped default policy captured at session creation, persisted for recovery, inherited by subagents, and used consistently for tool availability, mode entry, prompts, and reminders.
Changes:
- Persist and restore session-level default tool policies, including legacy-session initialization.
- Add tool catalog and configuration API support plus WebSocket mode-availability fields.
- Enforce required tools for Plan, Swarm, Tower, and autonomous goals while updating consumers, reminders, tests, manifests, and documentation.
| File | Description |
|---|---|
| packages/kap-server/test/tools.test.ts | Tests the tool catalog and old/new session policy isolation. |
| packages/kap-server/test/config.test.ts | Tests REST configuration merging and reporting for tool policies. |
| packages/kap-server/test/__snapshots__/apiSurface.snapshot.test.ts.snap | Updates the API snapshot for the tool catalog route. |
| packages/kap-server/src/transport/ws/v1/agentState.ts | Adds mode-availability values to WebSocket agent state frames. |
| packages/kap-server/src/routes/tools.ts | Implements the user-configurable tool catalog endpoint. |
| packages/kap-server/src/protocol/ws-agent.ts | Extends the WebSocket agent-state schema with availability fields. |
| packages/kap-server/src/protocol/tool.ts | Defines schemas for tool catalog entries. |
| packages/kap-server/src/protocol/rest-tool.ts | Defines the REST tool catalog response schema. |
| packages/kap-server/src/protocol/rest-config.ts | Adds tool policy fields to REST configuration schemas. |
| packages/agent-core-v2/test/session/subagent/subagentScopeCache.test.ts | Updates subagent session-policy test fixtures. |
| packages/agent-core-v2/test/session/agentLifecycle/agentLifecycle.test.ts | Updates agent lifecycle session-policy test fixtures. |
| packages/agent-core-v2/test/features/tower/towerService.test.ts | Tests Tower entry rejection when required tools are unavailable. |
| packages/agent-core-v2/test/features/tower/tools/towerTools.test.ts | Updates Tower service fixtures for tool availability. |
| packages/agent-core-v2/test/features/swarm/swarm.test.ts | Tests Swarm entry policy enforcement. |
| packages/agent-core-v2/test/features/plan/plan.test.ts | Tests Plan entry requirements and policy-aware fixtures. |
| packages/agent-core-v2/test/features/notify/notifyUserNudgeService.test.ts | Tests NotifyUser nudges under restricted tool policies. |
| packages/agent-core-v2/test/features/goal/injection/goalInjection.test.ts | Tests goal guidance and UpdateGoal availability behavior. |
| packages/agent-core-v2/test/features/goal/goal.test.ts | Updates goal lifecycle tests to include required policy tools. |
| packages/agent-core-v2/test/app/agentProfileCatalog/profile-shared.test.ts | Tests retaining skill catalog visibility when Skill invocation is disabled. |
| packages/agent-core-v2/test/agent/toolSelect/toolSelectService.test.ts | Tests restore-time tool removal announcement behavior. |
| packages/agent-core-v2/test/agent/toolPolicy/toolPolicyService.test.ts | Tests session-scoped policy snapshots and stable policy behavior. |
| packages/agent-core-v2/test/agent/task/taskService.test.ts | Tests task reminders under restricted tool policies. |
| packages/agent-core-v2/test/agent/profile/profileOps.test.ts | Updates profile operation session-policy fixtures. |
| packages/agent-core-v2/test/agent/profile/binding.test.ts | Tests policy snapshot restoration, legacy migration, and skill visibility. |
| packages/agent-core-v2/test/agent/changeNotifier/changeNotifier.test.ts | Tests skill reminders independently of Skill invocation availability. |
| packages/agent-core-v2/src/workspace/sessionLifecycle/sessionLifecycleService.ts | Skips automatic Plan entry when ExitPlanMode is unavailable. |
| packages/agent-core-v2/src/session/sessionToolPolicy/sessionToolPolicyService.ts | Captures, persists, restores, and exposes session default tool policies. |
| packages/agent-core-v2/src/session/sessionToolPolicy/sessionToolPolicy.ts | Defines the session default tool policy contract. |
| packages/agent-core-v2/src/features/tower/towerService.ts | Validates the complete Tower tool set before entry. |
| packages/agent-core-v2/src/features/tower/towerFeature.ts | Marks Tower tools as user-configurable. |
| packages/agent-core-v2/src/features/tower/tower.ts | Adds Tower handling for unavailable required tools. |
| packages/agent-core-v2/src/features/todo/todoFeature.ts | Marks TodoList as user-configurable. |
| packages/agent-core-v2/src/features/swarm/swarmFeature.ts | Marks AgentSwarm as user-configurable. |
| packages/agent-core-v2/src/features/swarm/agent/swarmService.ts | Rejects Swarm entry when AgentSwarm is unavailable. |
| packages/agent-core-v2/src/features/skill/skillFeature.ts | Marks Skill as user-configurable. |
| packages/agent-core-v2/src/features/plan/planService.ts | Rejects Plan entry when ExitPlanMode is unavailable. |
| packages/agent-core-v2/src/features/plan/planFeature.ts | Marks ExitPlanMode as user-configurable. |
| packages/agent-core-v2/src/features/notify/notifyUserNudgeService.ts | Suppresses NotifyUser nudges when the tool is disabled. |
| packages/agent-core-v2/src/features/notify/notifyFeature.ts | Marks NotifyUser as user-configurable. |
| packages/agent-core-v2/src/features/goal/injection/goalInjection.ts | Makes goal budget guidance depend on tool availability. |
| packages/agent-core-v2/src/features/goal/injection/goal-active-sparse-reminder.md | Adds conditional budget guidance to sparse goal reminders. |
| packages/agent-core-v2/src/features/goal/injection/goal-active-reminder.md | Adds conditional budget guidance to full goal reminders. |
| packages/agent-core-v2/src/features/goal/goalService.ts | Requires UpdateGoal for goal creation and resumption. |
| packages/agent-core-v2/src/features/goal/goalFeature.ts | Marks goal-management tools as user-configurable. |
| packages/agent-core-v2/src/features/cron/cronFeature.ts | Marks cron tools as user-configurable. |
| packages/agent-core-v2/src/app/telemetry/events.ts | Adds the Tower tools-disabled telemetry reason. |
| packages/agent-core-v2/src/app/agentProfileCatalog/profile-shared.ts | Keeps skill catalogs visible independently of Skill invocation availability. |
| packages/agent-core-v2/src/agent/toolSelect/toolSelectService.ts | Filters policy-inactive tools from restore-time removal announcements. |
| packages/agent-core-v2/src/agent/tools/web-search/webSearchTool.ts | Marks WebSearch as user-configurable. |
| packages/agent-core-v2/src/agent/tools/task/task-wait/taskWaitTool.ts | Marks WaitFor as user-configurable. |
| packages/agent-core-v2/src/agent/tools/task/task-stop/taskStopTool.ts | Marks TaskStop as user-configurable. |
| packages/agent-core-v2/src/agent/tools/task/task-output/taskOutputTool.ts | Marks TaskOutput as user-configurable. |
| packages/agent-core-v2/src/agent/tools/task/task-list/taskListTool.ts | Marks TaskList as user-configurable. |
| packages/agent-core-v2/src/agent/tools/os/write/writeTool.ts | Marks Write as user-configurable. |
| packages/agent-core-v2/src/agent/tools/os/read/readTool.ts | Marks Read as user-configurable. |
| packages/agent-core-v2/src/agent/tools/os/grep/grepTool.ts | Marks Grep as user-configurable. |
| packages/agent-core-v2/src/agent/tools/os/glob/globTool.ts | Marks Glob as user-configurable. |
| packages/agent-core-v2/src/agent/tools/os/bash/bashTool.ts | Marks Bash as user-configurable. |
| packages/agent-core-v2/src/agent/tools/fetch-url/fetchUrlTool.ts | Marks FetchURL as user-configurable. |
| packages/agent-core-v2/src/agent/tools/edit/editTool.ts | Marks Edit as user-configurable. |
| packages/agent-core-v2/src/agent/tools/ask-user-question/askUserQuestionTool.ts | Marks AskUserQuestion as user-configurable. |
| packages/agent-core-v2/src/agent/tools/agent/agentTool.ts | Marks Agent as user-configurable. |
| packages/agent-core-v2/src/agent/toolRegistry/toolContribution.ts | Adds contribution metadata for configurable tools. |
| packages/agent-core-v2/src/agent/toolPolicy/toolPolicyService.ts | Switches policy evaluation from live configuration to the session snapshot. |
| packages/agent-core-v2/src/agent/task/taskService.ts | Makes background-task reminders respect individually available tools. |
| packages/agent-core-v2/src/agent/profile/profileService.ts | Uses the session snapshot for profile policy checks and warnings. |
| packages/agent-core-v2/src/agent/changeNotifier/changeNotifierService.ts | Uses session policy data while preserving skill reminders. |
| packages/agent-core-v2/docs/state-manifest.d.ts | Documents persisted default tool policy state. |
| docs/zh/reference/server-api.md | Documents the tool catalog endpoint and availability fields in Chinese. |
| docs/zh/configuration/config-files.md | Documents session-scoped tool configuration in Chinese. |
| docs/en/reference/server-api.md | Documents the tool catalog endpoint and availability fields in English. |
| docs/en/configuration/config-files.md | Documents session-scoped tool configuration in English. |
| .changeset/session-default-tool-policy.md | Records the user-facing session-scoped tool policy changes. |
Review effort: Lite
Comment on lines
+351
to
+355
| const taskToolsActive = | ||
| this.policy.isToolActive('TaskList') && | ||
| this.policy.isToolActive('TaskOutput') && | ||
| this.policy.isToolActive('TaskStop'); | ||
| if (!taskToolsActive) return formatTaskList(tasks, true); |
Comment on lines
+37
to
+40
| plan_mode_available: toolPolicy?.isToolActive('ExitPlanMode') === true, | ||
| swarm_mode_available: toolPolicy?.isToolActive('AgentSwarm') === true, | ||
| tower_mode_available: optionalService(handle, IAgentTowerService)?.toolsAvailable === true, | ||
| goal_mode_available: toolPolicy?.isToolActive('UpdateGoal') === true, |
This was referenced Nov 10, 2026
5 of 6 tasks
liruifengv
changed the base branch from
main
to
feat/custom-subagent-settings
November 11, 2026 03:35
5 of 6 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Requirement or Bug
Desktop needs a built-in tool settings page whose switches apply to both current and new sessions. The server therefore needs a session-independent tool catalog, global
[tools]config mapping, current mode-availability information, and server-side entry guards for modes whose required tools are disabled.This PR intentionally does not snapshot tool defaults per session. Existing global tool policy remains dynamic for loaded agents, subagents, restored sessions, and newly created sessions.
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
Core idea
flowchart LR Catalog[Static and runtime tool metadata] --> API[GET /tools/catalog] Config[Global tools config] --> REST[Config REST mapping] Config --> Existing[Existing agent policy] Config --> New[New and restored agent policy] Existing --> Availability[Mode availability in agent frames] Existing --> Guards[Mode entry guards] Availability --> Desktop[Desktop entry visibility]The existing
AgentToolPolicyServicecontinues to listen for global config changes. There is nodefaultToolsstate, session snapshot, migration, or cold-restore snapshot path. Availability is computed from current policy whenever anagentframe is produced; changing[tools]alone does not publish an additional frame.Main changes
GET /api/v1/tools/catalogand exposetools.enabled/tools.disabledthrough the config REST schema.plan_mode_available,swarm_mode_available,tower_mode_available, andgoal_mode_availableto initial and subsequentagentframes.defaultPlanModeentry whenExitPlanModeis disabled.disallowedToolsdenials still apply.Reading guide
packages/kap-server/src/routes/tools.tsandpackages/agent-core-v2/src/agent/toolRegistry/toolContribution.ts— catalog metadata and endpoint.packages/kap-server/src/transport/ws/v1/agentState.ts— availability frame fields.packages/agent-core-v2/src/features/{plan,swarm,tower,goal}— entry requirements and guards.packages/kap-server/test/tools.test.tsandpackages/kap-server/test/sessionEventBroadcaster.test.ts— dynamic old/new-session policy and frame coverage.The session snapshot, Goal prompt, restore-time tool-removal, and reminder changes formerly explored on this branch are not part of the final diff.
Behavior Changes and Affected Users
[tools]semanticsGET /api/v1/tools/catalogwith static and runtime built-in metadata/toolsis unchanged[tools]changesagentframe, not immediately on config saveExitPlanMode/AgentSwarmdefaultPlanModeExitPlanModeis unavailableExitPlanModeor disable default Plan modeUpdateGoalUpdateGoalAffected contracts are additive: the tool catalog route, config
toolsfield, and agent availability booleans. No wire, session-state, SDK method, or old-client fallback contract is introduced.Verification
pnpm --filter @moonshot-ai/agent-core-v2 typecheck: passed.pnpm --filter @moonshot-ai/kap-server typecheck: passed.Checklist
gen-changesetsskill; added.changeset/configurable-tool-catalog.md.gen-docsskill assessment and updated the relevant English and Chinese server API pages.Companion desktop PR: https://github.com/MoonshotAI/kimi-code-app/pull/1239