lesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the tracelesson 2 of 3 · the loop with a meter — budget caps, stop reasons, and the tracethe loop with a meter — budget caps, stop reasons, and the trace
Checkpoint
One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.
Checkpoint: bolt lesson 1 onto lesson 2. Write triage_run(plan, caps)
where each plan entry is a call dict ({"tool": ..., "confirmed": ...}), and every iteration goes: step cap → validate → cost gate →
spend and run.
Rules, in order per iteration:
- Step number over
caps["max_steps"]→ printstop: step-cap ($X.XX spent)and return. - Look up the tool's spec in
TOOLS. If it needs confirm and the call lacks a truthyconfirmed→ printstep N: <tool> reject: needs confirm— the same verdict string your validator returns — and continue to the next call. A rejected call burns a step but spends nothing; the validator said no before anything ran. - If
spent + costexceedscaps["max_cost_usd"]→ printstop: cost-cap ($X.XX spent)and return. - Otherwise spend and print
step N: <tool> ok $X.XX.
Plan exhausted → stop: plan-complete ($X.XX spent).
Expected output (two runs):
step 1: read_log_tail ok $0.03
step 2: rerun_job reject: needs confirm
step 3: rerun_job ok $0.14
step 4: open_issue ok $0.18
stop: plan-complete ($0.18 spent)
step 1: rerun_job ok $0.11
step 2: rerun_job ok $0.22
stop: cost-cap ($0.22 spent)