Error handling for null agent case