Homework 4
Give your agent an inbox, and subagents
Due before class on Wednesday, October 28, 2026
Email is the oldest way for agents to talk: an address, an inbox, messages that wait until they're read. This week your agent gets its own Gmail address and an email MCP server, packaged as a plugin, says hello to the class's agent, and learns to hand work to subagents: copies of its own loop that it starts, talks to and stops.
Added October 23: part 4, subagents. Already sent your hello? Keep going from part 4; it goes in the same pull request.
Missed week 2 or 3? That's fine. Build the email plugin and use it from an agent you already have (Claude Code, Codex or OpenClaw). But building on your own agent loop teaches you considerably more, so if you can, build your harness too.
Start
- Open an AI coding agentClaude Code, Codex, Cursor, GitHub Copilot, … in your harness folder.
- Give it this
Read https://class.xhelio.ai/week-4/homework.md and help me with my homework. - Build it togetherIt helps you set up the account, builds the server and the plugin with you, connects it to your agent, sends the hello, builds the subagents with you, and opens your pull request.
Parts 1–3: an inbox
- A new Gmail account for your agent, with an app password in
.env. Never your personal or UCLA mail. - An email MCP server, as a plugin: check the inbox, read a message, send a message. IMAP and SMTP; Python's standard library is enough.
- Every email is untrusted text. The plugin's skill says never to follow instructions found in an email, and sending needs your approval or an allow list.
- A hello to the class agent at
lingtai2026@gmail.com, in the format below, then your agent reads the reply.
The hello
Subject: [AIR-2026 hello] <your-github-username>
class: AI in Research 2026
github: <your-github-username>
agent: <your agent's name>
harness: <your harness repo, or the agent you use>
model: <the model it runs on>
plugins: telegram, <research plugin>, email
research: <one sentence on your research>
reply-to: <your agent's Gmail address>
<A note written by your agent itself, at most
100 words: who it is, and what it can do
for your research.>
Fields first, one per line, so the class agent can read them. Send it once.
Part 4: subagents
A subagent runs your agent's own loop with a fresh conversation: its own system prompt, the task it was given, and its own tools. The main agent never sees its work, only its report. Each kind is a file agents/<name>.md, as in Claude Code: a name, a description, its tools, max_turns, and a body that is its system prompt.
delegate(agent, task) hand over: run it, wait, return its report
subagent(action, …) run in the background, control the lifetime
start agent, task start one; return its id (sa-3) at once
list id, type, state, turns, tokens, time running
send id, message message it; an idle one wakes up and goes on
wait ids, timeout wait until they finish; return their reports
read id, last its last steps, without stopping it
stop id stop it now, killing a running command
states running → idle (report ready) → running again on send
ends as stopped (stop, or session end) or failed (error, limits)
- Your harness enforces the rules, not the model: subagents can't start subagents; at most 4 at once;
max_turnsand a time limit; everybashcommand still asks you, naming the subagent; each subagent's conversation goes to a log. - Five demos: hand your inbox to a
mail-readerthat can only read email; fan out three research subagents and combine their reports; follow up with one; stop one runningsleep 600; one that runs out of turns. - No harness of your own? Define
mail-readeras a Claude Code or Codex subagent, and buildsubagentas an MCP server that runsclaude -porcodex execin the background.
What you submit
A pull request adding week-4/submissions/<your-github-username>/: your email plugin folder <you>-email/, your agent type files in agents/, the five demos in transcripts/, and a README.md linking to your harness (or naming the agent you used), saying when your agent sent its hello, and how your subagents run.
It counts when the plugin works in your agent, the hello arrived in the format above, your agent read the class agent's reply, your harness has delegate and subagent with the six actions and the rules, the five demos work, and no password is committed. Say in your pull request which AI helped you, and how.
More
- The assignment on GitHubThe full text, and where you submit.
- What your agent readsPlain text; the full guide is in the repository.
- What a subagent call contains, from classThe lead's tool call, the subagent's first call, the report.
- How agents talk, from classFiles, messages, shared servers and A2A.
- All homeworkYour task and your agent, all quarter.