Commit b369530
authored
refactor: document strict vs. lenient content-item semantics in convertMapToCallToolResult (#7571)
From a semantic function clustering analysis, two refactoring items were
identified for MCP content normalization. This PR addresses them.
## Changes
- **Documentation (`mcp/tool_result.go`)** — Added a `// Note:` comment
block in `convertMapToCallToolResult` explaining why the inline
`[]interface{}` switch must **not** be replaced with
`mcpresult.NormalizeContentItems`:
```go
// Note: This switch intentionally returns an error when a non-map item
is encountered
// (strict semantics), unlike mcpresult.NormalizeContentItems which
silently skips
// non-map items (lenient semantics). The strict behavior here is
required because this
// function produces SDK-valid CallToolResult values...
// Do NOT replace this switch with a call to
mcpresult.NormalizeContentItems — the
// two have deliberately different error-handling semantics.
```
- **Structural refactor (not done — blocked)** — Import graph audit
confirmed `mcp` already imports `difc`, and `difc` is a caller of
`mcpresult`. Merging `mcpresult` into `mcp` would introduce the cycle
`mcp → difc → mcp`. Consolidation is deferred until the dependency is
broken.1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
| |||
0 commit comments