Skip to content

[dotnet-code] Extract agent tool name sanitizer - #926

Merged
Quim Muntal (qmuntal) merged 1 commit into
mainfrom
dotnet-code-agenttool-sanitize-helper-b89802a0bbdb6d75
Aug 28, 2026
Merged

[dotnet-code] Extract agent tool name sanitizer#926
Quim Muntal (qmuntal) merged 1 commit into
mainfrom
dotnet-code-agenttool-sanitize-helper-b89802a0bbdb6d75

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

Summary

Extracted agent-tool name sanitization into an unexported sanitizeAgentName helper. This keeps existing behavior while making the Go internals structurally closer to the .NET SanitizeAgentName helper used when exposing agents as function tools.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI/AgentExtensions.cs - SanitizeAgentName helper used by AsAIFunction metadata generation.
  • dotnet/src/Microsoft.Agents.AI/FunctionInvocationDelegatingAgent.cs - sampled agent/function invocation area; rejected because Go already has separate tool auto-call middleware and this PR focuses on the safer agent-tool metadata shape.
  • dotnet/src/Microsoft.Agents.AI.Workflows/AgentResponseUpdateEvent.cs - sampled workflow response-update event area; rejected because the Go workflow event model does not have a similarly narrow internal cleanup.
  • dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/ChatCompletions/Models/ChatCompletionRequestMessage.cs - sampled provider message conversion area; rejected to avoid provider serialization churn.
  • dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillsSourceContext.cs - sampled skills context area; rejected because the Go skills source shape is already minimal and changing it would risk API surface changes.

Public API and Behavior

No public Go API changed. No intentional behavior change was made.

Tests

  • go test ./tool/agenttool

Existing agent-tool tests continue to cover sanitized names, fallback-to-ID behavior, default descriptions, and invocation behavior.

Notes

Checked for open [dotnet-code] PRs before editing. Exact searches for agenttool and SanitizeAgentName found no candidate-specific open PR; one broader low-integrity result was filtered by policy and could not be inspected, so the change was kept narrowly scoped to the exact helper extraction.

Generated by .NET-to-Go Code Portability Refactoring Agent · gpt55 · 90.4 AIC · ⌖ 14.3 AIC · ⊞ 23.2K ·

Closes #918

Align the Go agent-tool internals with the .NET SanitizeAgentName helper shape while preserving existing naming behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 27, 2026 17:45
@github-actions github-actions Bot added area:tool Changes files in the tool area size:small At most 30 changed lines across at most 2 files labels Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extracts the agent tool-name sanitization logic in tool/agenttool into an unexported sanitizeAgentName helper, aligning the Go internal shape with the referenced .NET SanitizeAgentName helper while preserving existing behavior.

Changes:

  • Refactored functool.Name() to call sanitizeAgentName(name) instead of inlining the regex replacement.
  • Added a private sanitizeAgentName helper that centralizes the invalidNameChars replacement logic.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

API Consistency Review

Scope: internal-only
Changed Go contract: None — the PR extracts invalidNameChars.ReplaceAllString(name, "_") into an unexported sanitizeAgentName helper. No exported Go symbols were added, removed, or changed.
Upstream evidence reviewed: dotnet/src/Microsoft.Agents.AI/AgentExtensions.csSanitizeAgentName (cited in PR description as the structural reference). The Go helper performs the same regex-replace sanitization; naming and semantics are aligned.
Result: out of scope for parity labeling; no inconsistencies found.

This is an internal-only refactor. No public API review (public-api-change label) is required and no parity issues were identified.

Generated by Go API Consistency Review Agent for #926 · sonnet46 · 13.2 AIC · ⌖ 6.86 AIC · ⊞ 6.4K ·

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Aug 27, 2026
@github-actions github-actions Bot added pending-auto-risk Automatic risk classification is in progress risk:low Limited blast radius and straightforward rollback and removed pending-auto-risk Automatic risk classification is in progress labels Aug 27, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Aug 28, 2026
Merged via the queue into main with commit b8a841c Aug 28, 2026
37 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the dotnet-code-agenttool-sanitize-helper-b89802a0bbdb6d75 branch August 28, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tool Changes files in the tool area parity-approved Go API consistency review found no parity issues risk:low Limited blast radius and straightforward rollback size:small At most 30 changed lines across at most 2 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-code] Extract agent tool name sanitizer

3 participants