Skip to main content

What is Phone Number Policy?

Phone number policies specifically detect and anonymize phone numbers in various formats (US, international, etc.).

Why its Important?

Phone number policies are essential for protecting user privacy and preventing phone numbers from being exposed through AI interactions. These policies prevent phone numbers from being sent to LLMs, which helps maintain user privacy and protects against spam, harassment, and identity theft.
  • Prevents sending phone numbers to LLM: Blocks phone numbers from being processed by language models, protecting user contact information
  • Protects user privacy: Prevents phone numbers from being exposed to third-party LLM providers or stored in training data
  • Reduces spam and harassment risk: Anonymizes phone numbers to prevent them from being used for unwanted communications

Usage

from upsonic import Agent, Task
from upsonic.safety_engine.policies import AnonymizePhoneNumbersPolicy

# Anonymize just phone numbers in agent output
agent = Agent(
    model="openai/gpt-4o",
    user_policy=AnonymizePhoneNumbersPolicy,  # This policy anonymizes phone numbers in agent responses
    debug=True,
    print=True
)

task = Task("My Number is: +1-555-123-4567. Tell me what is my number.")
result = agent.do(task)
print(result)
# Expected: Phone number before fed in agent should be anonymized (e.g., "+X-XXX-XXX-XXXX" format with random digits)

Available Variants

  • AnonymizePhoneNumbersPolicy: Pattern-based detection and anonymization
  • AnonymizePhoneNumbersPolicy_LLM_Finder: LLM-powered detection for better accuracy