Can Agents Manage a Colony? Running RimWorld with Strands Agents

Can Agents Manage a Colony? Running RimWorld with Strands Agents

How I connected Strand Agents to a live colony game, what broke along the way, the code that fixed it, and where one agent stopped being enough at a hundred colonists

Cloud Architect | DevOps | Kiro Pro | AI Engineering
Most of what I see AI agents do has a clear ending. They answer a question, fix a bug or book a meeting, and then they stop. The work I find more interesting never finishes. Running infrastructure, an operations queue or a small business means watching something that keeps changing, reacting when it goes wrong, and living with the decisions you made yesterday. I wanted to see how agents behave in that kind of work, and I needed a place to test it that was alive, unforgiving and completely disposable, because I expected the agents to break things.
This is the journey of how I got agents to run a small town inside a video game. It goes from a first attempt that never played at all to five people surviving almost four in-game days, and then to what happened when I gave the same agents a hundred. At each point where something broke, I'll show the code that fixed it, and at the end I'll show how to run the whole thing yourself. Most of that code is small, because Strands runs the agent loop for you.

The world, the colony and the test

The game is  RimWorld . A handful of people land on an empty map with a few supplies, and from then on they need food, shelter, sleep, medical care and some comfort, while the game throws animals, raiders, disease and bad weather at them. Each person has skills, likes and dislikes, and a mood. When mood drops too far, they stop working, lash out at others or wander off.
Time keeps moving whether you act or not, and you don't control the people directly. You give orders such as "build a wall here" or "this person cooks", and they carry them out as time passes. You don't need to know the game to follow this article: think of it as a small town that keeps running and can go wrong in many ways.
My test colony was five people starting with nothing built: no walls, no beds, no farm, and their supplies still packed and locked. The goal of the test was simple to say and hard to do: keep everyone alive and make the colony better for a fixed stretch of game time, with no checklist and no human help. Later in the article I'll show the exact goals I wrote down, because they changed as I learned what "better" had to mean. Along the way I also wanted to find out how far one agent could go before it needed help.

A few words on Strands Agents

 Strands Agents  is an open-source SDK from AWS for building AI agents. You give an  Agent  three things: a model, a system prompt and a set of tools, which are plain functions the model is allowed to call. Strands then runs what it calls the agent loop: the model reads the request, decides to call a tool, reads the result, and repeats until it has an answer or a limit stops it. The model can come from Amazon Bedrock, Anthropic or other providers, and switching between them is one line of code. I didn't care about that until halfway through, when I swapped models without touching anything else.
Four Strands features carry this story.  MCPClient  connects to an MCP server (the Model Context Protocol is an open standard for publishing tools that any agent can use) and turns its tools into agent tools, with a filter for which ones the agent sees. Hooks are small callbacks that Strands runs at fixed moments, such as just before or just after a tool call, and they can inspect, log or cancel what the agent is about to do. Limits and a cancel signal bound how long one agent call can run. And agents can be wrapped as tools for other agents, which is where the hundred-colonist test pointed.
intro to colony





First, I built a platform instead of a player

My first attempt explains every choice that came after it, so it's worth telling properly. Before the agent had made a single useful move, I had designed eleven agent roles, from an adviser and area specialists to a manager that settled their disagreements. Around them sat a rule engine that approved every action, a single component allowed to carry actions out, and a plan to deploy it all on Amazon Bedrock AgentCore. Each piece made sense on its own, which is why I kept saying yes. But the game's server only listens on my laptop, and an agent in the cloud can't reach my laptop without a tunnel that brings its own security and failure problems.
The worst problem was a gate I had built myself. The agent only got a turn if my code already had a pre-approved action for what the colony needed. The colony needed a research bench, but nobody had written a "place research bench" action, so the agent was skipped and never saw the rules it would have needed to suggest one. I called it an autonomous agent, but the model was picking from a menu I had written, and the menu was almost empty.
I also measured activity instead of results. Getting through one in-game day counted as success even when the colony had barely changed, and five bedrolls on open ground counted as shelter. My 500-credit budget existed only as text in a plan, and I spent about 2,000 credits, around $40, without getting anything that played the game. So that was a failure, and I had to start over. I kept three rules from it: put the agent next to the thing that is hardest to reach, keep the agent small with the controls around it in code, and measure the colony instead of the activity.



Starting over with an observability agent

The game talks to agents through RimMolt, a community add-on that turns RimWorld into an MCP server on my own machine. It has about 118 tools for reading the map, the people, the storage and the rooms, and for giving orders. For the restart I connected one agent, running on the same laptop as the game, and I only let it look. Strands'  MCPClient  takes the server URL, and a tool filter lets only the reading tools through (names starting with  get_ ,  list_ ,  find_ ,  inspect_  or  query_ ), so nothing the agent did could change the colony.
Reading came first for a reason. An agent can't act correctly on information that is wrong, and a model that answers confidently from a bad read is worse than one that says nothing. So the first question was not "what should we build?" but "is the game loaded and paused, and is anything urgent?", because I could check every word of the answer myself by calling the same status tool directly. The agent got it right: the colony's name, the day, five colonists, paused, and no danger. My automated test only checked that the reply contained text, so I compared the two by hand, and I kept that habit: read the world yourself before trusting what the agent says about it.
import os, re
from strands import Agent
from strands.models.anthropic import AnthropicModel
from strands.tools.mcp import MCPClient

READ_ONLY = re.compile(r"^(?:help|(?:find|get|inspect|list|query)_.+)$", re.IGNORECASE)

model = AnthropicModel(client_args={"api_key": os.environ["CC_API_KEY"]},
model_id="claude-sonnet-5-5", max_tokens=4096)
client = MCPClient(url="http://127.0.0.1:8787/mcp", startup_timeout=10,
tool_filters={"allowed": [READ_ONLY]})
with client:
agent = Agent(model=model, tools=client.list_tools_sync(),
system_prompt="Answer only from tool results.")
print(agent("Is the game loaded and paused, and what is urgent?"))



How does an agent know it knows enough?

The second request, "find a good place to build a base", went badly. The agent looked at the map one small patch at a time, more than 190 times, and kept going after I closed the client. I sat watching the call count climb, waiting for it to stop. It didn't. Every patch it looked at showed the edge of another patch it hadn't seen, and nothing told it when to stop. The game's server was fine. The problem was that I had asked an open question with no idea of what "enough" meant.
So I did the same task by hand to see how I knew enough. It took me six steps. I read the overall status, took one rough view of the whole map and found where the colonists were standing. Then I picked one candidate area near them, looked closely at its ground and walls, and checked that it could be roofed. I stopped there, because the goal was a good place, not the best place on the map, and the first candidate that passed every check was good enough.
"Enough" turned out to mean enough to make one decision, with a fixed number of candidates and a rule for when to stop. I wrote that method into the prompt and backed it with my first hook. Before each tool call, Strands runs the hook's  BeforeToolCallEvent  callback, and if the hook sets  event.cancel_tool , the tool doesn't run and that text goes back to the model as the result. The model reads why it was stopped and answers with what it has.
from strands.hooks import BeforeToolCallEvent, HookRegistry

class ToolBudgetHook:
def __init__(self, max_calls: int = 12) -> None:
self.max_calls, self.calls, self.seen = max_calls, 0, set()

def register_hooks(self, registry: HookRegistry, **_) -> None:
registry.add_callback(BeforeToolCallEvent, self.before_tool_call)

def before_tool_call(self, event: BeforeToolCallEvent) -> None:
signature = (event.tool_use["name"], str(event.tool_use.get("input")))
self.calls += 1
if self.calls > self.max_calls or signature in self.seen:
event.cancel_tool = "Budget reached. Answer from what you already observed."
self.seen.add(signature)
With the method and the budget, the next run used its 12 calls and stopped, instead of running until I killed it. The answer still wasn't good: it picked rough coordinates from the overview and called a 60-by-60 area "compact". The budget stopped the wandering. Pointing it at the right places was the prompt's job, and that split came back in every later stage.



Giving it hands, and finding out the guardrails weren't the problem


To let the agent act, I first built a careful path: order tools that checked every input, an approval step, a single component that sent the orders, and a fresh read of the game after every order. Running on Amazon Nova 2 Lite, it didn't produce a working colony. One run described a plan and changed nothing. Another filled a square with a solid wall. A third placed 169 doors. And then I found the cause: my own door tool filled the whole selected area by default.
When I removed all of that and gave Nova every tool directly, it did no better. The colony's starting supplies are locked until someone marks them usable, and it never unlocked them. My controls had never been the problem.
Because Strands keeps the model behind the  Agent  interface, trying a different model took one new module and nothing else. I split the work into three roles, each with its own Claude model. The planner (Opus) looks at the colony and writes a plan. The actor (Sonnet) carries out the plan by giving orders through many tool calls, and it's the agent I'll talk about most from here on. The reviewer (Haiku) reads a log of what happened afterwards and says what went wrong.
I also gave the agents short notes on what had worked in play, such as "unlock starting supplies one item at a time, because selecting a whole area silently fails". For this first run with hands, success was seven checks my code read from the game. They asked for a closed room with a door, a sleeping place inside for every colonist, a storage area and a table with two seats inside, a ring-toss game outside the door, and the game paused at the end. The first Claude run met all seven in 61 tool calls. That isn't a fair model comparison, because the setup also added a planning step and the notes, but it passed a bar the Nova setup never did.
from strands.types.agent import Limits

# role: (model id, max output tokens, USD per million tokens: input, output, cache read, cache write)
ROLES = {
"planner": ("claude-opus-5-5", 4096, (4.00, 20.00, 0.20, 5.00)),
"actor": ("claude-sonnet-5-5", 4096, (2.00, 10.00, 0.10, 2.50)),
"reviewer": ("claude-haiku-5-5", 2048, (0.10, 0.50, 0.01, 0.125)),
}

def build_model(role: str) -> AnthropicModel:
model_id, max_tokens, _ = ROLES[role]
return AnthropicModel(client_args={"api_key": os.environ["CC_API_KEY"], "max_retries": 5},
model_id=model_id, max_tokens=max_tokens)

all_tools = client.list_tools_sync()
read_tools = [t for t in all_tools if READ_ONLY.match(t.tool_name)]
act_tools = [t for t in all_tools if t.tool_name not in BLOCKED] # no save, load or time tools

planner = Agent(model=build_model("planner"), tools=read_tools, system_prompt=PLANNER_PROMPT)
plan = str(planner("Observe the colony and write the plan.", limits=Limits(turns=12)))
reviewer = Agent(model=build_model("reviewer"), tools=[], system_prompt=REVIEWER_PROMPT)
The roles differ only in model, tools and prompt. The planner gets the read-only tools, the actor gets everything except the tools my code keeps for itself, and the reviewer gets no tools at all, so it can only read the log I hand it. I trust this more than any check inside a tool. The agent can't misuse a tool it never gets. The prices in  ROLES  are only there so my code can estimate spend while a run is going, which comes back in the hooks section.



Taking the clock away from the agent

Who controls time shaped everything after this. In RimWorld, orders don't happen when you give them: while the game is paused, an order is only a note on a to-do list. The colonists carry it out when time runs, fetching the wood and building the wall piece by piece. So an agent has to give orders and then wait, meaning let game time pass, before it can see whether they worked. Game time is counted in ticks, 60,000 to an in-game day, and the game can run at different speeds or stay paused.
In my first attempt, the agent controlled the clock itself, and success was "get through a day". The cheapest way to reach that is to do nothing and let time run, and an agent that holds the clock will find the cheapest way.
So I split the work into two loops. Strands runs the inner loop: one call to the actor lets the model call tools, with the game paused, until it ends its turn or hits a  Limits  cap or a  cancel_signal  I trigger. I run the outer loop in plain Python: read the colony, write a short brief, start a fresh actor, then move time forward myself, about four in-game hours per cycle. The agent never sees the tools that save, load or speed up the game, so it can't skip ahead, and it can't count waiting as work.
def run_agent(role, tools, system_prompt, prompt, ledger, trace) -> str:
"""A fresh Strands agent for one role and one bounded turn."""
cancel = threading.Event()
agent = Agent(model=build_model(role), tools=tools, system_prompt=system_prompt,
hooks=[DenyListHook(), TraceHook(trace, role), GuardHook(ledger, role, cancel)],
callback_handler=None) # don't stream tokens to the terminal
return str(agent(prompt, limits=Limits(turns=20), cancel_signal=cancel))

for cycle in range(1, max_cycles + 1):
brief = colony_brief(client, cycle) # a fresh read of the game, every cycle
note = run_agent("actor", act_tools, ACTOR_PROMPT.format(plan=plan),
f"{brief}\nYour last note: {note}", ledger, trace)[:1500]
last_wait = advance(client, cycle_ticks) # Python moves time, never the model




When the game pauses itself

Moving time had its own surprise. The game pauses or slows itself whenever it wants your attention, and most of those moments don't need a decision. In my runs, letters (the game's pop-up messages) warned that a sealed ancient structure stood on the map, reported a mad hare, and described a wrecked war machine with a part inside worth salvaging. It also slows down on its own when something nearby looks risky. Only a few stops need an answer right away, such as hostile animals or raiders arriving.
My first version of the clock treated every stop the same and ended the cycle early. A four-hour cycle sometimes moved the game forward by less than half an hour, and three times by nothing at all. The run was planned as 12 four-hour cycles for 48 hours, spent its 18-cycle limit on small steps, and ended at 43 of 48 hours.
I went through my logs, listed every reason the game gave for stopping, and sorted them into two groups. Harmless ones are a letter, a notification, a slowdown, the all-clear after a threat, or simply reaching the target time. For those the code keeps waiting toward the end of the cycle, and the reasons go into the next brief so the actor can still read them. Anything else, such as  threatAppeared  or a reason I'd never seen, hands control back to a fresh actor at once.
BENIGN = {"timeout", "letter", "notification", "message", "forcedSlowdown",
"threatsCleared", "gameTicks", "tickLimit"}

def advance(client, ticks: int) -> list[str]:
target = status(client)["ticksGame"] + ticks
causes = []
while (remaining := target - status(client)["ticksGame"]) > 0:
wait = call(client, "wait_for_event",
{"maxGameTicks": remaining, "maxSeconds": 600, "pause": "always"})
causes.append(wait.get("cause"))
if not wait.get("ticksWaited") or wait.get("cause") not in BENIGN:
break # an attack, a crisis or an unknown stop: hand back now
call(client, "set_speed", {"action": "pause"})
return causes



Hooks became the control panel

Once the actor could change the colony and run for hours, I had three problems I couldn't solve with a better prompt. First, I had hidden the save, load and time tools, but I wanted a second lock in case one ever slipped through a filter. Second, I couldn't see what the agent had actually done, only what it said it had done, and those weren't always the same. Third, I needed a way to stop a run cleanly and a spending cap that actually stopped it, after the first attempt's budget that existed only as text. Each of these had to happen at a precise moment in the agent loop, which is what Strands hooks give you, and every control I needed ended up as one:
  • Deny-list hook ( BeforeToolCallEvent ): cancels any blocked tool before it runs. The logs show zero blocked attempts, so hiding the tools was enough and this hook stayed a backstop.
  • Trace hook ( AfterToolCallEvent ): writes one line per tool call, with its input, result and duration, to a log file. That log is what the reviewer reads and what I check after a run.
  • Guard hook ( AfterModelCallEvent ,  BeforeToolCallEvent ,  AfterInvocationEvent ): after each model call it prices the tokens used so far, and before the next tool runs it checks the Stop button and the dollar budget, cancelling the tool and setting the cancel signal if either trips. In my real runs the Stop button lived on a small web dashboard. In the example it's a file called  traces/STOP .
  • Tool budget hook ( BeforeToolCallEvent ): the one from the map search, which caps calls and refuses exact repeats.
from strands.hooks import AfterInvocationEvent, AfterModelCallEvent, AfterToolCallEvent

class DenyListHook:
def register_hooks(self, registry, **_):
registry.add_callback(BeforeToolCallEvent, self.before_tool)

def before_tool(self, event):
if event.tool_use["name"] in BLOCKED: # save_game, load_game, set_speed, ...
event.cancel_tool = f"{event.tool_use['name']} is reserved for the harness."

class GuardHook:
def __init__(self, ledger, role, cancel):
self.ledger, self.role, self.cancel, self.current = ledger, role, cancel, 0.0

def register_hooks(self, registry, **_):
registry.add_callback(AfterModelCallEvent, self.after_model)
registry.add_callback(BeforeToolCallEvent, self.before_tool)
registry.add_callback(AfterInvocationEvent, self.after_invocation)

def after_model(self, event):
self.current = cost_usd(event.agent.event_loop_metrics.accumulated_usage, self.role)

def before_tool(self, event):
if STOP_FILE.exists() or self.ledger.spent + self.current >= self.ledger.budget_usd:
event.cancel_tool = "Stop or budget reached. End your turn now with your short note."
self.cancel.set()

