Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions concordia/agents/entity_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@ def act(
except Exception:
# Ensure correct error handling in the case of multiple threads
# using the same entity by setting the phase to ready before raising.
self.set_phase(entity_component.Phase.READY)
try:
self._set_phase(entity_component.Phase.READY)
except ValueError:
# The failure interrupted a phase transition (e.g. inside
# PRE_ACT), so there is no valid successor to READY. Reset the
# phase directly to keep the entity usable for other threads.
self.set_phase(entity_component.Phase.READY)
raise
finally:
self._active_capture_key = self._agent_name
Expand Down Expand Up @@ -207,7 +213,13 @@ def observe(self, observation: str) -> None:
except Exception:
# Ensure correct error handling in the case of multiple threads
# using the same entity by setting the phase to ready before raising.
self.set_phase(entity_component.Phase.READY)
try:
self._set_phase(entity_component.Phase.READY)
except ValueError:
# The failure interrupted a phase transition (e.g. inside
# PRE_OBSERVE), so there is no valid successor to READY. Reset
# the phase directly to keep the entity usable for other threads.
self.set_phase(entity_component.Phase.READY)
raise
finally:
self._active_capture_key = self._agent_name
Expand Down
Loading