feat: Auto-exclude built-in tools overridden by user-registered tools#523
feat: Auto-exclude built-in tools overridden by user-registered tools#523
Conversation
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>
Resolve merge conflicts in 4 files: - dotnet/src/Client.cs: Keep MergeExcludedTools with main's non-nullable config access - go/client.go: Keep mergeExcludedTools with main's direct config access (no nil guard) - go/client_test.go: Keep both MergeExcludedTools tests and permission handler tests - python/test_client.py: Merge imports (both define_tool and PermissionHandler) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add E2E tests across all 4 SDKs verifying that registering a custom tool with the same name as a built-in tool (e.g., 'grep') causes the custom tool to be invoked instead of the built-in. This validates the mergeExcludedTools feature end-to-end. - Add 'overrides built-in tool with custom tool' test to Node, Python, Go, .NET - Add YAML snapshot for the replay proxy - Add test/scenarios/tools/tool-overrides/ with all 4 language implementations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix Python tests: add missing required argument to create_session() calls - Fix Go: separate misplaced buildUnsupportedToolResult doc comment from mergeExcludedTools - Fix Go sample: whitespace alignment from merge Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Cross-SDK Consistency Review: PASSEDI've reviewed PR #523 for consistency across all four SDK implementations (Node.js/TypeScript, Python, Go, and .NET). This PR demonstrates exemplary cross-SDK consistency in implementing the feature to auto-exclude built-in tools overridden by user-registered tools. Feature Implementation ConsistencyAll four SDKs implement the same core functionality with appropriate language-specific idioms: 1️⃣ Helper Function Pattern
All implementations properly deduplicate and merge tool names with existing excludedTools. 2️⃣ Integration PointsAll SDKs apply the merge logic in both:
3️⃣ Unit Test CoverageEach SDK includes comprehensive unit tests covering:
Test locations:
4️⃣ E2E Test CoverageAll SDKs include E2E tests verifying the feature works end-to-end:
All E2E tests use the same approach: register a custom 5️⃣ Documentation ConsistencyAll four READMEs include an identical "Overriding Built-in Tools" subsection with:
6️⃣ Test Scenarios & SnapshotsThe PR includes cross-language example implementations in
Language-Specific Differences (All Appropriate)The only differences are idiomatic language conventions, which are correctly applied:
All approaches are idiomatic and achieve the same result. Conclusion🎉 This PR maintains perfect feature parity across all four SDK implementations. The feature is:
No cross-SDK consistency issues found. Excellent work! 👏
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Cross-SDK Consistency Review: PASSEDThis PR demonstrates excellent cross-language consistency in implementing the auto-exclude feature for user-registered tools that override built-ins. All four SDK implementations maintain feature parity with properly adapted API patterns. Summary of ChangesThe PR adds functionality across all SDKs to automatically merge user-registered tool names into Consistency Analysis✅ Core Implementation PatternAll SDKs implement the same logic with language-appropriate patterns:
✅ Integration PointsConsistently applied in both ✅ Test CoverageAll SDKs include comprehensive unit and E2E tests: Unit Tests (testing the merge logic):
E2E Tests (testing actual override behavior):
All E2E tests use the same pattern: register a custom ✅ DocumentationIdentical "Overriding Built-in Tools" subsections added to all four READMEs with language-appropriate code examples, consistent messaging, and proper placement in the "Custom Tools" section. ✅ Naming ConventionsProperly adapted to language idioms:
Edge Cases Handled ConsistentlyAll implementations correctly handle:
No Issues FoundThis PR maintains excellent cross-SDK consistency. The feature is implemented uniformly across all languages with appropriate adaptations for each ecosystem's conventions and idioms. Great work! 🎉
|
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 intoexcludedToolsonsession.create/session.resume, so the CLI skips its built-in and the SDK dispatches locally.Changes
mergeExcludedTools()helper; applied increateSession+resumeSessiondict.fromkeys()for dedup; applied increate_session+resume_sessionmergeExcludedTools()helper with map-based dedup; applied inCreateSession+ResumeSessionWithOptionsMergeExcludedTools()internal static helper usingUnion(); applied inCreateSessionAsync+ResumeSessionAsync; addedInternalsVisibleTofor test projectExample (Node.js)
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/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)/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)/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 successfullyIntent Mapping:
Technical Inventory:
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.-
- Repo:
- 4 SDKs: Node.js (
- Issue Support overriding built-in tools #411: Users registering tools with names colliding with built-in CLI tools (e.g.,
- Solution: Auto-add user-registered tool names to
- Key architecture:
-
- Added
- Called in
- 4 new tests: tools added to excludedTools, deduplication, no-op, resumeSession
- Inline merge logic in both
- Uses
- 4 new tests in
- Added
- Called in
- Added
- Called in
- Added
- New file with 5 tests; all pass
- All 4 READMEs updated with "Overriding Built-in Tools" subsection + code examples
-
- Issue Support overriding built-in tools #411 comments confirmed: maintainer @SteveSandersonMS approved "override by name" approach
- No
- Backward-compatible: users not naming tools after built-ins see no change
-
- ✅ node-override — done
- ✅ python-override — done
- ✅ go-override — done
- ✅ dotnet-override — done
- ✅ docs-update — done
- ✅ Committed, pushed, PR opened
-
- All work complete. PR feat: Support overriding built-in tools #522 is open at feat: Support overriding built-in tools #522
- Branch:
- 13 files changed, 395 insertions, 9 deletions
-
- Last Agent Commands:
- Tool Results Summary: All succeeded. PR URL: https://github.com/git...
Technical Foundation:
github/copilot-sdkat/Users/patrick/projects/copilot-sdknodejs/), Python (python/), Go (go/), .NET (dotnet/)Bash,Read,Edit) couldn't override them — CLI handled them instead of dispatching to user's handler.excludedToolsin thesession.create/session.resumeRPC payload so CLI excludes its built-in and SDK dispatches locally.SessionConfig.tools→ mapped to RPC payload → CLI usesexcludedToolsto skip built-ins → SDK'stool.callhandler dispatches to user's registered handler.Codebase Status:
nodejs/src/client.ts:mergeExcludedTools()helper function (~L57)createSession(~L545) andresumeSession(~L623)nodejs/test/client.test.ts:python/copilot/client.py:create_session(~L483) andresume_session(~L658)dict.fromkeys()for deduplicationpython/test_client.py:TestExcludedToolsFromRegisteredToolsclass; all 26 tests passgo/client.go:mergeExcludedTools()helper (~L1355)CreateSession(~L464) andResumeSessionWithOptions(~L561)go/client_test.go:TestMergeExcludedToolswith 4 sub-testsdotnet/src/Client.cs:MergeExcludedTools()internal static helper (~L855)CreateSessionAsync(~L385) andResumeSessionAsync(~L470)dotnet/src/GitHub.Copilot.SDK.csproj:InternalsVisibleTofor test projectdotnet/test/MergeExcludedToolsTests.cs:Problem Resolution:
externalToolDefinitions/externalToolDispatcherfields exist despite issue description — theSessionConfig.tools+excludedToolsapproach is the correct mechanismProgress Tracking:
Active Work State:
support-tool-overridesRecent Operations:
git checkout -b support-tool-overrides && git add -A→ branch created, all changes stagedgit commit -m "feat: auto-exclude built-in tools overridden by user-registered tools..."→ committed asdc83960git push -u origin support-tool-overrides→ pushed successfullygh pr create --title "feat: Support overriding built-in tools" --body "..." --base main→ created PR feat: Support overriding built-in tools #522Created 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.