I wrote this note after class, at the students’ request. Most of the session was a live demo, so the note is a record of the steps we went through. I planned the stages before class. The log of every tool call, at the end, came from the students: they asked for it during class, and we added it live.
PowerCycles is the gas-turbine cycle code I write in Julia. In the session I built an agent setup for it one piece at a time. I used pi, the coding agent we use in this course. You ask an engine question in plain English. An analyst subagent writes and runs a PowerCycles script. Then it sends back the numbers with units, the values it assumed, and the path to the script.
A month and a half ago, I do not think a plain agent could have answered these questions correctly. Today it can. It reads the files, finds the right parts of the code, and runs it. So the setup in this note is not there to make the answers correct. It gives me answers that I can reproduce, in a form I expect. And when the agent uses the tools, I know what it did with my code.
The prompt at every stage
This is the prompt we use at every stage. It asks for the design point of a turbojet engine:
What are the thrust and TSFC of a turbojet with compressor pressure ratio 15 and turbine inlet temperature 1650 K, sized for 40 kN at Mach 0.85 and 33,000 ft?
| Stage | What I add | What the agent does |
|---|---|---|
| 0 | Nothing. A plain agent with read, bash, edit and write | The agent reads the README and examples/turbojet.jl, works out the standard atmosphere by hand, writes a script to /tmp, and starts a fresh Julia to run it. The answer is right. |
| 1 | Two tools: standard_atmosphere and run_julia | The agent now writes a script that uses these tools. run_julia saves the script in demo/runs/ and runs it on a Julia process that is already running, with PowerCycles loaded. |
| 2 | A skill with the workflow and the answer format | The agent loads the skill first and answers in four parts: the answer, the engine and condition, the script path, and what was not checked. |
| 3 | The analyst subagent, in .pi/agents/analyst.md | With “Use the analyst subagent” in the prompt, the main session sends the work to the analyst. Without that sentence, the main session does the work itself with bash. |
| 4 | One rule in AGENTS.md: send every analysis request to the analyst | The main session sends the work to the analyst without being told. |
At every stage the agent reports a thrust of kN, which is the sizing target, kg/(N·s) (1.261 lb/(lbf·h)), and an air mass flow of kg/s. I saw the same thing in rehearsal the night before, in 45 runs with Opus, Sonnet and Haiku. All 45 were correct, including Haiku with no setup at all. The README and the example files are good enough that a plain agent copies the pattern and gets it right.
What each piece changes
None of the pieces were needed for a correct answer to this prompt. They change how the work happens.
- Tools. A fresh Julia takes about 22 s to load PowerCycles before it can solve anything. The Julia process behind
run_juliais already running, and it solved the design point in 0.47 s. In rehearsal one plainbashcall hung for 888 s, and two plain agents wrote to the sametj_throttle.jl. Withrun_julia, each script gets its own file and a time limit, so every number in an answer traces back to one saved script. - Skills. I wrote the procedure down once in the skill, so the agent does not work it out again in each session. Every answer also comes back in the same four parts. In rehearsal the analyst once converted TSFC by hand and reported a value ten times too large. After that run I added a rule to the skill that every unit conversion happens inside the script.
- Subagents. The analyst has no
edit,writeorbashtool. It can build engines from library components but cannot change the components, and the only way it can run code isrun_julia. In rehearsal, when Opus did the work itself, the main session took in 12 to 26 thousand characters per request. With the analyst it took in 2 to 5 thousand, so its context grows more slowly. AGENTS.md. A definition in.pi/agents/analyst.mdwas not enough to make pi use the analyst. The main session sent work to the analyst on its own only after I added the one-line rule.
Some things we tried
After stage 4 we kept going in the same session with a few more prompts.
Sweep the pressure ratio from 8 to 30 and plot it. The analyst built a new engine for each value, because a design sweep needs one per point, and all 23 points converged. TSFC falls the whole way, from 39.11 to 32.65 mg/(N·s). Specific thrust peaks near a pressure ratio of 12. The analyst also pointed out that the model has no limit on compressor-exit temperature, so the sweep cannot show a practical best pressure ratio.
Compare it with a turbofan sized for the same thrust. The analyst started from examples/separate_flow_turbofan.jl, with a bypass ratio of 5 and a fan pressure ratio of 1.754. At the same 40 kN and K, the turbofan burns about 37% less fuel per unit thrust and needs about 3.8 times the airflow. The weight and drag of the larger fan are not in the model, and the analyst’s answer said so.
Add an intercooler and a recuperator. PowerCycles has neither. The analyst checked the duct and the mixer, found that neither one moves heat, and stopped. It could have faked an intercooler with a duct and a hand-set temperature drop. It did not, because those numbers would only look like PowerCycles output. Writing a new component is my job as the component author, and the analyst has no way to edit the library.
A request from the room: a log of every tool call
The students suggested a way to improve the setup. They asked for a log of every tool call the analyst makes, with its input and output. With that log, anyone can check afterwards what the analyst did. We added the log during class. I asked pi to write it, and pi wrote a small extension, logging/tool-log.ts, that loads only into analyst sessions. Each analyst run leaves one TOML file in demo/runs/logs/ with every tool call, its input, its output and its timing. For run_julia the log keeps the paths to the script and its output instead of copying the code. This is the entry for the design-point run in the figure at the top of the page.
[[call]]
seq = 4
tool = "run_julia"
duration_ms = 470
julia_status = "ok"
script = "runs/20261110-153957-turbojet-design-point.jl"
script_output = "runs/20261110-153957-turbojet-design-point.out"
[call.input]
purpose = "turbojet design point"
With the log and the saved scripts, I can check the analyst’s numbers later without rerunning anything.
If you try this on your own code
Start with an agent that has no setup, and look at what it gets wrong before you add anything. If your README has a runnable first example, that agent may already get the right answer. In that case, add a piece only when it makes the runs reproducible, gives the answer a form you can check, or takes away permissions the agent does not need. If your code has no runnable example, writing one may help more than any skill.