Skip to content

Comments

feat: Auto-exclude built-in tools overridden by user-registered tools#523

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/review-code-changes
Draft

feat: Auto-exclude built-in tools overridden by user-registered tools#523
Copilot wants to merge 2 commits intomainfrom
copilot/review-code-changes

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

When users register tools whose names collide with CLI built-ins (e.g. edit_file, read_file), the CLI would intercept those calls instead of dispatching to the user's handler. The fix: automatically merge user-registered tool names into excludedTools on session.create/session.resume, so the CLI skips its built-in and the SDK dispatches locally.

Changes

  • Node.jsmergeExcludedTools() helper; applied in createSession + resumeSession
  • Python — inline merge using dict.fromkeys() for dedup; applied in create_session + resume_session
  • GomergeExcludedTools() helper with map-based dedup; applied in CreateSession + ResumeSessionWithOptions
  • .NETMergeExcludedTools() internal static helper using Union(); applied in CreateSessionAsync + ResumeSessionAsync; added InternalsVisibleTo for test project
  • Tests — unit tests in all 4 SDKs covering: names added, deduplication, no-op (no tools), and resume path
  • Docs — "Overriding Built-in Tools" subsection added to all 4 READMEs

Example (Node.js)

// Register a tool named after a CLI built-in — your handler is called instead
const session = await client.createSession({
  tools: [defineTool("edit_file", {
    description: "Custom editor with project-specific validation",
    parameters: z.object({ path: z.string(), content: z.string() }),
    handler: async ({ path, content }) => { /* your logic */ },
  })],
  // No need to manually add "edit_file" to excludedTools — SDK does it automatically
});

