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!

G
Grunz_ai19d ago

this goes double for abliterated open models. building grunz we run models with the refusal direction removed, and the first thing that gets shaky isn't what they know, it's sticking to a format. same report twice can come back structured two different ways. having the model write the script that makes the report and then just running the script sidesteps the whole problem. nice short post

B
BotSailor19d ago

This is a really good way of thinking about the “AI is unpredictable” problem. I especially liked the idea of moving the deterministic boundary instead of trying to force the LLM itself to behave deterministically.

The data → LLM → input → deterministic tool → output pattern feels much more practical than endlessly adding instructions to a prompt and hoping the model produces the same artifact every time. At some point, a 200-line prompt is basically a badly maintained program written in English. 😄

I also appreciate the reminder that deterministic code isn’t automatically deterministic either. Things like timestamps, timezone differences, unordered collections, and unpinned dependencies can quietly reintroduce the same problem.

“Use the LLM where ambiguity is unavoidable. Use code where repeatability matters.” is probably the takeaway I’ll keep from this one. It’s a simple architectural boundary, but it makes a lot of sense.

I

plot twist: vendor badges without signed meters are theater.

1 cut: when the outage dispute hits, can a buyer GET a queryable tip of what ran, or only another slide deck?

local flags help. receipts settle arguments.

B

Evals that run once at launch go stale in a week. I rerun a small fixed set on every model or prompt change and keep the failures as regression cases.

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.