Part 5 of 6 · 2 min read
Exercises
Easy
Easy 1: Run it and read the table (30 minutes)
In code/mini-subagents, run pytest -q, python run_all.py.
Done when: you report parent tokens, total tokens and correctness for single_all, sub_last_message and sub_structured, and say why sub_last_message is cheap and wrong.
Hint
agents.table() returns the rows used in the notes.
Easy 2: Count a context (30 minutes)
Use agents.sizes_of on one sub-task and print the context size before each call.
Done when: you show the sizes grow with every step and compute the sub-task's total with cost_of_run.
Hint
W.make_task(0)[0][0].messages is one sub-task.
Easy 3: Find the injection (30 minutes)
Print the handoff of sub-task 3 under each strategy.
Done when: you list which strategies carry the injected line and which do not, and say why.
Hint
agents.handoff(sub, strategy).
Medium
Medium 1: Break-even (2 hours)
Sweep SYSTEM from 500 to 20,000 and steps per sub-task from 3 to 40.
Done when: you plot where sub-agents stop paying off and explain the role of the system prompt size.
Hint
change agents.SYSTEM and pass steps= to agents.run.
Medium 2: A better failure contract (2 hours)
Make one sub-agent fail (return nothing useful) and add a status field to the typed result.
Done when: you show the parent detecting the failure in the typed strategy but not in the last-message strategy.
Hint
add a field in structured_result; make a task with no finding line.
Medium 3: Pointer results (3 hours)
Let each child write its full trace to a file (module 5) and return only a path plus the typed result.
Done when: you show the parent can fetch the trace on demand and report the extra tokens when it does.
Hint
write the messages to a temporary file and return its name.
Hard
Hard 1: Real models (4 hours)
Run the four sub-tasks with a real model as one agent and as sub-agents, for two result strategies. (I did not run this, so your numbers are the ground truth.)
Done when: you report accuracy, usage-field tokens per strategy, the model and the date, and say whether the simulation's ranking held.
Hint
compare the final answer to the planted values.
Hard 2: Isolation plus caching (4 hours)
Combine this module with module 7: give all children the same system prompt and tool block and model one shared cache. (I did not run this.)
Done when: you report cost with and without the shared prefix and say what happens if one child reorders its tools.
Hint
reuse PrefixCache from module 7 with identical system segments.
Hard 3: Adversarial result (5 hours)
Make a child return a schema-valid result whose caveat field contains an instruction. (I did not run this.)
Done when: you show the parent obeying it, add one mitigation (type restriction, length limit, or a second check), and report what it still misses.
Hint
put the instruction in the field text and look at what the parent does with it.