PTENES
MODULE 5.2

🧠 Intellect: Autonomous AI

So far, you had an assistant that responded when called. Now you’ll give it a goal, a clock, and a memory. Intelecto is an agent that wakes up on its own, decides what to do, and acts without you telling it to. This is the final step of the journey.

6
Topics
45
Minutes
Basic
Level
Hands-on
Type
1

From Assistant to Autonomous Agent

One assistant waits for you to send a message. You ask, it answers, and then waits for the next instruction. A autonomous agent is different: you give it a goal (for example, "every day, summarize my new messages"), and it decides when to act, which steps to take, and when it no longer makes sense to continue. The difference isn’t the model’s intelligence. It’s who presses the button: you or the model.

THE AGENT CYCLE OBJECTIVE what they want to achieve 1. NOTICE 2. PLAN 3. ACT 4. REMEMBER the cycle repeats on its own until the goal is met

🧠 Analogy: The Intern Who Became an Employee

An assistant is like an intern who only does what you ask, when you ask. An autonomous agent is a trusted employee: you say, "take care of the inbox," and disappear for a week. It organizes things, replies to what it can, gathers questions, and gives you a summary when you return. You didn't have to click anything.

  • •Assistant: responds to a command (“summarize this text”)
  • •Agent: pursues a goal ("keep my system healthy")
  • •Assistant: without you, it stays idle
  • •Agent: without you, it keeps working

💡 Tip: Autonomy Is a Ladder, Not a Switch

You don’t need to jump straight to “the agent does everything on its own.” Start with little autonomy: the agent suggests, and you approve. Then it does the work and lets you know. Only at the end does it work without needing to notify you. Moving up one step at a time prevents surprises and helps you gradually trust it.

2

Scheduling: Make the Agent Wake Up on Its Own

For the agent to act without you, it needs a clock. Instead of running it all the time (using memory and energy), you set it to wake up at specific times: every morning at 7 a.m., every hour, or every Monday. The classic tool for this is cron on Linux, which you already learned about in Track 4.

crontab - Schedule the agent

Each cron line has 5 time fields (minute, hour, day, month, day of the week) followed by the command.

# Open the scheduling editor

$ crontab -e

# Run the agent every day at 7 a.m.

0 7 * * * /usr/bin/python3 /home/voce/agente/run.py

# Run every 15 minutes

*/15 * * * * /usr/bin/python3 /home/voce/agente/run.py

# View current scheduled jobs

$ crontab -l

0 7 * * * /usr/bin/python3 /home/voce/agente/run.py

👁 What you’ll see on the screen

# The 5 fields, from left to right:

• • • • •

| | | | |

| | | | +-- day of the week (0-6, Sunday=0)

| | | +---- month (1-12)

| | +------ day of the month (1-31)

| +-------- hour (0-23)

+---------- minute (0-59)

The asterisk * means “any value.” That’s why 0 7 * * * reads as: minute 0, hour 7, any day, any month, any day of the week.

⚠️ Common Error

Problem: "It works when I run it manually, but cron doesn’t execute anything."
Solution: Cron runs with a minimal environment and doesn’t know your shortcuts. Always use absolute paths (e.g.: /usr/bin/python3 instead of python3) and test the full command by pasting it into the terminal before scheduling it.

3

Persistent Memory: Remember Across Sessions

An AI model, by default, forgets everything when the conversation ends. Every time cron wakes the agent, it starts from scratch, as if it were the first day on the job. To avoid this, you store what matters somewhere that survives shutdown: a file or a database. This is persistent storage.

🧠 Analogy: The Notebook in the Drawer

Imagine an employee with total amnesia who forgets everything at the end of the workday. The solution? A notebook in a drawer. Before leaving, they write down what they did and what’s still pending. The next day, the first thing they do is read the notebook. This notebook is the agent’s persistent memory: a file memoria.json or a table in the database.

Simple memory in a JSON file

To get started, one file is enough. The agent reads it at the start and writes to it at the end.

# At the start: read what you already know

import json, os

memoria = {}

if os.path.exists("memoria.json"):

memoria = json.load(open("memoria.json"))

# ... the agent works and discovers things ...

memoria["ultima_execucao"] = "2026-06-17 07:00"

memoria["pendencias"] = ["responder cliente X"]

# At the end: save it for next time

json.dump(memoria, open("memoria.json", "w"), indent=2)

When the memory grows (many items, text search), replace the file with a database such as Supabase that you saw in Track 2.

✓ What to KEEP in memory

  • ✓What’s already been done (so you don’t repeat it)
  • ✓Pending items and what got left unfinished
  • ✓Your preferences that it learned

✗ What NOT to store

  • ✗Plain-text passwords and tokens (use environment variables)
  • ✗Whole conversations without clearing them (the file gets bloated)
  • ✗Unnecessary sensitive data from third parties
4

Integration with Services: Email, Calendar, and APIs

An agent that only thinks is useless. For it act in the world, you connect it to services: send an email, create a calendar event, post to an API. Each service becomes a "tool" the agent can use. You’ve already learned to work with APIs in Track 2; here it’s the same idea, except the agent decides when to call the API.

Call an API from the agent

# Send a message via any API (Python)

import requests, os

token = os.environ["API_TOKEN"]

resp = requests.post(

"https://api.servico.com/mensagens",

headers={"Authorization": f"Bearer {token}"},

json={"para": "voce@email.com", "texto": "Resumo pronto"}

)

print(resp.status_code)

200

The token comes from an environment variable (Track 2, Module 2.4) and never is written directly in the code.

📧
Email

SMTP or API (send notifications)

📅
Calendario

Create and read events

🔗
APIs REST

Any web service

⚠️ Common Error

Problem: "The agent sent 40 identical emails in one minute."
Solution: Without limits, an agent in a loop can trigger cascading actions. Always set a limit (at most N actions per run) and mark in memory what has already been sent so you don’t repeat it. Actions in the real world need a safeguard.

5

Monitoring and Logs: Know What It Did

An agent works while you sleep. If you don't record what it does, you're in the dark: you don't know whether it ran, ran into an error, or messed up. That's why every agent needs logs (a record of what happened) and alerts (a notification when something breaks). Logging is cheap; finding out about a problem too late is expensive.

1

Log every step

The agent writes in the log what it noticed, what it decided, and what it did.

import logging

logging.basicConfig(filename="agente.log", level=logging.INFO)

logging.info("Acordei. 3 mensagens novas.")

logging.info("Respondi 2. 1 ficou pendente.")

2

Read the Log Later

You open the log to check what happened during the latest runs.

# View the latest lines of the log

$ tail -n 20 agente.log

INFO: I woke up. 3 new messages.

INFO: I replied to 2. 1 is still pending.

3

Alert you when something breaks

If something goes wrong, the agent notifies you (email, message) instead of failing silently.

try:

do_task()

except Exception as e:

logging.error(f"Falhou: {e}")

send_alert(f"Agent failed: {e}")

💡 Tip: Log the decision, not just the action

Don't just log "sent email." Also log why: "I sent an email because the client's message had gone unanswered for 2 days." When the agent does something strange, that "because" will help you understand and correct its behavior.

6

Continuous Improvement: Measure, Adjust, Improve

An agent isn't ready-made. The first version will make mistakes, overdo things, and have silly ideas. The secret isn't getting it right the first time; it's improve every week: you measure how it's doing, adjust one thing, observe the result, and repeat. Over time, it becomes more useful and more reliable. This is the same improvement cycle that applies to any system you put into production on this journey.

🎯 The improvement cycle

MEASURE -> how many tasks did the agent complete? how many errors?

|

ANALYZE -> what went wrong the most? where did it overdo things?

|

ADJUST -> change 1 thing (an instruction, a limit, a schedule)

|

OBSERVE -> did it run better? go back to MEASURE

✓ What TO DO

  • ✓Change one thing at a time and observe
  • ✓Store simple metrics (completed tasks, errors)
  • ✓Start with limited autonomy and expand gradually

✗ What NOT to do

  • ✗Change ten things at once (without knowing what worked)
  • ✗Give full autonomy without testing first
  • ✗Assume that “done is done” and never check again

🏆 You’ve completed the full cycle

Notice: measuring, adjusting, and improving is exactly what you did with Git (versioning), with deploys (publishing and fixing), and with servers (monitoring and maintaining). The autonomous agent is nothing new. It’s everything you learned in the previous tracks, now driven by a goal instead of by your click. You’ve reached the top of the ladder.

📚 Module Summary

✓
Agent vs. assistant - the assistant responds to commands; the agent pursues a goal on its own
✓
Scheduling with cron - the clock that wakes the agent at the right times
✓
Persistent memory - a file or database to remember between sessions
✓
Service integration - email, calendar, and APIs for taking action in the real world
✓
Logs, Alerts, and Progress - know what it did and improve it every week

🎉 Congratulations: you completed the entire course!

You’ve reached the end of the 5 tracks from Zero to Deploy. Take a moment to look back:

  • •Track 1: terminal and Git — you learned to communicate with the machine and version your work
  • •Track 2: modern deployment - put projects online with Vercel, Supabase, and APIs
  • •Track 3: your own server - mastered VPS, SSH, and security
  • •Track 4: Docker and automation - packaged and automated everything
  • •Track 5: AI assistants - from Jarvis to the autonomous Intellect

You went from zero to deployment. Now it’s time to build, publish, and improve. The rest of the journey is yours.