Última actualización: 2026-12-02

DAY 002 OF 1600 · 2026-08-29

Day 002 — Agents, PEAS, and injection

A student's private learning log · one concept at a time. Date: 2026-08-29 · Day: 2 of 1600 Log: a student's private learning log · one concept at a time. ---

Concept #2 — Intelligent agents and the PEAS framework

PR01 introduces AI through the idea of an intelligent agent : something that perceives its environment, decides, and acts. PEAS is the four-part "job description" of any agent — Performance measure, Environment, Actuators, Sensors. A software bot is an agent too, not just a robot. I built a simple reflex agent for the classic two-room vacuum world: if the tile under its sensor is dirty, it sucks; otherwise it moves. This is introductory — I am at the start of the program. What I tried today: a small Python simulation of a reflex vacuum agent, with its PEAS description and a basic performance measure (1 / actions taken to finish). class ReflexAgent: # rule: if the tile under the sensor is dirty -> Suck; else move. def __init__(self): self.loc = "A" self.actions = [] def step(self, world): if world.sense(self.loc) == "DIRTY": world.suck(self.loc); self.actions.append("Suck") elif self.loc == "A": self.loc = "B"; self.actions.append("Right") else: self.loc = "A"; self.actions.append("Left") Real output: === PEAS (the agent's job description) === Performance: Clean every room in as few actions as possible Environment: Two rooms (A and B), each either dirty or clean Actuators: Suck, Left, Right Sensors: A dirt sensor at the agent's current room === Simulation === actions: ['Suck', 'Right', 'Suck'] world clean after 3 actions: True performance = 1/3 = 0.333 What I understood from it: the reflex agent needs no memory or planning — it acts on the current percept alone, which is exactly why it is called "simple". It cleaned the world in 3 actions (suck A, move to B, suck B). The trap in the exam is mixing up the *performance measure (how we score it) with the actuators* (how it affects the world) — they are different parts of PEAS. ---

Security #2 — Command injection (CWE-78)

I studied command injection: when user input is pasted directly into a shell command, an attacker can add ; and run their own command. This is a beginner topic for me; I ran everything only in a local /tmp sandbox against a fake "ping", never against a real system. The pattern I studied: # UNSAFE — user input concatenated into a shell string payload = "127.0.0.1; whoami" cmd = "ping -c 1 " + payload # shell runs whoami too What I understood about preventing it: never build shell strings from user input. Pass arguments as a list (no shell), or escape the value with shlex.quote() so ; becomes a literal character. import shlex safe_args = shlex.quote("127.0.0.1; whoami") # ';' is now literal Sandbox check (local only, harmless echo, no real target): UNSAFE command built: ping -c 1 127.0.0.1; whoami shell executed: 'pinging...\nINJECTED_AFTER_SEMICOLON' FIXED (shlex.quote) -> command args: '127.0.0.1; whoami' What I understood: the raw build let the shell run the part after the ; (the sandbox printed INJECTED_AFTER_SEMICOLON ), while the shlex.quote version keeps the whole string as one literal argument, so nothing extra executes. The rule I keep: user input must never reach a shell string. ---

Day 2 notes

Concept #2: reflex agent + PEAS ran, output above. ✔ Security #2: command injection understood, sandbox only. ✔ 1598 days left. One at a time.

Written by my own daily machine, checked by me.

← Back to the index

· Day 002 of 1600 · Matías Rathgeb


[ inicio ]   [ proyectos ]   [ posts ]   [ daylog ]


Página estática. Sin cookies, sin javascript, sin fuentes externas.
Contacto: ver inicio.