Bug Description
In netsecgame/game/coordinator.py:676, the _remove_agent_from_game method uses any(self._reset_requests.values()) to decide whether to trigger a game reset after an agent quits. The correct check is all(self._reset_requests.values()), which is the same logic used in _process_reset_game_action at line 424.
Using any() means that if even one remaining agent has requested a reset, the game reset is triggered immediately — even though other agents are still actively playing and have not requested a reset. This causes a premature, unsolicited game reset that corrupts the episode for all remaining agents.
Root cause
# Line 674-677 (_remove_agent_from_game) — BUGGY
agent_info["reset_request"] = self._reset_requests.pop(agent_addr)
# check if this agent was not preventing reset
if any(self._reset_requests.values()): # <-- BUG: should be all()
self._reset_event.set()
Compare with the correct logic used when agents explicitly request resets:
# Line 424 (_process_reset_game_action) — CORRECT
if all(self._reset_requests.values()):
# all agents want reset - reset the world
self._reset_event.set()
Steps to Reproduce
- Start a game with 3 agents (e.g., 2 Attackers + 1 Defender)
- Agent A requests a game reset (sets
_reset_requests[A] = True)
- Agents B and C are still playing (
_reset_requests[B] = False, _reset_requests[C] = False)
- Agent C sends
QuitGame
_remove_agent_from_game pops C's reset request, then checks any({A: True, B: False}.values()) which is True
_reset_event.set() fires — the game resets even though Agent B never requested it
Agent B's in-progress episode is destroyed. The _reset_game task resets all agent states, trajectories, and rewards.
Expected Behavior
After an agent quits, a game reset should only be triggered if all remaining agents have requested a reset. Line 676 should use all() instead of any():
if all(self._reset_requests.values()):
self._reset_event.set()
This matches the existing logic at line 424 and the comment at line 675 ("check if this agent was not preventing reset").
Version
1.1
Installation / Deployment Method
Running locally from source
Bug Description
In
netsecgame/game/coordinator.py:676, the_remove_agent_from_gamemethod usesany(self._reset_requests.values())to decide whether to trigger a game reset after an agent quits. The correct check isall(self._reset_requests.values()), which is the same logic used in_process_reset_game_actionat line 424.Using
any()means that if even one remaining agent has requested a reset, the game reset is triggered immediately — even though other agents are still actively playing and have not requested a reset. This causes a premature, unsolicited game reset that corrupts the episode for all remaining agents.Root cause
Compare with the correct logic used when agents explicitly request resets:
Steps to Reproduce
_reset_requests[A] = True)_reset_requests[B] = False,_reset_requests[C] = False)QuitGame_remove_agent_from_gamepops C's reset request, then checksany({A: True, B: False}.values())which isTrue_reset_event.set()fires — the game resets even though Agent B never requested itAgent B's in-progress episode is destroyed. The
_reset_gametask resets all agent states, trajectories, and rewards.Expected Behavior
After an agent quits, a game reset should only be triggered if all remaining agents have requested a reset. Line 676 should use
all()instead ofany():This matches the existing logic at line 424 and the comment at line 675 ("check if this agent was not preventing reset").
Version
1.1
Installation / Deployment Method
Running locally from source