Repository navigation
Python: sanitize handoff tool names for agent names with spaces - #9053
Closed
Suhas Aggarwal (suhasagg) wants to merge 2 commits into
Closed
Suhas Aggarwal (suhasagg) wants to merge 2 commits into
Suhas Aggarwal (suhasagg) wants to merge 2 commits into
Conversation
Suhas Aggarwal (suhasagg)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
October 5, 2026 12:10
Suhas Aggarwal (suhasagg)
temporarily deployed
to
github-app-auth
October 5, 2026 12:10 — with
GitHub Actions
Inactive
Suhas Aggarwal (suhasagg)
temporarily deployed
to
github-app-auth
October 5, 2026 12:11 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Sanitization can cause routing collisions and unnecessarily rewrites valid hyphens.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Sanitizes Python handoff tool names while preserving original agent IDs for routing.
Changes:
- Replaces unsupported characters with underscores.
- Adds regression and middleware-routing tests.
| File | Description |
|---|---|
_handoff.py |
Adds handoff tool-name sanitization. |
test_handoff.py |
Tests sanitization and original-ID routing. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Suhas Aggarwal (suhasagg)
temporarily deployed
to
github-app-auth
October 5, 2026 12:29 — with
GitHub Actions
Inactive
Member
|
Suhas Aggarwal (@suhasagg) Thanks for the contribution. This implements the same change as #9035, so we'll continue the work there and close this duplicate. |
This branch was previously deployed
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.


Summary
Fixes #9034.
Handoff tool names were generated directly from the target agent ID. When an agent name contained spaces or other characters that are invalid in provider function/tool names, the generated handoff tool name could also be invalid.
For example:
Billing Agent→handoff_to_Billing AgentThis change sanitizes non-alphanumeric/non-underscore characters when generating handoff tool names:
Billing Agent→handoff_to_Billing_AgentThe original target ID is preserved for handoff routing. Only the generated tool/function name is sanitized.
Changes
get_handoff_tool_name().Testing
test_handoff.py: 42 passed, 6 skipped.git diff --check: passed.