InfraLoka AcademyPathwayAI
PathwayAI

Module 2 · Chapter 2: Setting up the workspace

A workspace where an agent may be wrong

4 min read5 min readReviewed 26 October 2026

In short

Agents will be wrong, so give them a sandbox that can be thrown away and has no path to real data. Set every address they write to explicitly, because a forgotten default is the most common leak.

After this lesson you can

  • Set up a separate workspace where an agent may get things wrong
  • Set environment variables explicitly so an agent never falls back to a dangerous default

Terms in this lesson

Understand

Agents will get things wrong. Not maybe, but certainly, sooner or later: they misread the goal, read the wrong file, or run the right command in the wrong place. So the first preparation before an agent touches anything is a sandbox: a separate workspace where a mistake only breaks things you can throw away.

Its form depends on the work:

  • For documents: a test folder holding copies of files, not the real team folder.
  • For code: a separate checkout of the code per task, for example its own branch and working directory, so two agents never overwrite each other and changes can be discarded with one command.
  • For databases: a throwaway database in a container, on its own port that nothing else uses, filled with sample data or a disguised copy.
  • For outside services: a test account or the provider's test mode, not the account customers use.

A good sandbox has two properties. First, it can be rebuilt in minutes, so you do not hesitate to throw it away when it breaks. Second, it has no path to real data, except what you deliberately give. The second property is the one that leaks most often, usually not through a permission you granted, but through a default you did not notice.

Many programs have a default that is used when a setting is empty. The most common example: the database address. If the environment variable for the database address is not set, the program uses a default address, and that default is often the development database on your own machine, holding weeks of work data.

Now imagine an agent running tests that, as setup, empty the database. If the address is set explicitly to a throwaway database, there is no problem. If it is forgotten, the tests fall back to the default address and empty the wrong database. The agent did nothing malicious; it ran the right command with an empty setting. That is what happened in this lesson's case.

The rule: every environment variable that decides where the agent writes is set explicitly, in the same command as its task, not relied on from a local settings file or an earlier session. Better still, change the program so it refuses to run when the address is empty, instead of falling back to a default. This is part of the principle of least privilege: the agent can only reach what was given for this task.

One more small habit: write in the agent's instructions the places it must never touch, for example "never use the database on the default port, never write to the team folder". Instructions like this are not a reliable fence, because a model can misread or be misled by other text, but they help the agent refuse before trying. The real fence stays in the environment itself: narrow permissions and addresses set explicitly. The two together are much stronger than either one.

Finally, note the test environments you create: their name, which task they serve and how to throw them away. A forgotten environment slowly gets used for other things and stops being a safe place to be wrong.

Worked example

Before

The prompt

Please run the integration tests for this change and fix any that fail.

What came back

Weak output: I ran the integration tests. The test setup emptied the database, then 38 tests passed. All good.

After

The prompt

Goal: I want the integration tests for this change to pass. Material: run the tests only against the throwaway database I just created in a container, port 55441. Set the database address variable explicitly in the test command. Limits: never use the database on this machine's default port. If the database address is empty or different, stop and ask me. Check: show the full command you ran and the last test output.

What came back

Command: the database address set to the container on port 55441, then the integration tests run. Last output: 38 passed, 0 failed. The development database on the default port was not touched.

What changed

  • The first version did not say which database may be emptied; the tests picked the default.
  • The second names the sandbox, sets its address explicitly and gives a stop point if the address is empty.
  • Asking for the full command lets you check where the tests really wrote.

Common mistake

Mistake
Letting an agent work directly in your daily work folder and database because it is "only a quick try".
Why it hurts
A quick try uses the same permissions as real work. One test setup command, one misunderstood file move, and weeks of data are gone. Recovering takes far longer than creating a test space.
Do this instead
Create a sandbox first, even for a five-minute try: a copy of the folder, a copy of the code, a throwaway database. Set its addresses explicitly, then let the agent be wrong there.

Try

Sorting card

Which setup makes a safe place for an agent to be wrong?

  1. The real team folder, with the message "please do not delete anything"

  2. A database in a container on its own port, its address set in the command

  3. A test account at the payment service

  4. A separate copy of the code for this task only

  5. Your own development database, "because it only holds test data"

  6. The database address variable left empty so the program uses its default

6 cards left

An agent will run tests that empty the database as setup. Which arrangement is safest?

Take home

Before an agent touches anything

  • There is a sandbox I can rebuild in minutes
  • Every address the agent writes to is set explicitly in its command
  • The program refuses to run if an important address is empty
  • The agent's instructions name the places it must not touch
  • I note the test environments I create and how to throw them away

What went wrong for us

Incident, October 2026

An agent's test run that wiped a developer database

Context
We asked an AI agent to review a change and run its integration tests.
What happened
The tests set up their database by wiping it. The database address was not set, so the tests used the local development database and emptied it.
Impact
Local development data was lost. Restoring it was left to its owner. No production data was touched.
Root cause
The tests fell back to a default address when the variable was empty, and the agent was allowed to run any command on that machine.
What we did
We stopped running those tests on that machine, reported the data loss to its owner, and reran the tests in a throwaway container.
The guard we keep now
Integration tests run only in a throwaway container on its own port, with the address set explicitly. Agent instructions name the ports that are off limits.

The lessonAn agent's permissions should be as narrow as its task, and dangerous defaults should be removed.

What it means for your workWhen giving AI access to files or systems, keep it as narrow as the task and try it first on a copy, not on data people use.