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>
This commit is contained in:
OpenCode Test
2025-12-31 21:35:32 -08:00
parent 690c57caeb
commit d9332ae118
5 changed files with 446 additions and 1 deletions

53
mcp/delegation/README.md Normal file
View File

@@ -0,0 +1,53 @@
# 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) |