api.tools

写书文档

tools: { write_document: api.tools.writeDocument }

由运行者在调用者的电脑上创建或更改文本文件,它每次都保留上一个版本。

declaration onlyfreekeeps the old version
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

没有什么可以调用: api.tools.writeDocument 是一个声明。它是什么表现它运行, 通过机器,你的过程正在运行。

声明

const agent = api.agents.create({
  model: { main: session },
  storages: [pc],                       // the computer it may write to
  tools: {
    list_documents: api.tools.listDocuments,
    read_document: api.tools.readDocument,
    write_document: api.tools.writeDocument,
  },
});
agent = api.agents.create(
    model={"main": session},
    storages=[pc],                        # the computer it may write to
    tools={
        "list_documents": api.tools.list_documents,
        "read_document": api.tools.read_document,
        "write_document": api.tools.write_document,
    },
)

模型发送的内容

{ "path": "Launch plan/brief.md", "content": "# Brief\n\nShip in March.", "mode": "create" }
{"path": "Launch plan/brief.md", "content": "# Brief\n\nShip in March.", "mode": "create"}
pathstring必填

与机器上的工作空间有关

contentstring必填

文本。不是缓冲,也不是对象。

modestringcreate

create · update · append.

模式模式模式功能已经放入一个文件
create撰写新文件 。拒绝——它说要使用 update 或 append.
update替换内容。旧版本先保存。
append添加到结尾处 。旧版本先保存。

没有副本的任何东西被覆盖

之前 update 或 a append,当前内容是写给 .versions/<path>/<timestamp>隐藏文件夹不列列表, 以便副本不会在工作空间上乱乱乱乱乱乱乱—— 答案随 backup这条路刚刚走过

// What the run reports back
{ path: "Launch plan/brief.md", mode: "update", bytes: 412,
  backup: ".versions/Launch plan/brief.md/2026-10-07T09-12-44-000Z.md" }
# What the run reports back
{"path": "Launch plan/brief.md", "mode": "update", "bytes": 412,
 "backup": ".versions/Launch plan/brief.md/2026-10-07T09-12-44-000Z.md"}
为什么存在这种

代理商跟随可能来自网页或文档的文字。 给它无法撤销的文字会使一个指令成为错误的终局。 这里的上一个版本是一个读取, 您可以把它交回去 。

只文本文件

此类型是从扩展名中读取, 任何非文本的, 都会被拒绝 : .md, .txt, .json, .csv, .html, .yaml,源文件。图像或 PDF 媒体不是用这种方式书写的,

长文件以通行证写成

描述对模型如此说明:创建文件,然后扩展到 append。一幅单笔巨幅的作品与对转折产出预算的答案竞争;但有好几次通行证。

它通过电话机的电脑 和包件运行

服务器无法到达磁盘。 当代理器调用此功能时, 运行会要求持有密钥的机器执行它, 软件包在那里工作, 答案会回到运行中。 所以只有在您的程序正在监听时它才会起作用, 并且文件的任何一个内容都不会被写入 。

拒绝运行报告

  • 缺少 path,或者不是字符串的。
  • content 3⁄4 ̄ ̧漯B
  • A A A mode 3 外。
  • create 指明两种模式,它们都行得通。
  • 工作空间以外的路径,或者绝对路径。