HERA: Hybrid Edge-cloud Resource Allocation for Cost-Efficient AI Agents