google-deepmind / google-deepmind/concordia
Bug: Phase Validation Bypass in EntityAgent Exception Handlers
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 367
- PR merge metrics
- No merged PRs in 30d
Description
Exception handlers in `act()` and `observe()` methods call `self.set_phase()` instead of `self._set_phase()`, bypassing phase transition validation.
### Root Cause
Two methods exist for setting phase:
- `_set_phase()` (line 97): ✓ Validates transitions via `check_successor()`
- `set_phase()` (line 266): ✗ Sets phase directly without validation
Exception handlers incorrectly use the public method that skips validation.
### Impact
During error recovery, agent can be forced into invalid phase state, causing:
- Invalid agent state after exception recovery
- Downstream errors from invalid phase transitions
- Race conditions in multi-threaded scenarios
### Current Code (lines 187-191, 209-213)
```python
except Exception:
self.set_phase(entity_component.Phase.READY) # BUG: No validation
raise
```
### Fix
```python
except Exception:
self._set_phase(entity_component.Phase.READY) # Fixed: Validates transition
raise
```
This ensures phase transitions are validated even during error handling.
Contributor guide
Research direction
Start in the act() and observe() exception handlers at lines 187-191 and 209-213, then compare their set_phase() calls with _set_phase() at line 97 and set_phase() at line 266. Update both handlers to preserve phase-transition validation and verify that exception recovery no longer bypasses the documented checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100