Skip to content

fix(pettingzoo): fix action space resolution, error message formatting and agent cleanup - #6345

Open
reginaldalfret wants to merge 1 commit into
Unity-Technologies:developfrom
reginaldalfret:fix/pettingzoo-action-cleanup
Open

reginaldalfret wants to merge 1 commit into
Unity-Technologies:developfrom
reginaldalfret:fix/pettingzoo-action-cleanup

Conversation

@reginaldalfret

Copy link
Copy Markdown

Proposed change(s)

  1. Discrete Action Space Resolution in Mixed Action Spaces: In _update_action_spaces, when an action spec has single discrete branch (\discrete_size == 1) along with continuous actions (\continuous_size > 0), the subsequent \if act_spec.discrete_size > 0:\ branch previously overwrote \d_space = spaces.Discrete(...)\ with \spaces.MultiDiscrete(...). Changed to \elif act_spec.discrete_size > 1:\ so single-branch discrete space correctly retains \spaces.Discrete.
  2. Action Space Error Formatting: In _process_action, the error message referenced {self.action_space}\ instead of {current_action_space}, which printed Python's <bound method ...>\ string representation instead of the space definition.
  3. Safe Agent Cleanup: In _cleanup_agents, guarded .remove(current_agent)\ with \�nd current_agent in self._live_agents\ and .get(...)\ to avoid unhandled \ValueError: list.remove(x): x not in list\ when terminated agents are cleaned up or already removed.
  4. Regression Tests: Added unit tests in \ est_pettingzoo_wrapper.py\ verifying error message formatting and safe agent cleanup.

Types of change(s)

  • Bug fix

Checklist

  • Added tests that prove my fix is effective or that my feature works

…g and agent cleanup

- Fix discrete action space resolution so single-branch discrete space retains spaces.Discrete instead of being overwritten by MultiDiscrete in mixed action spaces
- Fix invalid action error message formatting to display current_action_space rather than bound method representation
- Guard _cleanup_agents against ValueError when terminated agent is already removed from _live_agents
- Add regression unit tests in test_pettingzoo_wrapper.py
@reginaldalfret
reginaldalfret requested a review from a team as a code owner November 14, 2026 10:48
@CLAassistant

CLAassistant commented Nov 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants