An agent with a write tool and no boundaries can write anywhere it can reach, including over files it should never touch. An allowlist is the boundary: a short list of folders the agent may write to, with everything else denied. ADK agents can create persistent outputs like files and documents that live beyond the conversation, which makes the boundary worth setting before the first write. Write the list down, enforce it in the write tool itself rather than in the agent’s instructions, and test it by asking the agent to write outside the list. Instructions alone do not gate a tool; the check must live on the write action.
What you need
- The folders the agent genuinely needs to write to, listed by path
- A write tool that checks the target path before writing
- One test write inside the list and one outside it
Step 1: List the allowed folders and nothing else
Write the allowlist as the exact folders the agent may write to, such as the project output folder and the drafts folder. A folder not on the list is denied, not merely discouraged.
Step 2: Enforce the list in the write tool
Add the check to the write tool itself: before writing, confirm the target path sits inside an allowed folder, and refuse otherwise. A check in the instructions alone will be ignored under pressure.
Step 3: Test a write inside the list and one outside it
Ask the agent to write a file inside an allowed folder and confirm it lands, then ask it to write outside the list and confirm it is refused with a clear message. If the outside write lands, the check is not in the tool.
Worked example: synthetic file-write allowlist check
The table below is a synthetic example. It shows the expected result of the allowlist; no file was written.
| Write target | Allowed? | Result |
|---|---|---|
| output/report.md | Yes | Written |
| drafts/notes.md | Yes | Written |
| config/settings.json | No | Refused |
| No write outside the list | Yes | Pass |
Expected result (UNTESTED). the two allowed writes land, the write outside the list is refused, and no file is written outside the allowlist. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- An allowlist only helps if the write tool enforces it; instructions alone do not gate a tool.
- Paths can be tricky: a symlink or a relative path can point outside the list, so resolve the path first.
- An allowlist that is too narrow blocks legitimate work, so review it when the task changes.
- The list protects the filesystem, not the contents: a bad file in an allowed folder is still a bad file.
