Chain of Agents: Large Language Models Collaborating on Long-Context Tasks