Skip to content

fix: eliminate duplicate sys tool delegation block via callSysServer helper#1910

Merged
lpcox merged 1 commit intomainfrom
copilot/duplicate-code-fix-sys-tools
Mar 14, 2026
Merged

fix: eliminate duplicate sys tool delegation block via callSysServer helper#1910
lpcox merged 1 commit intomainfrom
copilot/duplicate-code-fix-sys-tools

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

Summary

Closes the duplicate code issue for the sys tool sysServer delegation block in internal/server/unified.go.

The two sys-tool handler closures (sysInitHandler and sysListHandler) previously contained an identical ~10-line block that:

  1. Marshaled a tools/call params object with the tool name
  2. Invoked us.sysServer.HandleRequest("tools/call", ...)
  3. Checked the error
  4. Returned nil, result, nil

Changes

  • Extracted a callSysServer(toolName string) (interface{}, error) helper method on UnifiedServer that centralises the marshal → HandleRequest → error check → return pattern
  • Updated sysInitHandler and sysListHandler to delegate to the helper, keeping only their tool-specific pre-call logic and log messages
  • The helper makes it straightforward to add future sys_* tools without copy-pasting the delegation block

Implementation Checklist

  • Review duplication findings
  • Extract callSysServer(toolName string) helper on UnifiedServer
  • Update sysInitHandler to use helper
  • Update sysListHandler to use helper
  • Verify future sys_* tools follow the helper pattern
  • Tests pass (make agent-finished)

Resolves: [duplicate-code] Duplicate Code Pattern: Sys Tool sysServer Delegation Block

Copilot AI requested a review from lpcox March 14, 2026 23:12
@lpcox lpcox marked this pull request as ready for review March 14, 2026 23:17
Copilot AI review requested due to automatic review settings March 14, 2026 23:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@lpcox lpcox merged commit 37ccc78 into main Mar 14, 2026
5 checks passed
@lpcox lpcox deleted the copilot/duplicate-code-fix-sys-tools branch March 14, 2026 23:19
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.

3 participants