Repository navigation
feat(mcp): load MCP tool schemas on demand; persist proposed plans - #409
Open
raymondginger2018-sudo wants to merge 1 commit into
Open
raymondginger2018-sudo wants to merge 1 commit into
raymondginger2018-sudo wants to merge 1 commit into
Conversation
MCP servers can contribute many tool definitions, and every one of them is advertised up front before the conversation starts. With a large MCP fleet that is the single biggest fixed cost in the system prompt. Add an opt-in deferred mode (DEEPCODE_DEFERRED_MCP_TOOLS=1): the system prompt lists MCP tool names only, and a new SearchMcpTools tool returns the full schema for the tools the model actually needs. Execution is unchanged because executeMcpTool resolves tools by name, not by what was advertised. Also persist a finished plan to .deepcode/plans/<timestamp>-plan.md before opening the implementation chooser, so the plan survives a compaction, an undo or a later session. Persistence is best-effort and never fails a turn. And tighten two tool docs: git commit/push discipline in bash.md, and the 'coverage - silence is not success' rule for background jobs.
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.
Summary
Two prompt/context-economy improvements plus two tool-doc tightenings.
1. Deferred MCP tool schemas (opt-in). MCP servers contribute tool definitions that are all advertised up front. With a large fleet that is the biggest fixed cost in the system prompt. Behind
DEEPCODE_DEFERRED_MCP_TOOLS=1, the system prompt lists MCP tool names only and a newSearchMcpToolstool returns the full schema for the tools the model actually needs.Execution is unaffected:
executeMcpTool()resolves tools bynamespacedNameinthis.tools, independent of what was advertised. Default is off, so behaviour is unchanged unless the env knob is set.2. Plan persistence. A finished
<proposed_plan>is written to.deepcode/plans/<timestamp>-plan.mdbefore the implementation chooser opens, so the plan survives a compaction, an undo, or a later session. Persistence is best-effort and never fails a turn — the approval flow is untouched.3. Tool-doc discipline in
bash.md: git commit/push rules (only when asked; branch first on the default branch) and the "coverage — silence is not success" rule for background jobs.Changes
packages/core/src/prompt.tsPromptToolOptions.deferredMcpTools; advertiseSearchMcpTools; only inject its doc when enabledpackages/core/templates/tools/search-mcp-tools.mdpackages/core/src/mcp/mcp-manager.tslistMcpToolNames()+searchMcpTools(query, limit)packages/core/src/tools/executor.tsSearchMcpToolshandler (limit clamped to 1..25)packages/core/src/session.tsisDeferredMcpToolsEnabled(),refreshMcpToolDefinitions(),buildSystemPromptWithToolCatalog()packages/core/src/common/plan-implementation.tspersistProposedPlan()packages/cli/src/ui/views/App.tsxpackages/core/src/tests/plan-implementation.test.tspackages/core/templates/tools/bash.mdTests
npm run check(typecheck + eslint + prettier): passnpm run build: pass (bundle assets copied)npm test: 696 pass / 5 fail (cli) + 673 pass / 2 fail (core). All 7 are pre-existing onmain:model-settingsfailures reproduce identically on a cleanorigin/maintree (verified by stashing my changes and re-running the same file);Dependency note
No new dependencies. Default behaviour is unchanged; the only runtime switch is the
DEEPCODE_DEFERRED_MCP_TOOLSenv var.