Deterministic Code Instead of Model Calls
In this article
- Decide for a task whether it belongs in plain code, a model call or model-written code in a sandbox, by asking whether the transformation is known and checkable.
- Compare the tokens and the time of a model-based and a code-based aggregation, and say where the saving comes from.
- Return a typed summary to the model that reports missing and cut-off data as rows instead of hiding them.
- Name the limits that model-written code must run under before you allow it.
Overview
Your support manager wants a weekly report: how much money was refunded in each region. A first version pastes the order records into a language model and asks it for the totals. On real data it is slow, it costs a lot, and one week the numbers do not add up.
The fix is older than any model: write the sum in code. The harder skill is knowing which steps of an agent belong in code. After reading, you can sort a task with one question, measure what the move to code saves, hand the model a short, fixed-shape summary it can trust, and say what limits apply when you let the model write the code itself.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- One question per task
- The refund report, measured
- A summary the model can trust
- When the model writes the code
- The rule at work
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions