# OpenAI Swarm Email Delegation: Coordinating Specialist Sub-Agents with Scoped Keys

_By Tayyab Mughal, Founder & AI Chief · 23 August 2026 · 2 min read_

> Designing lightweight multi-agent swarms using OpenAI Swarm patterns with dedicated triage, drafting, and sender routines.

Learn how to implement lightweight multi-agent delegation routines using OpenAI Swarm patterns to isolate email credentials and enforce permission boundaries.

## Lightweight agent handoffs vs heavyweight frameworks

OpenAI Swarm introduces a minimalist pattern for multi-agent coordination centered on stateless routines and function-based handoffs.

Instead of passing global credentials to a monolithic agent, Swarm allows a Customer Triage Agent to hand off execution to a dedicated Outbound Email Agent that alone holds scoped sending permissions.

## Implementing the Swarm Handoff Pattern

Here is how to structure a triage agent that inspects customer questions and transfers control to an email agent with allowlist validation.

```python
from swarm import Swarm, Agent
import requests
import os

client = Swarm()

def send_transactional_email(to_email: str, subject: str, message: str) -> str:
    """Dispatches email via SadaSend scoped credentials."""
    res = requests.post(
        "https://api.sadasend.com/v1/emails",
        headers={"Authorization": f"Bearer {os.getenv('SADASEND_AGENT_KEY')}"},
        json={"to": to_email, "subject": subject, "text": message}
    )
    return "Dispatched" if res.status_code == 200 else f"Failed: {res.text}"

# Dedicated Outbound Specialist
email_agent = Agent(
    name="Outbound Email Agent",
    instructions="You are a dedicated sender. Format the email clearly and call send_transactional_email.",
    functions=[send_transactional_email]
)

def transfer_to_email_agent():
    """Handoff function for triage agent."""
    return email_agent

# Front-line Triage Agent (No email execution tools)
triage_agent = Agent(
    name="Triage Agent",
    instructions="Determine if the user requires an email notification. If yes, transfer to Outbound Email Agent.",
    functions=[transfer_to_email_agent]
)

response = client.run(
    agent=triage_agent,
    messages=[{"role": "user", "content": "Please send a confirmation email to sam@partner.io about project launch."}]
)
print(response.messages[-1]["content"])
```

## Security isolation benefits

- Triage and reasoning agents never hold API secrets in their context window.
- Tool execution is localized to leaf agents with explicit allowlists.
- Zero bloat: Python execution finishes in milliseconds without heavyweight background daemons.

---

_Tags: OpenAI Swarm, Python, Multi-Agent, Architecture_
