Skip to content

Accept transfer_to_number tools that use transfer_rules - #940

Merged
PaulAsjes merged 2 commits into
mainfrom
pma/transfer-rules
Nov 23, 2026
Merged

PaulAsjes merged 2 commits into
mainfrom
pma/transfer-rules

Conversation

@PaulAsjes

Copy link
Copy Markdown
Collaborator

Summary

A transfer_to_number tool can hold per-provider transfer_rules instead of transfers; the API takes exactly one of the two. The tools-as-code builder rejected a pulled rules-only tool as no_transfers, so it couldn't be loaded and written back. Now such a tool is valid, its rules are kept exactly as loaded, and a tool with both lists is a new conflicting_transfers error.

Details
  • no_transfers fires only when neither transfers nor transfer_rules has entries. The API requires the transfers key, so a pulled rules tool carries "transfers": [], which is written back as loaded.
  • transfer_rules is load-only: there is no builder method for it. Rules are nested per-provider unions (Twilio, SIP trunk, Exotel, each with two transfer modes), which would be a large surface to add in all eight SDKs for a field the API describes as an alternative form.
  • conflicting_transfers: transfer() on a loaded rules tool (or a loaded config with both) would otherwise produce a config the API rejects.
  • New shared fixtures: 22-transfer-rules.json (byte-identical round trip of a rules tool) and 23-errors-conflicting-transfers.json.
  • Mirrors the elevenlabs-js reference; fixtures vendored unchanged.
  • Coordinated change across all SDKs (found by Cursor Bugbot on Add the agent tools-as-code builder elevenlabs-go#11): elevenlabs/elevenlabs-js, elevenlabs/elevenlabs-python, elevenlabs/elevenlabs-php, elevenlabs/elevenlabs-ruby, elevenlabs/elevenlabs-dotnet, elevenlabs/elevenlabs-rust, plus commits on Add the agent tools-as-code builder elevenlabs-go#11 and Add the agent tools-as-code builder elevenlabs-java#9.

Testing

  • pytest tests/agent_tools: 90 passed. ruff check and ruff format --check clean.
  • Output for fixture 22 byte-identical to elevenlabs-js.

🤖 Generated with Claude Code

Mirrors elevenlabs-js: no_transfers only when neither transfers nor a
loaded transfer_rules has entries, loaded rules kept as loaded, and a new
conflicting_transfers error when both are set. Vendors fixtures 22 and 23.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PaulAsjes
PaulAsjes marked this pull request as ready for review November 20, 2026 08:18
@cursor

cursor Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Scoped to SystemTool transfer validation and error codes for load/build round-trips; no auth or runtime behavior changes.

Overview
Transfer validation now treats transfer_to_number tools with only transfer_rules (and an empty transfers list) as valid, so API-loaded rules-based configs round-trip through Tool.from_json() and build() without a spurious no_transfers error. transfer_to_agent still requires non-empty transfers; transfer_rules do not satisfy that requirement.

A new conflicting_transfers validation error is raised when both transfers and transfer_rules are present (e.g. calling transfer() on a loaded rules-only tool), matching the API’s mutual-exclusion rule.

Tests and shared JSON fixtures cover the happy path round-trip and the conflict case.

Reviewed by Cursor Bugbot for commit 68c9731. Bugbot is set up for automated code reviews on this repo. Configure here.

transfer_to_agent has no transfer_rules, so a loaded one no longer lets an
agent transfer skip no_transfers. Adds tests that an agent transfer with
rules is no_transfers and that build() sends loaded rules in the request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PaulAsjes
PaulAsjes merged commit 4d80084 into main Nov 23, 2026
6 checks passed
@PaulAsjes
PaulAsjes deleted the pma/transfer-rules branch November 23, 2026 11:46
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.

2 participants