PTENES
MODULE 6.5

🎯 Determinism

Not every scheduled task needs an agent “thinking” every time. In this module, you’ll learn when it’s worth locking behavior into a fixed sequence — faster, cheaper, and predictable.

6
Topics
25
Minutes
Intermediate
Level
Theory + practice
Type
0 of 60%
1

🔁 What determinism means

New here? Determinism means doing the same thing, the same way, every time—without “deciding” anything along the way. It’s the difference between a cake recipe (always the same steps, in the same order) and an experienced cook (who tastes, adjusts the seasoning, and changes plans if an ingredient is missing). Both can make a good cake, but one is predictable and the other is flexible.

In the previous modules in this track, you saw the agent “thinking”: it reads the context, decides which tool to use, evaluates the result, and adjusts the next step — that’s how the routine that learns (module 6.4) improves on its own over time. Determinism is the opposite of that, by design: a fixed sequence of actions that doesn’t change, interpret, or “think” — it just executes.

AGENT THINKING (loop) decidewhat act checkresult adjustthe plan go back to the beginning — reassess every time DETERMINISTIC SCRIPT (fixed sequence) 1. read data 2. calculate 3. save always in this order; never makes a different decision

Caption: on the left, the “thinking” agent goes through a decision cycle at every step (useful when the task varies). On the right, the deterministic script follows a straight, fixed line of numbered steps—with no cycle and no decisions along the way.

Fixed
Same order every time
Without judgment
Doesn’t interpret anything
Predictable
Expected result
Opposite
From the agent “thinking”
2

✅ Why sometimes you WANT determinism

It may seem strange to ask an agent for less "intelligence," but it makes perfect sense for a specific type of task: repetitive and well-defined. If every day at 7 a.m. you need to export a report, rename the previous day's files, and email it — the task's format doesn't change. It doesn't need "judgment"; it needs reliability and speed.

An agent that “thinks” every time uses more tokens (the unit of processed text that determines cost, covered in module 0.1) and takes longer, because it reevaluates the context from scratch on each run. A fixed script skips that step: it already knows exactly what to do.

💡 Main Concept

Repetitive, predictable task → deterministic script. Task with changing context → thinking agent.

  • •Faster: no “evaluate what to do” step.
  • •Cheaper: fewer tokens spent per run.
  • •More reliable: the result doesn’t vary from one day to the next.

✓ Good candidate for a fixed script

  • ✓Daily backup of a specific folder
  • ✓Generate a report in the same format every week
  • ✓Rename files according to a fixed pattern

✗ Poor candidate (requires an agent to think)

  • ✗Reply to emails with different content every day
  • ✗Decide priority among tasks whose importance changes
  • ✗Investigate why something broke (the cause varies)
3

📜 What a script is

New here? One script is a fixed list of instructions the computer runs in order, one after another, without interpreting or deciding anything— it’s the recipe from the previous example, only written in code instead of Portuguese. Unlike the agent, which “reads” the situation and chooses what to do, the script simply follows exactly what’s written, the same way every time.

The good news: the person writing the script can be the agent itself. It can "think" once, put together the right sequence of steps, and save it to a file. From then on, whoever runs it doesn’t need to think — they just run the file.

🔍 Inside

  • Script: code file with fixed steps — no "thinking," just execution.
  • Who writes: The agent, once, using its reasoning to put together the right sequence.
  • Who runs it later: the scheduled task runs only the script—without needing the agent again.
4

✍️ Write once, run every time

Here’s the trick that separates an expensive scheduled task from a cheap one: instead of asking the scheduled task to “think” every time it runs, you ask the agent write the script just once — and from then on, the scheduled task only runs that script. The "intelligent" part (writing, reviewing, adjusting the script) happens rarely and separately; the "repetitive" part (running it every day) is fast and inexpensive.

STAGE 1 — RARE Agent thinks write the script (once) script.sh ready and saved STAGE 2 — EVERY DAY scheduled task runs script.shwithout thinking ✓ fast, cheap, repeats every day without spending "reasoning" again

Caption: on the left, the agent thinks through and writes the script ONCE. On the right, the scheduled task runs that ready-made script EVERY day—fast, without spending tokens to “think” again on each run.

💡 Practical Tip

If your scheduled task runs every day and never changes format, ask the agent: “Could this become a fixed script?” Most of the time, the answer is yes—and the time and cost savings are immediate.

5

⌨️ Copy-run: ask for the script and the task that only runs it

Objective: ask the agent to write a simple script for one of your repetitive tasks and configure a scheduled task to run only that script from now on — without "thinking" again each time it runs.

Quero transformar a tarefa "<descreva a tarefa repetitiva, ex: exportar o relatório de vendas
do dia anterior e salvar em /relatorios>" num script determinístico.

1. Escreva um script simples (bash ou python, o que fizer mais sentido) que execute exatamente
   essa tarefa, sempre da mesma forma.
2. Teste o script uma vez rodando manualmente e me mostre o resultado.
3. Configure uma tarefa agendada para rodar ESSE SCRIPT (não o agente pensando) no horário
   "<defina o horário, ex: todo dia às 7h>".
4. Explique em uma frase por que isso fica mais rápido e barato do que o agente decidir tudo
   de novo a cada execução.

How to verify: run the scheduled task manually once and check that it calls the script (it doesn’t open a new "thinking" session); the runtime should be much shorter than a normal agent session.

6

🧭 When NOT to use a fixed script

Determinism is great until your task needs to evaluate a changing context. If the right decision today differs from the right decision tomorrow—because it depends on something that varies (email volume, document content, an external condition)—a fixed script will get it wrong because it can't adapt. In that case, having the agent “think” (covered in module 6.4) is worthwhile again.

⚠️ Attention

Don’t force determinism on a task that naturally varies. A “rigid” script trying to cover every possible case gets huge, hard to maintain, and still breaks the first time it encounters an unanticipated scenario. If the task changes, let the agent think.

✓ Use a deterministic script when...

  • ✓The sequence of steps is always the same
  • ✓There’s no decision to make, just execute
  • ✓Speed and cost matter more than flexibility

✗ Keep the agent thinking when...

  • ✗Each run depends on a different context
  • ✗The task needs to “judge” what’s important
  • ✗Unexpected errors require investigation, not repetition
1

Ask: does the task change format?

If the answer is “no, it’s always the same,” a fixed script is the way to go.

2

Ask: is there a real decision to make?

If so, and that decision varies, keep the agent thinking (module 6.4).

3

If you're unsure, start by thinking it through and migrate later

Run it as an agent thinking through the steps a few times; if you notice that the steps are always repeating in the same way, then turn it into a script.

Quick check (optional): Which task is the BEST candidate for becoming a deterministic script?

✅ Module Summary

✓
Determinism: fixed sequence, with no decisions along the way.
✓
When it's worth it: repetitive, well-defined tasks — faster and cheaper.
✓
Script: fixed list of instructions, written once by the agent, always executed the same way.
✓
When NOT to use: context varies → it becomes worthwhile for the agent to think again.

Next module:

6.6 — Notifications and Restrictive Permissions: How to Know the Task Is Done and How to Protect Your Files.