File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1010if TYPE_CHECKING :
1111 from mesa_llm .llm_agent import LLMAgent
1212
13- if TYPE_CHECKING :
14- from mesa_llm .llm_agent import LLMAgent
15-
1613
1714@tool (tool_manager = trader_tool_manager )
1815def move_to_best_resource (agent : "LLMAgent" ) -> str :
@@ -80,12 +77,21 @@ def propose_trade(
8077 )
8178
8279 if other_agent is None :
83- return f"Agent { other_agent } not found."
80+ return f"Agent { other_agent_id } not found."
8481
8582 if not isinstance (other_agent , Trader ):
8683 return f"agent { other_agent_id } is not a valid trader."
8784
8885 # Simple trade acceptance logic for demonstration
86+ if sugar_amount <= 0 or spice_amount <= 0 :
87+ return "sugar_amount and spice_amount must be positive."
88+
89+ if agent .sugar < sugar_amount or other_agent .spice < spice_amount :
90+ return (
91+ f"agent { agent .unique_id } or agent { other_agent_id } "
92+ "does not have enough resources for this trade."
93+ )
94+
8995 if other_agent .calculate_mrs () > agent .calculate_mrs ():
9096 agent .sugar -= sugar_amount
9197 agent .spice += spice_amount
You can’t perform that action at this time.
0 commit comments