The Agent Loop: Why AI Agents Fail as Tasks Get Longer