Conversation
for more information, see https://pre-commit.ci
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #259 +/- ##
==========================================
+ Coverage 90.67% 90.78% +0.10%
==========================================
Files 19 19
Lines 1555 1573 +18
==========================================
+ Hits 1410 1428 +18
Misses 145 145 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @colinfrisch , @sanika-n |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63f93fb3a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
examples/agriculture_model/agent.py
Outdated
| self.land_size = random.randint(1, 5) | ||
| self.wealth = random.randint(1000, 50000) | ||
| self._base_internal_state = list(self.internal_state) | ||
|
|
||
| self.crop_type = random.choice(["wheat", "rice", "maize"]) |
There was a problem hiding this comment.
Use the model RNG for seeded farmer attributes
When a user reruns the example with the same Random Seed, these fields are still drawn from Python's global random module, so the seed only stabilizes grid placement, not land size / wealth / crop type (and compute_yield() also uses random.uniform). That makes the new seed control misleading and breaks reproducibility for experiments based on this example.
Useful? React with 👍 / 👎.
| self.memory = STLTMemory( | ||
| agent=self, | ||
| llm_model="ollama/llama3.1:latest", | ||
| display=True, |
There was a problem hiding this comment.
Pass the configured llm_model into STLTMemory
If someone follows the new example docs and switches app.py to OpenAI or Gemini, the agent still creates its memory backend with hard-coded ollama/llama3.1:latest. Once the short-term buffer fills and memory consolidation runs, the simulation will try to talk to a local Ollama server even though the main agent model is configured differently, which turns the example into a runtime failure after a few steps for non-Ollama setups.
Useful? React with 👍 / 👎.
examples/agriculture_model/tools.py
Outdated
| if agent.crop_state == CropState.IDLE: | ||
| return "No crop planted" | ||
|
|
||
| agent.fertilizer += level | ||
| if agent.crop_state == CropState.PLANTED: |
There was a problem hiding this comment.
Reject fertilizer after a crop becomes READY
Once current_day reaches harvest_date, update_crop_state() marks the crop READY, but this tool still increments agent.fertilizer for that state. Because harvest_crop() immediately feeds the final fertilizer level into compute_yield(), any agent that fertilizes on or after harvest day can inflate yield and profit without affecting growth time, which corrupts the simulation outputs whenever the LLM chooses that action.
Useful? React with 👍 / 👎.
examples/agriculture_model/agent.py
Outdated
| self.yield_output = base_yield * rain_factor * fert_factor * noise | ||
| price = self.model.market_price[self.crop_type] | ||
| self.profit = self.yield_output * price |
There was a problem hiding this comment.
Accumulate profit across harvests
model.py reports Total Profit and Average Profit by summing a.profit, but this assignment overwrites the previous value on every harvest. As soon as a farmer completes a second crop cycle (for example by choosing a short days_to_harvest, or just because the run keeps going), all earlier revenue is discarded and the charts only reflect the latest harvest per agent.
Useful? React with 👍 / 👎.
| self.current_day += timedelta(days=1) | ||
| self.agents.shuffle_do("step") | ||
| self.datacollector.collect(self) |
There was a problem hiding this comment.
End the run after the 120-day season
The example is described as a single farming season, but step() only advances the date, steps agents, and keeps collecting metrics forever. In the Solara app that means farmers can keep replanting indefinitely unless the user stops the run manually, so the reported crop-state and profit curves stop representing one season's outcome and drift upward over time.
Useful? React with 👍 / 👎.
for more information, see https://pre-commit.ci
This PR introduces a new Agriculture Decision Model built using Mesa + Mesa-LLM.
The model simulates farmer decision-making under uncertainty, incorporating factors such as rainfall variability, market prices, and social influence. Farmer agents use LLM-based reasoning and tool execution (planting, fertilizing, harvesting) to manage crops over a season.
The model tracks key metrics including total yield, profit, and crop distribution, and demonstrates how reasoning-driven agents adapt to environmental conditions.
Here is the reasoning:-

