Move deterministic loop steps into code
Use ordinary code for steps fully determined by their inputs and retain model judgment for the ambiguous remainder.
These examples and illustrative results are independently authored teaching materials, not measured model results.
Use case
An agent repeatedly normalizes invoice currencies/totals and interprets unclear descriptions. Teaching I1=usd/100 cents, I2=USD/250 and I3=EUR/300; allowed currencies are USD/EUR with separate sums and no exchange. I2 service/I3 fee classification needs contract context.
Mechanism
Map call-site responsibilities and identify outputs fully determined by complete inputs/rules. Move formatting/filtering/arithmetic into tested code with validation. Retain genuine interpretation with necessary evidence. Structured fields can still require policy judgment; shape alone does not justify deleting the model step.
Bad example
Ask the model to normalize/sum each fixture row repeatedly, then force business classification from service/fee without checking policy/contracts.
Good example
Use ordinary code for permitted-currency normalization, integer-cent validation and per-currency totals: USD=350, EUR=300, without mixing/exchange. Separately handle service/fee classification with contract evidence, preserving missing-context uncertainty. Record replaced versus retained call responsibilities and inspect deterministic results/residual inputs.
Why the change matters
Code makes fixed invariants inspectable while responsibility separation keeps real ambiguity from becoming guessed hardcoded policy.
Observable expectation
Compare USD 350/EUR 300 and invalid-currency/noninteger errors. Contract-free classification stays unknown; arithmetic success does not establish classification.
Inspect complete call mapping and retained judgment/error handling. No real financial records are processed.
Limits
Determinism requires complete policy/input; real precision/limits/categories follow the project. Source one-model-call advice is not a universal call count. This fixture measures neither cost nor effect.