AI coding agents are getting more tools every month: shell access, file writes, network calls, package installs. That's also the problem. Every capability you grant an agent is a capability a bad prompt, a hallucinated command, or a poisoned dependency can abuse. A recent thread here on DEV asked what happens when those boundaries fail — and the honest answer is: usually nothing, until the one time it matters.
This article is a practical pattern I've been refining for evaluating agent-generated code without letting it anywhere near my main machine or repositories. It uses two ingredients that lower the cost of experimentation to nearly zero: a free tier of model access, and a free ephemeral server you can treat as disposable. The pattern works with any provider that offers those two things; I'll note where I used one specific option.
The core idea
Never evaluate agent output in an environment you care about. Instead:
- Spin up a throwaway environment with no credentials, no SSH keys, no access to your real repos.
- Give the agent a task and capture everything it does.
- Run a fixed battery of checks against the output.
- Destroy the environment.
The important property isn't the tooling — it's that the environment is cheap enough to be disposable. If spinning up a sandbox costs you money or setup time, you'll skip it "just this once," and that's when things go wrong.
A concrete setup
Disclosure: This article was prepared as part of MonkeyCode's product outreach. I used MonkeyCode here because it offers free access to models and a free server option, which fits the "disposable by default" requirement — a sandbox that costs nothing is a sandbox you'll actually use. The workflow below is provider-agnostic, though; substitute whatever free tier you have.
The sandbox workflow has four scripts. Here's the skeleton, which you can adapt:
#!/usr/bin/env bash
# run_agent_trial.sh — execute one agent task in isolation
set -euo pipefail
TRIAL_DIR=$(mktemp -d /tmp/agent-trial.XXXXXX)
echo "Trial workspace: $TRIAL_DIR"
# 1. No secrets in scope: explicitly empty env for the trial
env -i HOME="$TRIAL_DIR" PATH="/usr/bin:/bin" \
bash -c '
# 2. Agent generates code into the trial dir only
# (prompt sent via your provider CLI/API here)
# 3. Static checks before anything executes
grep -rnE "curl|wget|nc |/etc/|sudo|rm -rf /" . && \
echo "FLAG: suspicious command patterns" || echo "static scan clean"
'
# 4. Cleanup is unconditional
trap 'rm -rf "$TRIAL_DIR"' EXIT
Key points, none of which are exotic:
-
env -istrips your environment variables, so no API keys, tokens, or cloud credentials leak into the trial. This alone prevents the most common real-world agent accident. - The static grep is deliberately crude. It's not a security scanner — it's a tripwire that catches the obvious stuff (
curl | sh, writes outside the workspace) before you run anything. -
trap ... EXITmeans the workspace dies even if the trial crashes.
A decision table: when is a free-tier sandbox enough?
| Scenario | Free sandbox OK? | Why |
|---|---|---|
| Evaluating a model's code quality on toy tasks | Yes | No real data involved; failure cost is zero |
| Testing an agent's tool-use behavior (file ops, shell) | Yes | Isolation matters more than compute |
| Prototyping an agent workflow before buying infra | Yes | You're validating the design, not the scale |
| Running agent code against production-like data | No | Free tiers rarely offer the controls you need for sensitive data |
| Load/performance benchmarking | No | Unspecified quotas and shared resources make results meaningless |
| Anything needing guaranteed availability | No | Free options can change or disappear; don't build dependencies on them |
The evaluation battery
A sandbox without a rubric is just a playground. For each trial I score four things:
- Boundary discipline — did the agent attempt anything outside its declared scope? (The static scan plus a review of the command log.)
- Correctness — does the generated code pass a small test I wrote before seeing the agent's output? Writing the test first is crucial; otherwise you'll unconsciously write tests that the output passes.
- Self-verification — when the code fails, does the agent notice and fix it, or does it declare success anyway? This is the single best predictor of whether an agent is safe to supervise loosely.
- Cleanup behavior — does it leave temp files, background processes, or half-applied migrations? Agents that clean up after themselves are dramatically easier to trust in shared environments.
Limitations and who shouldn't use this
- A disposable sandbox reduces blast radius; it does not make agent output trustworthy. Prompt injection via dependencies or fetched content can still produce bad code that passes your checks.
- Free tiers — models and servers alike — come with unspecified limits. Don't measure performance on them, don't rely on them for anything time-sensitive, and don't assume today's availability is permanent.
- This pattern is overkill if you're just asking a model questions in a chat interface with no tool access. It's specifically for agents that can do things.
- If your threat model includes a genuinely adversarial model (not just a sloppy one), a free shared server is not adequate isolation. Use proper virtualization or an air-gapped machine.
Takeaway
The agents-will-break-things discourse tends to swing between "never trust them" and "just supervise better." The boring middle ground is environmental: make the cost of a safe trial so low that skipping it feels sillier than doing it. Free model access plus a free disposable server hits that threshold today — whatever provider you get them from. If you want to try the exact setup above, MonkeyCode's free tier is one way to run it without touching your own infrastructure.
What's in your evaluation battery? I'd be curious what checks other people run before letting agent output anywhere near a real repo.
Top comments (0)