Skip to content
mentoor

Topic 3 of 5 · 4 min read

Making the model compute with tools

Goal: Rewrite an exact-task request so the answer comes from a tool, and confirm from the output that it ran.

For an exact task, do not ask the model to know the answer. Ask it to produce the answer with a tool, such as code, a calculator or a spreadsheet formula, and check that the tool actually ran.

Check yourself · 1 of 3

You need the exact total of a long column. Which request is best?

Choose one answer

Why it matters

A program adds the same way every time. When the model writes a small piece of code and a code tool runs it, the answer comes from the program, not from a prediction. Several assistants offer this: ChatGPT's data analysis feature runs code on files you upload, Claude has a code execution tool, and Gemini and others have similar options. Features and names change, so check what your own tool offers.

How to do it

  1. Say it is exact. "This is an exact calculation."
  2. Name the method. "Use code to compute it" or "use a calculator tool". If you have no tool, ask for a spreadsheet formula that you will run yourself.
  3. Give the data cleanly. Upload the file, or paste values one per line. Messy input causes errors that no tool can fix.
  4. Ask to see the code and the raw output. The code lets you read the logic. The raw output is the program's real result.
  5. Ask for the answer after the output. "Then state the result in one sentence, using the output."

Confirm that it really ran

Many tools show a code block with a result, an "analysis" panel, or a "ran code" label. If you see only a paragraph with numbers, the model may have written the answer from memory and described a calculation that never happened. Look for the code, the output beneath it, and the same number in the final reply. If any of these is missing, ask: "Did you run this? Show me the tool output."

Before and after

Before: What is 18.5% of 2,349,120, and how many weekdays are between 3 March and 9 June 2027?

After: These are exact calculations. Use code. (1) Compute 18.5% of 2,349,120. (2) Count weekdays from 3 March 2027 to 9 June 2027, inclusive. Show the code and its raw output, then summarise.

When you have no code tool

Ask for a formula and run it yourself. For example, a spreadsheet's SUM, COUNTIF and NETWORKDAYS functions do the work exactly. The model writes the formula, which it is good at. Your spreadsheet does the calculation.

What goes wrong

  • Described, not run. The reply says "I used Python" but shows no output.
  • Right tool, wrong inputs. The code runs but on a misread column or the wrong date format. The tool is exact about the wrong question.
  • Hidden assumptions. "Inclusive or exclusive?", "Which time zone?" Code will pick one silently.

Examples

Weak and strong versions of one request

Weak: Total these 40 expenses.

Strong: Use code to total the amounts in the attached file. Print the number of rows read and the total. Then give me the total in one sentence.

Printing the row count lets you spot a misread file at a glance.

No tool? Ask for the formula

If your assistant cannot run code, ask: "Give me a spreadsheet formula that counts how many cells in column B contain 'price'." You paste it in and the spreadsheet counts exactly.

Key points

  • For exact work, ask the model to produce the answer with a tool, not to recall it.
  • Name the method: code execution, a calculator, or a spreadsheet formula you run yourself.
  • Ask to see both the code and its raw output, then check the final number matches.
  • If no code or output appears, the model may have described a calculation it never ran.
  • A correct tool run on misread input still gives a wrong answer.

Common mistakes

  • Asking for the answer but not naming a tool, so the model predicts it.
  • Accepting 'I used code' when no code or output is shown.
  • Feeding messy or ambiguous data and trusting the clean-looking result.
  • Leaving rules such as inclusive dates or time zones unstated.

Check yourself · 2 of 3

An assistant says "I ran Python and the answer is 4,812" but shows no code or output. What should you do?

Choose one answer

Check yourself · 3 of 3

Your assistant cannot run code. How can you still get an exact count of rows containing a word?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic