@@ -72,7 +72,7 @@ def __init__(
7272 self ,
7373 model : Model ,
7474 model_reporters : dict [str , Callable ] | None = None ,
75- agent_reporters : dict [str , str ] | None = None ,
75+ agent_reporters : dict [str , str | Callable ] | None = None , # <-- ALLOWS CALLABLE
7676 trigger : Callable [[Any ], bool ] | None = None ,
7777 reset_memory : bool = True ,
7878 storage : Literal [
@@ -92,7 +92,10 @@ def __init__(
9292 model_reporters : dict[str, Callable] | None
9393 Functions to collect data at the model level.
9494 agent_reporters : dict[str, str | Callable] | None
95- Attributes or functions to collect data at the agent level.
95+ (MODIFIED) A dictionary mapping new column names to existing
96+ column names (str) or callables. Callables are not currently
97+ processed by the agent data collector but are allowed for API compatibility.
98+ Example: {"agent_wealth": "wealth", "age_in_years": "age"}
9699 trigger : Callable[[Any], bool] | None
97100 A function(model) -> bool that determines whether to collect data.
98101 reset_memory : bool
@@ -108,10 +111,14 @@ def __init__(
108111 """
109112 if agent_reporters :
110113 for key , value in agent_reporters .items ():
111- if not isinstance (value , str ):
114+ if not isinstance (key , str ):
112115 raise TypeError (
113- f"Agent reporter for '{ key } ' must be a string (the column name), "
114- f"not a { type (value )} . Callable reporters are not supported for agents."
116+ f"Agent reporter keys must be strings (the final column name), not a { type (key )} ."
117+ )
118+ if not (isinstance (value , str ) or callable (value )):
119+ raise TypeError (
120+ f"Agent reporter for '{ key } ' must be either a string (the source column name) "
121+ f"or a callable (function taking an agent and returning a value), not a { type (value )} ."
115122 )
116123
117124 super ().__init__ (
0 commit comments