GuardAgent: Safeguard LLM Agents by a Guard Agent via Knowledge-Enabled Reasoning