ThisCalculator

Everyday

Decision Agents: Let the LLM Explain, Code Calculate?

Updated · Standard formula, shown below

Decision Agents: Let the LLM Explain, Code Calculate?

Yes: a decision agent can use a large language model (LLM) to interpret a request, explain options, and choose an appropriate next step, while ordinary code performs exact calculations. This division is often useful, but it is a design principle rather than a guarantee: the system still needs clear rules, validated inputs, and checks on both the model’s decisions and the code’s results.

What a decision agent does

A decision agent is a system that observes information, selects an action, and may repeat that cycle as new information arrives. In software, the term can describe anything from a small workflow that routes requests to a more elaborate system that calls tools or coordinates multiple steps. It does not refer to one standardized architecture.

An LLM can contribute language understanding and flexible interpretation. For example, it can turn “compare these two delivery options and tell me which arrives sooner” into a structured request. Code can then calculate arrival times from supplied dates and durations. The agent can present the result in plain language.

The phrase “let the LLM explain, let code calculate” captures a sensible separation of responsibilities. It does not mean that every judgment is a calculation or that an LLM cannot make arithmetic mistakes. It means that tasks with precise, testable rules should generally be handled by deterministic software rather than relying on generated text alone.

Why separate interpretation from calculation

LLMs generate responses based on patterns in their training and the current context. They are useful when a request is phrased informally, contains relevant context, or needs a readable explanation. But a fluent answer is not proof that a number is correct. A model may misread a value, choose an unstated assumption, make an arithmetic error, or describe an estimate as exact.

Conventional code follows specified operations. Given validated inputs and a correctly implemented formula, it can produce repeatable results. That makes it better suited to arithmetic such as totals, conversions, eligibility checks, and date calculations, provided the rules and inputs are themselves right.

Keeping the roles distinct also makes testing easier. Developers can test a calculation function against known examples, and separately assess whether the model correctly understands requests and explains outputs. If the result is wrong, this division helps identify whether the problem came from interpretation, data, formula implementation, or presentation.

How the workflow works

A practical agent can use a sequence like this:

  1. Interpret: The LLM identifies the user’s goal and the information needed.
  2. Structure: The system turns the request into typed fields, such as quantities, units, and an operation.
  3. Validate: Code checks that required fields exist, values are in range, and units are compatible.
  4. Calculate: A deterministic function applies the specified formula or business rule.
  5. Explain: The LLM or a controlled template describes the result, assumptions, and relevant caveats.
  6. Check: The application verifies that the response agrees with the computed result before showing it.

Consider a request to split a 48-kilometre trip into three equal sections. The model can recognize that “split equally” means division and ask for clarification if the request is ambiguous. Code calculates 48 ÷ 3 = 16 kilometres per section. The explanation can say that each section is 16 kilometres, assuming equal distances. The arithmetic is simple, but the same architecture helps when calculations are more involved.

What should remain in code

Use code for operations where a wrong result can be clearly detected by a rule or formula. Typical examples include:

  • Arithmetic, unit conversion, and aggregation of numeric data.
  • Applying explicit, versioned rules to structured inputs.
  • Checking ranges, required fields, and consistent units.
  • Looking up an authoritative record when the system has access to a defined data source.
  • Recording the inputs, formula version, and output needed for later review.

Code cannot make an uncertain source of information certain. If a calculation depends on a current exchange rate, a schedule, or a user-provided measurement, the system must obtain the right data and identify its source or timestamp. The formula may be correct while the input is stale or incorrect.

What the LLM should and should not decide

An LLM can help classify requests, extract likely values from text, ask follow-up questions, and explain a result for different audiences. It can also help select among available tools when the choices and permitted actions are clearly defined.

However, the model’s interpretation should not silently become a fact. If a user says “around five miles,” the system should preserve the uncertainty or ask whether an exact value is required. If “monthly” could mean a calendar month or a fixed number of days, the system should clarify which convention applies before calculating.

Likewise, an explanation should not add claims that are absent from the inputs or calculation. A model may summarize “the computed total is 120” but should not invent why that total is appropriate. High-impact or consequential decisions need suitable human oversight and domain-specific safeguards; adding an LLM does not make a decision reliable by itself.

Common failure modes and safeguards

Problems often happen at the boundaries between language and computation rather than inside the formula:

  • Incorrect extraction: The model reads “1,500” as “150.” Validate values and show interpreted inputs when it matters.
  • Unit mismatch: Adding miles to kilometres without conversion gives a misleading total. Require explicit units and convert them through tested functions.
  • Ambiguous rules: Code cannot resolve an unstated definition. Ask a question or display the assumption being used.
  • Unverified output: A generated explanation may contradict the tool result. Compare numeric claims in the response with the actual output, or use a template for critical figures.
  • Tool misuse: An agent may call the wrong operation or pass malformed data. Restrict available tools, validate arguments, and handle errors explicitly.

Testing should cover ordinary cases, boundary values, invalid inputs, and ambiguous requests. Monitoring can help reveal patterns of failure, but it does not replace testing or review. For important calculations, preserve enough information to reproduce the result, including input values, units, and the rule or formula used.

Frequently Asked Questions

Can an LLM do calculations accurately?
It can handle simple arithmetic in some cases, but its response is not a dependable substitute for a tested calculation function when exactness matters. Use code for the calculation and verify the inputs.

Does “let the LLM explain, let code calculate” mean the LLM makes every decision?
No. The application should define permitted actions and decision rules. The LLM may interpret language or recommend a next step, while code enforces constraints and carries out precise operations.

Should the LLM choose which formula to use?
It may identify a likely formula, but the system should verify that choice against the task’s defined rules and available inputs. Ask the user when multiple interpretations would change the result.

Can code guarantee a correct answer?
No. Code can calculate consistently, but a faulty formula, bad input, incompatible units, or outdated data can still produce a wrong answer. Test the implementation and validate the data.

When should a person review an agent’s decision?
Human review is appropriate when an error could have significant consequences, when the request is ambiguous, or when the system’s rules do not cover the situation. The required review depends on the task and its risks.

Bottom line

“Let the LLM explain, let code calculate” is a useful design guideline for decision agents: use language models for flexible interpretation and communication, and tested code for precise, repeatable computation. Treat the handoff between them as part of the system that needs validation. Correct arithmetic is only one piece of a trustworthy answer; the inputs, assumptions, rules, and explanation must also hold up.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.