桥接

自定义工具

customTools: { name: { description, parameters, category, run } }

自己工具,在35号工具旁边宣布 允许它们被计算 和显示的完全一样

4 categoriesdescription is requiredwrite by default
Using Python?

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

宣告

const agent = api.agents.create({
  runtime: "local", machine: pc, model: "gemini-3.5-flash",
  customTools: {
    open_ticket: {
      description: "Open a ticket in our tracker. Returns its number and URL.",
      category: "write",
      parameters: {
        title:  { type: "string", required: true },
        body:   { type: "string" },
        labels: { type: "array", items: { type: "string" } },
      },
      async run({ title, body, labels }, { signal }) {
        const ticket = await tracker.create({ title, body, labels }, { signal });
        return { output: `Opened #${ticket.number}: ${ticket.url}`, summary: `#${ticket.number}`, meta: { url: ticket.url } };
      },
    },
  },
});
def open_ticket(args):
    ticket = tracker.create(title=args["title"], body=args.get("body"), labels=args.get("labels") or [])
    return {"output": f"Opened #{ticket.number}: {ticket.url}"}

agent = api.agents.create(
    runtime="local", machine=pc, model="gemini-3.5-flash",
    tools={
        "open_ticket": {
            "description": "Open a ticket in our tracker. Returns its number and URL.",
            "category": "write",
            "parameters": {
                "type": "object",
                "properties": {
                    "title": {"type": "string"},
                    "body": {"type": "string"},
                    "labels": {"type": "array", "items": {"type": "string"}},
                },
                "required": ["title"],
            },
            "run": open_ticket,
        },
    },
)
descriptionstring必填

模型上所有的人都知道工具 拒绝空的 。

runfunction必填

(args, { signal }) => string | { output, summary?, meta? }.

categorystringwrite

read · write · storage · exec.

parametersobject{}

模型可以发送什么, 以同样的形状 内置工具使用。

类是真实的决定

选择触发条件后果
读为只会看从未问过, 跑着 与其他的读物平行
write改变一些可以恢复的东西询问时询问,自动免费
storage它改变的东西没有撤消即使在汽车里也问,“每个目标”
exec专横的问了除了满满的 什么都问
读作是应谨慎的

用户从未要求使用,而且从未同时运行。 发送、出版或花费的工具决不能被宣布为阅读工具,而定制工具不能使用三种总是要求使用的工具,因此,在运行前,任何此类工具都属于自己的代码。

名称名称名称名称名称名称名称

内置工具的名称,包括 skill 和 task - 拒绝 invalid_custom_tool 而不是跟踪它

返回的运行时间

返回成为
字符串字符串产出:没有摘要。
{ output }输出。任何非字符串的,按 JSON.
{ output, summary }加加显示的行 tool_end.
{ output, summary, meta }加上你想拥有的接口

丢弃是罚款: 它会随着您的讯息而成为失败的工具结果, 模型会适应。 The 。 signal 当跑步停止时,火势会燃烧—— 任何缓慢的事情都要遵守。

每一转一转,都花花代代币

声明会随时间转寄, 所以每个自定义工具都会添加到每一步的帐单中。 声明这个运行可能真正叫什么, 而不是您应用程序能做的 。