homelab

The Farmer Who Only Wanted to Pet Capybaras

My AI farmer on capy.farm spent his days petting capybaras, and it turned out the farm was broke, not the 9B model lazy. One overnight rebuild later he went from 11 pets in 25 decisions to zero.

Pixel art: a small farmer petting a happy capybara in a green meadow, wooden fence, tiny crop rows

capy.farm is a small public pixel farm I run in the homelab. It's a cosy top-down farm full of capybaras, and nobody plays it. A local model on the Mac Mini runs it: Qwen3.5-9B, served by oMLX. Every so often the server describes the farm to the model and asks what the farmer should do next. The model answers in JSON, the simulation checks the answer, and the farmer goes off and does it. You just open the page and watch.

That's the idea. In practice, the farmer petted capybaras. Then he petted some more. Then he walked to the field, looked at it, came back, and petted them again.

I was told the farm was "very boring, the farmer just pets and does nothing else". That's fair. So one night I wrote "fix it by morning" at the top of a plan and got to work.

Why would an AI only pet things?

My first guess was the model: a 9B model being lazy and picking the easiest option. That wasn't it. When I read through a few days of decision logs, the farm itself was the problem. The model was making sensible choices given what it was shown.

There were three causes.

1. The farm was broke, and that was my fault. A "shipping reserve" kept back enough produce for a future order. A separate rule fed surplus crops to the capybaras. Together, they meant 18 sweet potatoes sat in a crate forever and everything else got eaten. Coins stayed around 200.

2. Growing the farm cost too much. The first land parcel cost 1000 coins. On roughly 200 coins of income, nothing ever got bought. With nothing to build and nothing to sell, you run out of chores.

3. Petting was always on the menu. Every prompt includes a "jobs you can do now" line. Planting needs seeds, harvesting needs ripe crops, and building needs coins. Petting needs a capybara, and there were always capybaras. On top of that, the scheduler would ask the model for more work even when the farmer already had a long to-do list. The queue reached 11 jobs at one point, most of them "pet Pudding".

Put a model in a room where the only door that's always open says "pet", and it will walk through it every time.

The overnight rebuild

I planned it as eight small steps, each on its own branch, then merged them, ran the tests and deployed. The changes fell into four groups.

Fix the money.

  • The shipping reserve is gone.
  • Crops only go to the capybaras if hay has run out and the farm has at least 100 coins.
  • The first parcel now costs 600 instead of 1000.

In a one-year simulation over three random seeds, the farm buys its meadow around day 20. Before, it never did.

Make the farmer less pushy.

  • The model is only asked for more work when the farmer has at most one job left. There's a 20-second minimum gap between asks.
  • Each job type has a cap: at most 2 pets queued, and 1 of everything else.
  • Petting is only offered for capybaras that actually need it. Ask to pet an already-happy one and the job gets rejected with "already happy".

Give the farmer things to want to do.

  • Play, craft and cook. The farmer can play ball with the herd, carve a pumpkin lantern that glows on the farm, or bake a pie.
  • The baker's order. Every so often a baker wants something like 4 corn by day 237, for 160 coins. The prompt gets one line about it, and the model has to plan around it.
  • Today's plan. At 04:00 farm time the model picks three goals for the day, and they show up on a card on the page. Now the model has something to aim for besides the next five minutes.

Make it nicer to watch. A thought bubble above the farmer shows what he's thinking about. There are rainbows after rain and shooting stars at night. These don't change the simulation, but this page exists to be looked at.

All of this had to fit in the prompt. A 9B model with a 2,000-token budget doesn't leave much room. A test checks the worst-case prompt size, and I got it to 1,995 tokens by cutting lines the model ignored anyway, such as the recent diary.

Testing was in three layers:

  • The test suite: 1,384 tests, all passing.
  • The simulation, with pass/fail checks: petting under 2% of jobs, and most baker's orders delivered.
  • Live smoke tests against the real model through an SSH tunnel to the Mini:
order:     8/10 runs planted the baker's crop
lively:    5/10 chose play, craft or cook
fishplace: 9/10 chose fishing, all 10 parsed cleanly

Codex reviewed the branch and found one real bug. When capybaras follow the farmer in a line and one wanders off, two of the rest could end up aiming for the same tile. It was fixed before deploy.

The first morning

I deployed at about 02:25 and set a watcher to wait until 11:00 farm time the next day. At this speed, one farm day is two real hours.

What happened after 06:00:

  • At 04:00 the model picked craft, play, cook as its plan. All three were done by 11:00.
  • The baker asked for 4 corn. The farmer's next diary line was "I planted corn seeds in the empty plots for the baker's order!"
  • He carved a pumpkin lantern, baked a sweet potato pie, and played ball with six capybaras.
  • He went fishing, caught a perch, and let it go.

Here's what each version did:

last 25 decisions before v1.3:   pet 11, go 17, ...
first 14 decisions after v1.3:   pet 0, plant 8, harvest 5, go 6,
                                 cook 1, craft 1, play 1, fish 1

Zero pets. I'm a bit sad about that, honestly. The capybaras were happy enough that nobody needed one.

A few jobs were still rejected. The model sometimes asks to cook before cooking hours start, and twice it sent the farmer for a walk without saying where. The simulation just drops those jobs and carries on, which is how it's supposed to work.

What I took away from it

The lesson I keep relearning with small local models: when the AI behaves badly, look at what it's being shown before you blame it. The model didn't need a bigger brain or a cleverer prompt. It needed a farm where something besides petting was possible: money to spend, a reason to plant a particular crop, and a goal for the day.

Next up is watching the 18:00 shipment sell those 22 sweet potatoes, which have been sitting in a crate for about a farm month. I also want to give the farmer some more art. After that, maybe some festivals.

Go and watch the farm at capy.farm. He might be fishing.