Homework 2
Build your own agent
Due before class on Wednesday, October 14, 2026
In class we took an agent apart: a loop of API calls, where a tool call is just text your program acts on.
This week you build that loop yourself: a small program, a harness, that chats with you and runs
shell commands. It has exactly one tool, bash. Over the coming weeks it grows: more tools, MCP servers,
skills, other agents.
Your AI coding agent writes most of the code with you. You make the decisions, and by the end you can point at the loop and explain every step.
Start
- Open an AI coding agentClaude Code, Codex, Cursor, GitHub Copilot, … in a folder under your home directory.
- Give it this
Read https://class.xhelio.ai/week-2/homework.md and help me with my homework. - Build it togetherIt helps you get a model API, builds the harness with you step by step, tests it, publishes it on GitHub, and opens your pull request.
Your harness
- Talks to a model through an OpenAI-compatible API. Base URL, key and model come from environment variables, never the code.
- Runs the agent loop from class: tool call → run it → send the result → call again; text → show it and wait for you.
- Has one tool,
bash, with a time limit, returning the output and exit code. - Asks you before each command. Saying no tells the model you declined.
- Chats with you in a local web page (recommended) or the terminal.
- Shows each call's tokens: input, cached input, output.
Write the loop yourself: no agent frameworks. A few hundred lines is plenty.
A model API
- Your subscription, with sub2api (recommended)Runs on your computer and serves a subscription you already pay for as an API only you use.
- OpenRouterOne key, hundreds of models. Free models allow 50 requests a day, or 1,000 after buying $10 of credits.
- Any OpenAI-compatible keyOpenAI, Gemini, DeepSeek, … all work.
sub2api can get your account banned. Using a subscription this way may break your provider's terms. OpenAI's Codex lead said in August 2026 that many users flagged by their fraud-prevention systems were using sub2api; Anthropic's and Google's terms also forbid it. If you use it: your own account only, on your own computer, never shared or reachable from the network. Rather not risk it? Use OpenRouter.
What you submit
A pull request adding one file, week-2/submissions/<your-github-username>/SKILL.md: a skill that tells an AI agent how to install your harness from its public repository, configure it, run it, and check that it works.
It counts when the repository is public, the skill works on a fresh computer, and the harness does everything on the list. Say in your pull request which AI helped you, and how.