def after_invocation(self, event):
self.ledger.spent += self.current # shared across every fresh agent
None of these hooks costs an extra model call, and two of them caught real bugs. My first budget never tripped, because I had turned on prompt caching to save money and almost all input then arrived as cached reads, which my counter ignored. Caching didn't change how the agent played. It was purely a cost setting, and the bug was in my accounting. Strands reports cached reads and writes separately in  accumulated_usage , so  cost_usd  now prices each kind on its own.
The trace also caught my reviewer being wrong. Haiku's review of my first two-day run said nobody had defended the colony, but the trace showed the actor calling two colonists to arms and sending them after a wild coyote. Two armed colonists chasing one coyote is a lot of things, but it isn't "nobody". The log was 281 KB, and the reviewer only saw its last 60,000 characters. In another run a building query returned more data than the game's server allows, my code read the error as "no buildings", and the agent had built a room my own checks couldn't see. The agent had done the job. My code was the part that failed.



Two days alive, but nobody built a home


  For the timed runs I replaced the seven checks with goals, because a colony that only has to survive two days can do it sleeping in a field. In the game, sleeping outside on the ground costs mood every night, and low mood ends in breakdowns days later, so a home is what keeps a colony alive after the test window ends. The actor got five goals in priority order. Survive first by reacting to attackers, fires and injuries, then keep three to five days of food, then build closed, roofed rooms with a bed for everyone. After that comes mood (somewhere to eat, something to do, rooms that aren't ugly), and only then research and improvements.
The first two-day run kept all five colonists alive, but nobody built a home. The actor ordered beds and never came back to them, because its only memory between cycles was a 1,500-character note, and "beds ordered" didn't tell the next actor to check. I fixed it with memory the model can't forget. Each cycle, Python reads every planned or half-built structure from the game and remembers when it first appeared. Anything stuck for two or more cycles goes at the top of the actor's prompt as STALLED, with an instruction to fix it before starting anything new.
first_seen: dict[str, int] = {}

def construction_brief(client, cycle: int) -> str:
global first_seen
things = call(client, "list_things", {"category": "construction"}).get("things", [])
open_now = {t["id"]: t["def"] for t in things}
first_seen = {i: first_seen.get(i, cycle) for i in open_now} # drop finished, keep ages
stalled = [f"{d} {i}" for i, d in open_now.items() if cycle - first_seen[i] >= 2]
return f"Open construction: {len(open_now)}; STALLED: {stalled[:12] or 'none'}"
With that tracker, a fresh Opus plan every in-game day and the dollar budget, the next two-day run was clean: 12 cycles, $1.56, a shared bedroom of 63 tiles with nine beds, and nothing left half-built. My own measure has a gap, though: a structure disappearing from the list means "finished or cancelled", not proven built. When I added the game's room-quality score to the brief (below zero means the room makes people unhappy), the bedroom improved from -47 to -29. But the unhappiest colonist dropped to a mood of 29, because Tasca was starving while 154 meals sat in storage. A better average can hide a worse individual, so I started reporting both.



Memory belongs to the code

Looking back over these fixes, I saw a pattern I hadn't planned. Every problem of continuity, meaning carrying what happened before into the next cycle, was solved by plain code that reads the game, not by asking the model to remember. The brief, the STALLED list and the daily re-plan all start from a fresh read of what is actually built, and the dollar ledger, the clock and the saves live in the harness, the Python code around the agents. The model does the part only a model can do: read a messy situation and decide what to do next. Each time I asked it to remember something across cycles it eventually didn't, and each time I moved that job into code, the problem stopped coming back.



How the prompts and the checks grew

None of the goals or prompt rules above existed at the start. Each one came from a run that failed in a specific way. The seven checks came from the first run with hands and were about one room. The timed runs needed goals for a living colony, so the checks became the five priorities. Then "beds ordered, never built" added the STALLED list and this rule at the top of the actor's prompt:
FOLLOW THROUGH FIRST: every cycle starts with a "Construction follow-up" list read fresh by the
harness. Anything marked STALLED has not progressed for 2 cycles: before placing new blueprints,
find out why (forbidden or missing material, nobody assigned to Construction, a higher-priority
job, unreachable cell) and fix it, or cancel it and build a cheaper alternative.
A room counts only when it is built, enclosed and roofed, not when its blueprint is placed.
A room that was built but scored as ugly by the game added a room-quality rule: fix the worst problem first, such as rubble on the floor or bare dirt, and lay a floor. Tasca starving next to full storage added the unhappiest colonist's mood to the brief, beside the average.
The knowledge notes grew the same way. They started from an earlier project where a model played the same game through the same server, and each note is a fact the tool descriptions don't tell you, confirmed in play. Unlocking supplies only works one item at a time. A job priority of 1 is silently stored as 3 until you set some other priority to 2 first, and a failed construction attempt destroys the half-built frame and its materials. My code loads these notes into the planner's and actor's prompts, and although the prompt grew from a few lines to a page, I can still say which run put each line there.



Almost four days, then the connection dropped

The longest five-colonist run aimed for seven in-game days and lasted almost four. A crazed animal attacked and a coyote showed up, and the actor did what a player would. It called colonists to arms, which in the game means taking direct control of them as fighters instead of letting them work, dealt with both animals, and then released everyone back to their jobs.
Then Wolle, the colony's only doctor, was badly hurt and lying on the ground with nobody treating him. The actor changed the work assignments so Gray became the doctor, and had Gray treat and feed him. Nobody had written a rule for "the doctor is the patient". I rewatched the timelapse of the open camp turning into a walled bedroom more than once. It was the first run that looked like someone was actually running the colony.
The run also found two gaps no shorter run had tested. There was never an indoor storeroom, because my goals ranked storage last and none of my checks asked for one. And at about 88 in-game hours the game's server stopped answering: RimMolt closed the connection, and every attempt to reconnect failed. My code didn't crash. It hung, waiting forever for a reply that would never come, and never reached the line that checks for Stop, so I killed the process by hand and the final review never ran.




Deciding how long anything may wait

That hang made me ask a question I had skipped: how long is each piece of this allowed to take, and what happens by default if I never say? In Strands,  Limits  is off unless you set it, so one agent call has no turn cap by default. An MCP tool call through  call_tool_sync  has no timeout by default either, so a dead server means waiting forever. The Anthropic client does have defaults: ten minutes per request and two retries. Strands' cancellation is cooperative: the cancel signal and the hooks only act between model and tool calls, and a hung call in my own Python never gets back to them.
So I set my own. The actor gets 20 turns per cycle and is told to take about 15 actions. Every call my code makes to the game has a 30-second timeout, except the clock's wait, which can take up to ten minutes of real time and gets eleven, so a dead connection now raises an error instead of hanging. The model client retries five times instead of two, and the whole run has a dollar budget and a cycle cap. I'd also save the game from code once per in-game day so a crash can resume.
def call(client, name, args=None, timeout_s=30):
result = client.call_tool_sync(f"harness-{name}", name, args or {},
read_timeout_seconds=timedelta(seconds=timeout_s))
if result.get("status") == "error":
raise RuntimeError(f"{name} failed: {str(result.get('content'))[:300]}")
return json.loads(result["content"][0]["text"]) # a ten-minute wait uses timeout_s=660




From five colonists to a hundred

Five colonists are easy to keep in your head. To find where one agent stops being enough, I gave the same code and the same three agents a hundred colonists on the hardest difficulty, with nothing built and every weapon lying on the ground. The only code change was the name of the save it was allowed to use. Before spending anything, I ran a read-only probe to measure two things.
The status report is what the game returns when my code asks for the colony's overall state, including every colonist. The brief is the short summary my code writes from it for each fresh actor: the day, any danger, the food count, and one line per colonist with mood, health and current job. With a hundred people, the status report alone came back at 24,659 characters, and the brief grew to about 1,400 tokens, around twenty times the size for five colonists.
Size matters for two reasons. The brief is part of every model call the actor makes in a cycle, so it's paid for again on every turn. More importantly, it's a hundred lines of problems for an agent that has about 15 actions to spend. With five colonists, the brief is a short list and the actor can deal with all of it. With a hundred, it has to choose, and whatever it doesn't choose waits four hours for the next actor.
The planner did well. It read the colony correctly: the starting food would last about twelve days for a hundred people, so food wasn't urgent. It expected large raids early, because a richer colony draws bigger attacks, and its first instruction was to arm people, with archers at the bedroom doors. As plans go, I'd call it good.
The actor started well. In the first cycle it laid out two shared bedrooms for fifty people each, a hundred sleeping spots, a storage area and a rice field. By the fourth cycle it was losing the thread. It queued 539 wooden floor tiles to fix the game's "ugly surroundings" penalty, while its own note said most colonists were idle and it didn't know why. Its bulk orders kept the cost per cycle about the same as with five colonists, but its attention didn't scale.
Within eighteen in-game hours, average mood fell from 50 to 19, one colonist hit zero, twenty-two were close to a breakdown, and one had already lashed out at the others. The worst moods came from personal causes, such as pain or beliefs particular to one colonist, which a colony-wide fix like floors does nothing for. I also had help the agents didn't. At my request, a separate AI assistant working outside the harness gave equip orders to all hundred colonists during the first cycle and later walled in the storage areas, so I count those as outside help, not the actor's work. Then the server stopped answering again, and I stopped the run at $1.53.





Splitting the work

One agent with a good brief could manage a small group, but a large one needs the work divided, the same way a real team would divide it. Strands already has the piece for that: an agent wrapped as a  @tool  that another agent calls. The  @tool  decorator turns the function's name, arguments and docstring into a tool spec, so to the overseer a specialist looks like any other tool.
from strands import tool

@tool
def medic(task: str) -> str:
"""Treat injured and sick colonists. Give the names and the problem."""
return run_agent("actor", medical_tools, MEDIC_PROMPT, task, ledger, trace)

overseer = Agent(model=build_model("planner"), tools=[medic, builder, defense],
system_prompt="Read the scout's report and give each specialist one task.")
overseer(scout_report)
That snippet is a design sketch I haven't run yet. Each specialist keeps its own short tool list and its own hooks, so the medic can't call colonists to arms and the defense agent can't rebuild the bedroom. A cheap Haiku scout could boil a hundred colonists down to one report, and an Opus overseer could route work without reading the whole colony. Narrow specialists would each own one area: rooms and storage, hauling, medicine or defense. It's the team I designed at the very beginning, except this time a run has shown why it's needed, and it only stays if it beats the single actor on the same hundred-colonist save.




If you want to try it yourself

You need RimWorld with the RimMolt mod on the same machine as the agent, Python 3.12,  uv , and an Anthropic API key. Everything runs on your laptop, so there is nothing to deploy or tear down in a cloud account. Make a throwaway save first, because the agent will change the colony; mine was five colonists starting with nothing.
Start with the dry run, which connects and reads the colony without calling a model, so it costs nothing. Then run a short session with a hard budget.
git clone https://github.com/llamojha/article-cb-speed-run-2 && cd article-cb-speed-run-2
uv init --bare --python 3.12
uv add "strands-agents==1.56.0" "anthropic==1.12.1" "mcp"
echo 'CC_API_KEY=<your Anthropic API key>' > .env # .gitignore already skips it
uv run python examples/minimal_colony_loop.py --dry-run
uv run --env-file .env python examples/minimal_colony_loop.py --hours 8 --max-cycles 3 --budget-usd 1
touch traces/STOP # clean stop, from another terminal
jq -r .tool traces/minimal-*.jsonl | sort | uniq -c | sort -rn | head # what did it actually do?
My two-day runs came to $1.56 and $2.25, the almost-four-day run $4.48, and eighteen hours with a hundred colonists $1.53. Those are estimates from the token counts Strands reports at Anthropic's list prices, not a bill. To check a run, look at the game rather than the agent's report: the number of colonists should match, the count of unfinished structures should go down from cycle to cycle, and no blocked tool should appear in the trace. To clean up, stop the run, reload your save if you want to start over, delete  traces/ , and revoke the API key if you made one just for this.



What a colony taught me about infrastructure

I started this because the work I care about never finishes, and a colony turned out to be a fair stand-in for it. Most of what I fixed would look the same on an agent that watches servers or works an operations queue. The clock belongs to code, the way a scheduler owns when jobs run, and every call to the outside world needs a timeout because the defaults will wait forever. The real state of the system beats the agent's report of it, and one agent's attention runs out long before its budget does. On security, the agent only reaches a server on my own machine and the save and time tools are both hidden and blocked, which is the boundary I'd keep for anything with real stakes.
So, can agents manage a colony? Five people, yes, for days, with Python holding the clock and the memory and Strands hooks holding the controls. A hundred, not yet with one agent. If you're building an agent for work that never ends, start where I should have: one small agent next to the system, read-only until it says true things, and every control in code. Then give it a colony, or a queue, and watch what it forgets.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article