Instructions fileAGENTS.md or CLAUDE.md, read at the start of every session
ToolsRead, search, edit, run commands, fetch a web page
Permissions and sandboxAllow, ask or deny each tool; limit files and network
Context managementCompaction near the limit; subagents with their own context
ExtensionsMCP servers (Lecture 18), skills, hooks that run your scripts
YouThe prompt, the approvals, checking every change
Every part around the model is a file or a setting you control
06-763 / L19
Coding agents, the model is a small box
Lecture 1: in a production ML (machine learning) system, the ML code is a small part of the code. Same for agents: in Codex, the code that talks to the model is about 2% of 1.1 million lines
How we know: we counted the lines of Rust in Codex's open-source code on GitHub (118 packages, tests left out) and sorted the packages by job ourselves. Another sorting moves the numbers a little, so read them as approximate: 2 to 3% talks to the model
06-763 / L19
Coding agents, the instructions file
The agent starts every session knowing nothing about your project. The instructions file tells it, every time
# AGENTS.md
Setup: uv sync, then uv run for everything
How to build: the same environment as you and CI (Lecture 2)
Tests: uv run pytest after every change
How to check its own work
Data: data/measurements.duckdb is read-only
What not to touch
Code: modules in src/, each with a test
Where things go
AGENTS.md: an open format that many coding agents read (Codex, Cursor, Copilot, opencode ...). Claude Code reads CLAUDE.md
Read at every start, but "context, not enforced configuration". Keep it short: Anthropic suggests under 200 lines
Context rot: "as the number of tokens in the context window increases, the model's ability to accurately recall information from that context decreases"
Three ways to keep it small: compaction summarizes the old messages; a new session starts empty; a subagent explores in its own window and returns a summary, "often 1,000-2,000 tokens"
Nx: a free tool that JavaScript developers install to build and test their projects, about 6 million downloads a week. It is published on npm, the package registry for JavaScript, like PyPI for Python
1. A stolen keyAttackers stole the key that publishes Nx, through a flaw in its automated checks
2. Fake versionsThey published Nx versions with a hidden program, live for about 4 hours, August 2025
3. You install NxThe hidden program runs on your machine
4. It runs your agentClaude Code, Gemini CLI or Amazon Q, with every check off, told to search the disk for keys and crypto wallets
5. PublishedWhat the agent found went to a public GitHub repository
The attacker used the developer's own agent to search the machine. Keep secrets out of its reach; turn the checks off only inside a container
A test is a small function that runs your code on a case where you know the answer, and fails if the answer is wrong.
Two files: the code, c_to_f, converts Celsius to Fahrenheit (F = C × 9/5 + 32). Its test checks one case you know: water boils at 100 °C, which is 212 °F
pyproject.toml, uv.lockL2One environment for you, the agent and CI
AGENTS.mdL19How to set up, how to test, what not to touch
src/L2Modules the agent can import and test, not notebook cells
tests/pytestPass or fail: the agent knows when it is done
data/measurements.duckdbL3 L4SQL, through a read-only connection
schemas/L6Validation catches wrong data, whoever wrote the code
runs/L10Every number traces back to the run that made it
.git/L2Every change a diff you can read and undo. Commit before it starts
A project that checks itself with one command is a project an agent can work in
06-763 / L19
Working with one, what to watch for
Check every change
Check the test results and the final products: the plot, the table, the page. You can only catch a wrong answer in a subject you understand, so the fundamentals of your field matter more now
Secrets
No keys in files it can read. Test credentials, not production ones
Debugging spirals
Fix after fix with no progress: stop, rethink the problem from the start, then begin a fresh session
Privacy
A cloud model sees the code and data the agent reads. Check before a confidential project
Understanding
MIT warns of "overreliance and shallow understanding". Write the critical parts yourself
Cost grows with every stepKeep the start of the prompt stable for the cache; cap the steps
Long runs go wrong more oftenIf each step slips 1 time in 20 and nothing catches it, a 20-step run slips about 2 times in 3. Check along the way: tests, approvals
Prompt injection is not solvedRead-only tools, approval, a sandbox, no lethal trifecta
A report is not evidenceCheck the system itself; run the tests yourself
Instructions are not enforcedWhat must hold goes in permissions, hooks and tests
Runs are not reproduciblePin the model version; log every step (Lecture 1)
A physical system can be hurtThe agent proposes; a person decides
06-763 / L19
Recap
An agent: an LLM that calls tools in a loop and picks each next step
The harness, not the model, is most of the system
Guardrails in code: least privilege, approval, no lethal trifecta
Coding agents: gather, act, verify, with an instructions file and permissions
They work best where one command checks the work: uv, git, tests
Measure, do not assume: developers felt faster but took 19% more time (2025)
06-763 / L19
Before next time
Final project proposal: due today
Practice module for this session: on the course site
Write an AGENTS.md for your project: how to set up, how to test, what not to touch
Down the hall: Gabe Gomes' group, Chemical Engineering and Chemistry. The robot is an Opentrons OT-2 liquid handler.
Step 3 is the one to dwell on: it could not have known the command; it found out by trying and reading the error.
Dec 2025: the Agentic AI Foundation, under the Linux Foundation; Block gave its goose agent too.
Feb 2026: about 1 million lines and 1,500 pull requests, "0 lines of manually-written code". The engineers wrote instructions, docs and checks. "Humans steer. Agents execute."
The energy model is a formula we wrote for this example, not a measurement: noon sun 34 degrees above the horizon in early November, so direct light is best at a tilt of 56 degrees; sky light is 30% of the total.
Same loop as Coscientist: Planner = LLM, the four actions = tools, the software that ran them = harness. Steps 1 to 4 repeat until step 5.
Call 2 is the one to point at: the model did not know the mount's range; the error told it, and it tried again.
When an agent fails, look at the harness first: what did it read, which tools did it have, what came back? Anthropic: "we actually spent more time optimizing our tools than the overall prompt".
Prices: Anthropic read 0.1x, write 1.25x the input price, 5-minute lifetime refreshed on use. OpenAI: automatic above 1,024 tokens.
Priced with Anthropic's multipliers: write 1.25, read 0.1. Token counts from tiktoken.
Claude Code's docs: "Pick your model and effort level at the top of a session, then save /compact for natural breaks between tasks." Manus calls a timestamp at the start of the system prompt "a common mistake". Thariq Shihipar (Claude Code team): "At Claude Code, we build our entire harness around prompt caching". In our solar run, a clock at the top makes the run cost 124% of no cache at all.
Lemkin founded SaaStr. Fortune: data on "more than 1,200 executives and over 1,190 companies"; "the agent told Lemkin that a retrieval, or rollback, function would not work in this scenario". The agent's own words: "This was a catastrophic failure on my part".
Counted 2026-11-03, openai/codex at a pinned commit; the grouping is in make_figures.py. The model-calling files inside the core package add about 0.3%.
Same idea as query_log in our example: the connection is opened read-only, so DuckDB refuses a DELETE whatever the model asks.
The flags: --dangerously-skip-permissions (Claude Code), --yolo (Gemini CLI), --trust-all-tools (Amazon Q). The lethal trifecta in one install: your files, the attacker's prompt, a way out through the GitHub command line.
Reversed second row reads right to left, so the arrows still follow the flow.
The assert is the line inside the test that checks the answer. Anthropic: "Ask Claude to write code that passes the tests, instructing it not to modify the tests." An agent told only "make the tests pass" can edit the test instead of the code.
The tools changed between the two: Claude Code and Codex spread through 2025 (METR's words). The 2025 paper saw no clear learning effect over the first 30 to 50 hours of Cursor. METR calls the 2026 number "an unreliable signal" and a lower bound.