Collapse RPC logging split API and remove duplicated tag-branching#6829
Merged
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] Fix duplicate code pattern in RPC logging API
Collapse RPC logging split API and remove duplicated tag-branching
Jun 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies RPC request/response logging by collapsing split “with/without agent tags” logger APIs into a single API that accepts optional tag slices, and then removes duplicated tag-attachment branching in MCP connection logging.
Changes:
- Consolidated
LogRPCRequest/LogRPCResponseinto unified functions that accept optionalagentSecrecy/agentIntegrityslices. - Removed repeated
shouldAttach*branching at connection logging call sites by passing a nil-or-real*AgentTagsSnapshotand extracting tags once. - Updated MCP and logger tests/comments to align with the unified logging API.
Show a summary per file
| File | Description |
|---|---|
| internal/logger/rpc_logger.go | Collapses RPC request/response logging APIs to accept optional agent tag slices. |
| internal/logger/rpc_logger_test.go | Updates tests to call unified APIs; keeps coverage for tagged/untagged JSONL behavior. |
| internal/mcp/connection.go | Deduplicates tag-attachment branching by selecting a nil-or-real logging snapshot once. |
| internal/mcp/connection_logging.go | Introduces snapshotTags helper and removes duplicated logger branching in request/response logging helpers. |
| internal/mcp/connection_logging_test.go | Updates helper calls to the new snapshot-based signature. |
| internal/mcp/sdk_method_dispatch_test.go | Updates test comments to reflect unified optional-tag logging behavior. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 0
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.
RPC request/response logging exposed split APIs for with/without agent tags, which forced repeated
shouldAttachTagsbranching in connection logging. This change collapses logging to a single request/response API with optional tag slices and removes duplicate branching at call sites.Logger API consolidation (
internal/logger/rpc_logger.go)LogRPC*+LogRPC*WithAgentSnapshot) to 2 public functions:LogRPCRequest(..., agentSecrecy, agentIntegrity []string)LogRPCResponse(..., err, agentSecrecy, agentIntegrity []string)nilslices.Connection logging deduplication (
internal/mcp/connection_logging.go,internal/mcp/connection.go)if shouldAttachTagsbranches from outbound/inbound logging paths.Call-site and test alignment