Files
claude-code/mcp/delegation/README.md
OpenCode Test d9332ae118 Add tiered model delegation for gmail operations
Implements cost-efficient gmail operations by delegating to appropriate
model tiers via Claude CLI subprocess. Simple fetches use no LLM,
summarization and triage delegate to Sonnet, complex reasoning stays
with Opus (PA). Uses subscription instead of API key.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 21:35:32 -08:00

54 lines
1.6 KiB
Markdown

# Model Delegation Helper
Spawns lower-tier Claude models via Claude CLI using your subscription.
## Setup
**No API key needed!** Uses Claude CLI with your existing subscription.
Requirements:
- Claude CLI at `/home/linuxbrew/.linuxbrew/bin/claude`
- Active Claude subscription (Pro/Max)
## Usage
### Gmail operations (tiered)
```bash
PY=~/.claude/mcp/gmail/venv/bin/python
HELPER=~/.claude/mcp/delegation/gmail_delegate.py
# Haiku tier - just fetch and list (no LLM call)
$PY $HELPER check-unread --days 7
# Sonnet tier - fetch + summarize (uses claude CLI)
$PY $HELPER summarize --query "from:github.com"
# Sonnet tier - urgent triage (uses claude CLI)
$PY $HELPER urgent
```
## Model Tiers
| Tier | Model | LLM Call | Use For |
|------|-------|----------|---------|
| haiku | (none - just fetch) | No | List, count, group emails |
| sonnet | claude --model sonnet | Yes | Summarize, categorize, triage |
| opus | (PA direct) | N/A | Complex reasoning, prioritization |
## How It Works
1. **check-unread**: Fetches emails via Gmail API, groups by sender. No LLM needed.
2. **summarize**: Fetches emails, then spawns `claude --print --model sonnet` to summarize.
3. **urgent**: Fetches flagged emails, spawns Sonnet to triage by urgency.
## Integration with PA
The Personal Assistant (Opus) delegates gmail operations:
| User Request | Delegation | Model Used |
|--------------|------------|------------|
| "Check my email" | `check-unread` | None (fetch only) |
| "Summarize X emails" | `summarize` | Sonnet via CLI |
| "What's urgent?" | `urgent` | Sonnet via CLI |
| "What should I prioritize?" | (direct) | Opus (PA) |