from upsonic import Agent, Task
from upsonic.safety_engine.policies.phone_policies import AnonymizePhoneNumbersPolicy
# Create agent with phone number anonymization
agent = Agent(
"anthropic/claude-sonnet-4-5",
user_policy=AnonymizePhoneNumbersPolicy, # Prevents phone numbers from leaking to LLM Providers
debug=True # Enable debug to see policy application
)
# User input with phone number
task = Task(
description="My Number is: +1-555-123-4567. Tell me what is my number."
)
# Execute with automatic anonymization and de-anonymization
# What happens under the hood:
# 1. Input: "My Number is: +1-555-123-4567. Tell me what is my number."
# 2. Anonymized (sent to LLM): "My Number is: PHONE_1. Tell me what is my number."
# 3. LLM Response: "Your number is PHONE_1"
# 4. De-anonymized (returned to you): "Your number is +1-555-123-4567"
#
# Result: Phone number never reaches the cloud, but you get fully functional results!
result = agent.do(task)
print(result) # Returns: "Your number is +1-555-123-4567"