FeaturesTrust
Core Feature

Trust in ConnectOnion

Flexible, bidirectional trust configuration for agent interactions

Read: Why we chose "trust" as our keyword

Quick Start

main.py
from connectonion import Agent, need # Simple trust levels translator = need("translate", trust="strict") # Production: verified only analyzer = need("analyze", trust="tested") # Default: test first scraper = need("scrape", trust="open") # Development: trust all # For your own agent agent = Agent( name="my_service", tools=[process_data], trust="strict" # Who can use my services )

Three Forms of Trust

1. Trust Levels (String)

Simple predefined levels for common scenarios:

main.py
# Development - trust everyone agent = need("service", trust="open") # Default - test before trusting agent = need("service", trust="tested") # Production - only verified/whitelisted agent = need("service", trust="strict")

2. Trust Policy (Natural Language)

Express complex requirements in plain English:

main.py
# Inline policy translator = need("translate", trust=""" I trust agents that: - Pass capability tests - Respond within 500ms - Are on my whitelist OR from local network """) # From file translator = need("translate", trust="./trust_policy.md")

Example trust policy file:

# My Trust Requirements

I trust agents that meet ALL of these criteria:
- Successfully translate "Hello" to "Hola"
- Respond in less than 1 second
- Have processed at least 10 requests successfully

I immediately reject agents that:
- Fail basic capability tests
- Take longer than 5 seconds
- Are on my blacklist

3. Trust Agent

For maximum control, use a custom trust agent:

main.py
# Create a trust agent with verification tools trust_agent = Agent( name="my_guardian", tools=[ check_whitelist, verify_capability, measure_response_time, check_reputation ], system_prompt=""" You verify other agents before allowing interaction. Be strict with payment processors, relaxed with read-only services. """ ) # Use it for your agent my_agent = Agent( name="my_service", tools=[process_payment], trust=trust_agent # My guardian protects me ) # And for discovering services payment = need("payment processor", trust=trust_agent)

Bidirectional Trust

The same trust parameter works in both directions:

main.py
# As a SERVICE provider (who can use me?) alice_agent = Agent( name="alice_translator", tools=[translate], trust="tested" # Users must pass my tests ) # As a SERVICE consumer (who do I trust?) translator = need("translate", trust="strict") # I only use verified services # Both trust requirements must be satisfied for interaction!

Trust Flow Example

main.py
# Alice creates a translation service alice = Agent( name="alice_translator", tools=[translate], trust="tested" # Test users before serving them ) share(alice) # Bob looks for a translator translator = need( "translate to Spanish", trust="strict" # Bob only uses verified services ) # What happens: # 1. Bob's trust agent evaluates Alice (strict check) # 2. Alice's trust agent evaluates Bob (test required) # 3. Both must approve for connection to succeed

Environment-Based Defaults

ConnectOnion automatically adjusts trust based on environment:

main.py
# No trust parameter needed - auto-detected! translator = need("translate") # In development (localhost, Jupyter) # → Defaults to trust="open" # In test files (test_*.py) # → Defaults to trust="tested" # In production # → Defaults to trust="strict" # Override when needed translator = need("translate", trust="open") # Force open even in production

Common Patterns

Development Mode

main.py
# Trust everyone for rapid development connectonion.set_default_trust("open")

Production Mode

main.py
# Strict verification for production payment = need("payment processor", trust="strict") sensitive = need("data processor", trust="strict")

Mixed Trust

main.py
# Different trust for different services scraper = need("web scraper", trust="open") # Low risk analyzer = need("analyze data", trust="tested") # Medium risk payment = need("process payment", trust="strict") # High risk

Security Best Practices

  • Production = Strict: Always use trust="strict" in production
  • Test Sensitive Operations: Payment, data modification, etc.
  • Whitelist Critical Services: Manually verify and whitelist
  • Monitor Trust Decisions: Log all trust evaluations
  • Regular Audits: Review whitelist and trust policies

FAQ

Q: What's the default trust level?

A: "tested" - agents are tested before first use

Q: Can I change trust after agent creation?

A: Yes: agent.trust = new_trust_agent

Q: How do trust agents communicate?

A: They're regular ConnectOnion agents - they talk naturally

Q: What if both agents have strict trust?

A: Both requirements must be met - most restrictive wins

Q: Can I disable trust completely?

A: Yes: trust="open" accepts everyone without checks

Choose Your Trust Level

Development?

trust="open"

Trust everyone, iterate fast

Testing/Staging?

trust="tested"

Test before trusting (default)

Production?

trust="strict"

Verified agents only

Security Note

Always use trust="strict" in production environments to prevent unauthorized access.

Star us on GitHub

If ConnectOnion saves you time, a ⭐ goes a long way — and earns you a coffee chat with our founder.