Backward-compatible: users with no name collisions see no behavior change.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/copilot_internal/user
    • Triggering command: /opt/hostedtoolcache/node/22.22.0/x64/bin/node /opt/hostedtoolcache/node/22.22.0/x64/bin/node /home/REDACTED/work/copilot-sdk/copilot-sdk/nodejs/node_modules/@github/copilot/index.js --headless --no-auto-update --log-level debug --stdio ache/node/22.22.0/x64/bin/git (http block)
    • Triggering command: /opt/hostedtoolcache/node/22.22.0/x64/bin/node /opt/hostedtoolcache/node/22.22.0/x64/bin/node /home/REDACTED/work/copilot-sdk/copilot-sdk/nodejs/node_modules/@github/copilot/index.js --headless --no-auto-update --log-level debug --stdio cal/bin/git (http block)
    • Triggering command: /opt/hostedtoolcache/node/22.22.0/x64/bin/node /opt/hostedtoolcache/node/22.22.0/x64/bin/node /home/REDACTED/work/copilot-sdk/copilot-sdk/nodejs/node_modules/@github/copilot/index.js --headless --no-auto-update --log-level debug --stdio rgo/bin/git (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

i want to review the code in this branch

Chronological Review: 1. User asked about branch changes → on main, no changes 2. User asked for 10 recent issues → listed, recommended #518 3. User asked to find issue about overriding tools → found #411 4. User entered plan mode → analyzed codebase extensively via explore agents, created plan with 5 todos 5. User entered fleet mode → dispatched 4 parallel agents for SDK implementations 6. All 4 agents completed, then docs agent dispatched and completed 7. User asked to commit, push, and open PR → done successfully

Intent Mapping:

Technical Inventory:

  • github/copilot-sdk repo with 4 SDKs: Node.js, Python, Go, .NET
  • Issue Support overriding built-in tools #411: Support overriding built-in tools
  • Solution: auto-add user tool names to excludedTools in RPC payload
  • mergeExcludedTools helper pattern across SDKs

Code changes across 13 files, all committed and pushed.

Recent Commands: git commit, git push, gh pr create → PR #522 created

1. Conversation Overview: - Primary Objectives: User wanted to explore the copilot-sdk repo, find a good issue to work on, then plan and implement Issue #411 ("Support overriding built-in tools"), and finally commit/push/open a PR. - Session Context: Started with repo exploration → issue review → found #411 about tool overrides → planned implementation → executed across all 4 SDKs in parallel → committed and opened PR #522. - User Intent Evolution: Browse issues → focus on #411 → plan → execute → ship.
  1. Technical Foundation:

    • Repo: github/copilot-sdk at /Users/patrick/projects/copilot-sdk
    • 4 SDKs: Node.js (nodejs/), Python (python/), Go (go/), .NET (dotnet/)
    • Issue Support overriding built-in tools #411: Users registering tools with names colliding with built-in CLI tools (e.g., Bash, Read, Edit) couldn't override them — CLI handled them instead of dispatching to user's handler.
    • Solution: Auto-add user-registered tool names to excludedTools in the session.create/session.resume RPC payload so CLI excludes its built-in and SDK dispatches locally.
    • Key architecture: SessionConfig.tools → mapped to RPC payload → CLI uses excludedTools to skip built-ins → SDK's tool.call handler dispatches to user's registered handler.
  2. Codebase Status:

    • nodejs/src/client.ts:
      • Added mergeExcludedTools() helper function (~L57)
      • Called in createSession (~L545) and resumeSession (~L623)
    • nodejs/test/client.test.ts:
      • 4 new tests: tools added to excludedTools, deduplication, no-op, resumeSession
    • python/copilot/client.py:
      • Inline merge logic in both create_session (~L483) and resume_session (~L658)
      • Uses dict.fromkeys() for deduplication
    • python/test_client.py:
      • 4 new tests in TestExcludedToolsFromRegisteredTools class; all 26 tests pass
    • go/client.go:
      • Added mergeExcludedTools() helper (~L1355)
      • Called in CreateSession (~L464) and ResumeSessionWithOptions (~L561)
    • go/client_test.go:
      • TestMergeExcludedTools with 4 sub-tests
    • dotnet/src/Client.cs:
      • Added MergeExcludedTools() internal static helper (~L855)
      • Called in CreateSessionAsync (~L385) and ResumeSessionAsync (~L470)
    • dotnet/src/GitHub.Copilot.SDK.csproj:
      • Added InternalsVisibleTo for test project
    • dotnet/test/MergeExcludedToolsTests.cs:
      • New file with 5 tests; all pass
    • All 4 READMEs updated with "Overriding Built-in Tools" subsection + code examples
  3. Problem Resolution:

    • Issue Support overriding built-in tools #411 comments confirmed: maintainer @SteveSandersonMS approved "override by name" approach
    • No externalToolDefinitions/externalToolDispatcher fields exist despite issue description — the SessionConfig.tools + excludedTools approach is the correct mechanism
    • Backward-compatible: users not naming tools after built-ins see no change
  4. Progress Tracking:

    • ✅ node-override — done
    • ✅ python-override — done
    • ✅ go-override — done
    • ✅ dotnet-override — done
    • ✅ docs-update — done
    • ✅ Committed, pushed, PR opened
  5. Active Work State:

  6. Recent Operations:

    • Last Agent Commands:
      1. git checkout -b support-tool-overrides && git add -A → branch created, all changes staged
      2. git commit -m "feat: auto-exclude built-in tools overridden by user-registered tools..." → committed as dc83960
      3. git push -u origin support-tool-overrides → pushed successfully
      4. gh pr create --title "feat: Support overriding built-in tools" --body "..." --base main → created PR feat: Support overriding built-in tools #522
    • Tool Results Summary: All succeeded. PR URL: https://github.com/git...

Created from Copilot CLI via the copilot delegate command.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Auto-add user-registered tool names to excludedTools in session.create/resume
RPC payloads so that SDK-registered tools override CLI built-in tools.

- Node.js: mergeExcludedTools() helper + createSession/resumeSession updates
- Python: inline merge logic in create_session/resume_session
- Go: mergeExcludedTools() helper + CreateSession/ResumeSessionWithOptions updates
- .NET: MergeExcludedTools() helper + CreateSessionAsync/ResumeSessionAsync updates
- Tests added for all 4 SDKs
- All 4 READMEs updated with "Overriding Built-in Tools" documentation

Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
Copilot AI changed the title [WIP] Review code changes in branch feat: Auto-exclude built-in tools overridden by user-registered tools Feb 20, 2026
Copilot AI requested a review from patniko February 20, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants