Skip to content

Bug: Phase Validation Bypass in EntityAgent Exception Handlers #238

@manaspros

Description

@manaspros

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)

except Exception:
  self.set_phase(entity_component.Phase.READY)  # BUG: No validation
  raise

Fix

except Exception:
  self._set_phase(entity_component.Phase.READY)  # Fixed: Validates transition
  raise

This ensures phase transitions are validated even during error handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions