AI Agents: Theory and Practice