过去,长时间运行的智能体一旦开始,就只能等它结束或停止后再补充信息。现在可以边运行边发送内容。消息会等待当前工具完成,在智能体下一步之前传给模型,并由同一次运行继续回答。
在应用中使用
IaGenify Beta 和桌面应用会在运行期间保持消息框可用。待处理消息会显示为一个标签,在智能体读取前都可以移除;读取后,它会进入对话,智能体继续回答。Design、Workflows 和 Mail 编辑器中的智能体面板也支持此功能。
在 SDK 中使用
const running = agent.run({ message: "Clean up the Notes folder" });
// Later, while a tool is still running:
agent.queue("Also keep a copy of plan.md");
// { queued: true, id: "u1", position: 1 }
const result = await running;
result.unsent; // only present if a message was never read`queue()` 会立即返回。如果当前没有运行,它会告知你且不保存消息,这样你可以把内容作为新消息发送。如果运行在读取前结束——例如被停止或预算耗尽——消息会出现在 `result.unsent` 中。
在 Python 中使用
Python 的 `agent.run()` 会阻塞当前线程,因此应从另一个线程调用 `queue()`;此接口支持线程安全调用。该功能随 Python SDK 0.2.0 提供。
import threading
worker = threading.Thread(target=lambda: agent.run(message="Clean up the Notes folder"))
worker.start()
agent.queue("Also keep a copy of plan.md")
worker.join()文档
常见问题
排队消息会打断正在运行的工具吗?
不会。当前工具会先完成,消息会在下一次模型调用前读取。
如果我停止智能体会怎样?
未读消息会被退回,而不是发送。在应用中,它们会回到消息框。