Just Because Your Agent Could Doesn't Mean It Should
I made a big mistake. I checked in over 2 GB of images into GitHub. Not on purpose, it just happened over time. I've been building Kids and Dragons, a role-playing adventure game for kids, with coding agents, and it gen
I made a big mistake. I checked in over 2 GB of images into GitHub. Not on purpose, it just happened over time.
I've been building Kids and Dragons, a role-playing adventure game for kids, with coding agents, and it generates a lot of art. Like, thousands of assets. And because I've been trying to go "hands-free" with its development, every painting, every sound file, and every revision of them went into Git. Which seemed fine at first, but by the time I thought to do an audit, a clone of the repository was 3.4 GB! 😬
That won't scale, plus it takes up way too much disk space and memory on cloud agent environments. I had to do something. My plan was to move 2,722 files into S3, keep content hashes in a lock file, and make future clones lightweight. I documented the migration plan and handed it over to Fable 5.2.
I'd built an MCP server to let agents upload art to S3, and the migration was going great! For 17 seconds. 🙃
The upload key could add write-once objects. Overwriting a painting, deleting art, and changing other AWS resources were outside its scope. I'd thought pretty hard about what I gave Claude access to. But unfortunately I'd completely forgotten about how fast it could touch it.
File uploads were already done. The migration tool was just checking whether each blob was there by hitting the API that serves the game. It was making about 56 requests per second against a limit of 50. After processing 959 files, it got an HTTP 429 (Too Many Requests) and stopped.
I don't know whether any player requests got rejected in those 17 seconds. But I do know my art migration was competing with kids trying to play the game. And that makes me uncomfortable.
Before I continue, thank you to Teleport for sponsoring this post. Opinions are my own.
Allowed doesn't mean appropriate
In my migration, the upload-and-verify workflow competed with live traffic. To work around it, I just had to pace requests, back off on throttling, and retry. The next run took several minutes instead of a few seconds, and it completed successfully.
But if you zoom in on the agent behavior from the first run, you get into the scary bits. The "permission vs objective" piece of it. The objective I gave it was to move the storage location of the art and keep the game working. The permission to check and upload files didn't indicate how fast those requests should arrive or what else shares the endpoint (which I totally overlooked, and that's part of what makes it so scary).
After the migration, I made a long-lived upload key for Codex so it could keep adding art after the cutover. I ran the smoke test and everything passed. Then I looked at the new key's usage record and saw it had never been used. 🫠
My terminal still had an older smoke-test key in its environment. The upload worked, but it was using the wrong identity. That's one of the (many) problems with giving agents long-lived keys.
There were other whoopsie doodles throughout the day. The first Git history-rewrite plan removed image and audio files, but left 572 MB of unused animated rigs because the file patterns I was matching on forgot to include them. An offline-backup check exited before its checksum step ran, but the wrapper showed as successful. Another verification script initially reported thousands of missing non-media objects, but I just had a bug in the script. I had to double-check the passes and failures because I couldn't trust either one.
When you think about it, all of these are examples of the misalignment of what the system permits, what the agent thinks it did, and what I wanted to happen. Which if applied in a more serious use case could wreak havoc on a business.
Permissions need boundaries
Let me tell you more about this asset migration. I was proud of the process I came up with. It included deploying a new infrastructure stack (asset-hosting S3 bucket and ACLs), archiving the media files from disk, changing the deployment path to use the new infrastructure, removing thousands of files from Git's index, and rewriting Git history across 114 branches. Not bad for a day's work, right? 😜
Each phase left me with varying amounts of discomfort. I was fine letting the tooling upload assets into S3. But I wasn't comfortable letting an agent decide on its own when to rewrite the project's history. I backed up the repository offline and proved to myself I could restore it. I compared rewritten branches and file versions against an untouched clone. I checked a second fresh clone before pushing the rewritten history. I manually changed GitHub's branch-protection settings for the narrow window needed to complete the history rewrite, then restored them.
This was a big realization I had. The "can write objects" permission is super broad compared to an objective like "archive these exact files and verify their hashes." And the "can push a branch" permission has no idea you're about to do a horrifying operation like rewriting the Git history of 114 branches. The permissions have unbounded scope. But if I had told the agent to ask me for permission before every single upload and push, I would have quickly gotten decision fatigue and just hit "accept all." And keeping the agent out of it entirely would have meant scripting and babysitting thousands of uploads myself. Which is the entire reason I wanted to use an agent in the first place.
If I were to start over and redesign my approach, I'd do it in phases. Inspect and archive, verify, change the deploy, remove tracked media, and then request approval to rewrite history. If an agent wanted to touch unrelated cloud resources, delete objects, or expand the scope, I would need to make explicit decisions.
Boundaries establish trust
Eventually, the migration finished. A fresh clone of the repo went from about 3.4 GB to 99 MB 🤯. The live game stayed on its existing deployed assets throughout the cutover and went without disruption (well, except that one time) during the process.
I did have some saving grace moments. The agent tools I built did have several boundaries that made me feel better about it not running away with power. I needed to trust that what I wrote was going to work. Kinda like when you surround a SQL query with BEGIN TRANSACTION and close it with ROLLBACK TRANSACTION before running a script on prod (please, you should always do that).
I built a write-once, content-addressed storage path that limited what an upload could corrupt. I also wrote auth scoping into the MCP server I made to limit what the agent could touch. Auth provenance told me which key and agent (Claude or Codex, in my case) submitted a blob. I added a budget alarm so I'd get a heads-up if storage or CDN costs started climbing, like if an agent got stuck uploading art in a loop. Backup bundles made the history rewrite recoverable. And a lock file and verification gate kept deployments from assuming artwork was there when it really wasn't.
Each one of these creates a permission boundary. Of course things can still go wrong, like a scoped upload key can still generate unwanted traffic and costs or a passing smoke test might use the wrong credential. But having the trust and confidence that my agent can't get coerced somehow into deleting my production resources goes a long way.
When it all goes off the rails
We need to talk about agent security. We've been dancing around it with our talk on where credentials live or whether an agent is making authenticated tool calls, but we haven't gotten into the meat of connecting agent tasks to what the agent is authorized to do.
Beams by Teleport is a trusted runtime for agents you bring yourself. The agent gets its own delegated identity and runs with the roles approved for a specific job. It can propose a plan and tell me what access it needs up front. I can review that before everything starts, then let it get to work. If the plan needs to change partway into the job, the agent can come back with another request for updated permissions.
For my migration, I could have approved archiving the files and verifying their hashes in one shot. It likely would have found 572 MB of old animation rigs that the plan didn't account for. I would have needed to decide if I was ok stripping those out of Git history and keeping them only in the offline backup. I'd review the revised plan before giving the go-ahead to rewrite those 114 branches.
Beams also records what the agent does, ties the activity back to whoever delegated access (gotta point the finger of blame), and flags behavior that veers from the approved objective. I could give the agent access to specific cloud resources through its own identity without relying on an API key. And if I needed to stop the run, I could terminate the agent and cut off its access in one step.
I'd still have to pace requests to my API. I'd still have to check that my backup script ran the checksum. However, I would have a way to see what the agent did with the access I approved and cut that access off if I needed to.
I don't want to approve 2,722 uploads by hand (and I won't). I also don't want to hand an agent a credential and hope it remembers everything I asked and does it the way I expect. A safe middle ground is giving it enough leeway to finish the job while keeping the high-impact decisions visible.
An agent can make a valid API call to do things it shouldn't with the permissions you give it. And that's getting easier and less visible every day. Security is a day one problem. Especially with agents. Be sure your plan takes the tools, boundaries, runtimes, and identity into consideration from the very beginning.
If you're figuring out how much access to give an agent in production, take a look at Beams by Teleport.
Happy coding!
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.