- Add terminated→idle as a valid state transition in AGENT_VALID_TRANSITIONS - Add resetAgent() method that clears lastError, taskId, and ends heartbeat runs - Clear lastError automatically when transitioning away from terminated state - Remove inline heartbeat lifecycle from updateAgentState (moved to resetAgent) - Add comprehensive tests for state transitions, error clearing, and resetAgent behavior