Hello Ray/RLlib community,
I’ve noticed a potential discrepancy in the RLlib documentation, specifically concerning the required signature for the policy mapping function (policy_mapping_fn) within AlgorithmConfig.multi_agent.
Documentation URL:
The Issue:
The current documentation states the required signature for policy_mapping_fn as:
policy_mapping_fn: (agent_id, episode, worker, **kwargs) -> PolicyID
However, when configuring multi-agent environments using the New API Stack (based on Algorithm and RLModule), including the worker argument in the function definition raises a TypeError (got an unexpected keyword argument 'worker').
Working Signature (New API Stack):
The function signature that successfully executes in the current New API Stack is:
def policy_map_fn(agent_id, episode, **kwargs):
# Mapping logic
return "my_policy_id"
Documented/Old API Signature:
The signature including worker seems to be required only for the Older API Stack or specific low-level use cases:
def policy_map_fn(agent_id, episode, worker, **kwargs):
# Mapping logic
return "my_policy_id"
Request/Suggestion:
To prevent confusion and runtime errors for users adopting the New API Stack, I suggest updating the AlgorithmConfig.multi_agent documentation to clearly differentiate between the required signatures:
-
Indicate the New API Stack signature (omitting
worker) as the primary or default usage. -
Explicitly mention that the signature including
workeris associated with the Older API Stack.
Thank you for your consideration in clarifying this detail for the community!