6.2.8 · D3AI Agents & Tool Use

Worked examples — Code-generation agents

2,741 words12 min readBack to topic

Before any symbol appears, one reminder in plain words:


The scenario matrix

Every case this topic can throw at you falls into one of these cells. The worked examples below are tagged with the cell they hit, and together they fill every row.

# Case class What's special about it Covered by
A Ordinary interior value , small Ex 1
B Large- / limiting behaviour , what does approach? Ex 2
C Degenerate low: agent never succeeds — no amount of iteration helps Ex 3
D Degenerate high: agent always succeeds — one try is enough Ex 3
E Inverse question given a target , solve for required Ex 4
F pass@k from raw counts small — exact combinatorics, edge and Ex 5
G Real-world word problem budget/cost trade-off, units of dollars & minutes Ex 6
H Exam twist: broken independence why naive formula over-counts; the TDD/ mini-check Ex 7
Figure — Code-generation agents

The figure above plots against for three values of . Notice the shape: every curve climbs fast then flattens toward (the dashed ceiling). The curve is the flat red line stuck at ; the curve jumps to immediately. Those two flats are cells C and D — the degenerate edges of the whole family.


Worked examples

Example 1 — the ordinary case (cell A)


Example 2 — the limit as attempts grow (cell B)


Example 3 — both degenerate edges (cells C and D)


Example 4 — inverse question: solve for (cell E)


Example 5 — pass@k from raw counts, including edges (cell F)


Example 6 — real-world cost trade-off (cell G)


Example 7 — exam twist: independence breaks (cell H)


Recall Self-test (reveal after trying)

One-try success , three attempts — ? ::: With , does raising to a million ever help? ::: No — stays ; iteration multiplies an existing chance, it can't create one. Given , smallest for ? ::: (since ). pass@2 with , ? ::: . Why does a real debugging agent beat the independence formula? ::: It conditions on past errors, raising the effective per-round success, so the true is at least the independence estimate.

Prerequisites & neighbours: Large Language Models · Tool use in AI systems · Automated testing · Program synthesis · Retrieval-Augmented Generation · Prompt engineering · AI safety and alignment · back to Code-generation agents.