Remote Agent

Remote Session API

RemoteAgent 下 session 可用的核心方法和能力边界

Remote Session API

通过 RemoteAgent 拿到 session 后,最常用的方法有:

  • getInfo()
  • prompt()
  • subscribe()
  • history()
  • system()
  • fork()

这些 API 尽量和本地 session 的使用面保持一致,方便你在本地和远程模式之间复用同一套心智模型。

获取 session

const session = await agent.createSession();

如果你要继续一个已有远程会话:

const session = await agent.getSession("repo-analysis");

这样就可以切换到一个已知远程 session,而不是每次都从头开始。

发起一轮 prompt

const turn = await session.prompt({ query: "继续" });
await turn.finished;

订阅后续事件

const unsubscribe = session.subscribe((event) => {
  console.log(event);
});

unsubscribe();

历史消息

const history = await session.history({
  limit: 50,
});

System prompts

const system = await session.system();

分叉

const next = await session.fork();