Skip to main content

Command Palette

Search for a command to run...

Your LLM Is Not Deterministic

Stop asking probabilistic models to generate reports. Let them build and orchestrate deterministic tools instead.

Updated
•2 min read•View as Markdown
Your LLM Is Not Deterministic
M

Software Engineer x Data Engineer - I make the world a better place to live with software that enables data-driven decision-making

Run the same report twice and the second result may reorder sections, rename a heading, or round a number differently. Add more instructions and the prompt starts looking like a brittle program written in prose. We don't want that.

This is usually the point where you should write an actual program (remember the times when you used to write programs manually? Good, old times, huh?).

Move the Deterministic Boundary

Instead of sending raw data to an LLM and asking for the final artifact:

data -> LLM -> report.out

make the model produce structured input for a deterministic tool:

data -> LLM -> input.data -> generate-report.sh -> report.out

The LLM still handles the ambiguous work: understanding the request, collecting information, preparing the input, choosing the tool, and recovering from failures.

The script owns validation, calculations, ordering, and formatting.

./scripts/generate-report.sh input.data > reports/report.out

One script with a documented input format and useful exit codes is often enough. It can be tested, versioned, and run by developers, CI, or an agent.

See? Everyone is using the same tool. Outcome is always the same.

Let the LLM Build the Missing Tool

If the script doesn't exist, ask LLM to create it once instead of asking it to regenerate the report every time. A larger workflow can expose the same commands through a Makefile:

validate:
    ./scripts/validate-input.sh ${INPUT}

report: validate
    ./scripts/generate-report ${INPUT} > reports/report.out

Now everyone uses the same interface:

make report INPUT=input.data

There's no separate AI workflow to maintain.

Deterministic code still needs discipline. Pin tool versions, and timezone. Sort collections explicitly. Pass timestamps in as input instead of the current clock. Otherwise, the nondeterminism merely moves into the script.

Use the LLM where ambiguity is unavoidable. Use code where repeatability matters. If your prompt keeps growing to control exact output, stop refining it and give the model a tool instead.

Cheers!

Machine Learning

Part 1 of 7

In this series, I will discuss machine learning concepts and their implementation in the modern world of software architecture. [Series cover photo by JJ Ying on Unsplash]

Up next

MCP vs ACP: Clarifying the Protocol Layer in the Agentic Era

How Model Context Protocol and Agent Communication Protocol shape the AI stack.