api.agents.create({ runtime: "local" }) 创建一个物体,当您调用 run(),询问模型要做什么,操作工具本身,反馈结果,重复到模型停止询问。循环就是产品。
由这里运行的
| 因为环环是本地的 | 你得到 |
|---|---|
| 工具在您的进程中执行 | 代理读取磁盘, 没有任何上传的东西可以查看 。 |
| 权限是回调 | 代码决定, 依电话, 并同时有争论。 |
| 信贷在计时时计时 | 预算可以在下次呼叫前停止运行,而不是在法案之后。 |
| 历史是你的 | 你可以读读,剪切,总结,或者扔掉 |
| 只有转弯是遥远的 | 服务器唯一要做的就是做它唯一要做的 |
最小的代理 工作
import { IaGenify } from "iagenify";
const api = new IaGenify({ apiKey: process.env.IAGENIFY_API_KEY });
const pc = await api.storage.get();
const agent = api.agents.create({
runtime: "local",
machine: pc,
model: "gemini-3.5-flash",
mode: "ask",
onPermission: async ({ tool, category, args }) => {
console.log("asking for", tool, category, args);
return "once"; // "once" | "always" | "deny"
},
});
const result = await agent.run({
inputs: "Read every markdown file in Notes and tell me what is unfinished.",
onEvent: (event) => {
if (event.type === "text") process.stdout.write(event.text);
},
});
console.log(result.stopReason, result.usage);import os, sys
from iagenify import IaGenify
api = IaGenify(api_key=os.environ["IAGENIFY_API_KEY"])
pc = api.storage.get()
def on_permission(request):
print("asking for", request["tool"], request["category"], request["args"])
return "once" # "once" | "always" | "deny"
agent = api.agents.create(
runtime="local",
machine=pc,
model="gemini-3.5-flash",
mode="ask",
on_permission=on_permission,
)
def on_event(event):
if event["type"] == "text":
sys.stdout.write(event["text"])
result = agent.run(
inputs="Read every markdown file in Notes and tell me what is unfinished.",
on_event=on_event,
)
print(result["stopReason"], result["usage"])每一件、每一件都有文件记载
| 片片片 | 决定决定决定决定决定决定, | Page |
|---|---|---|
machine | 工具运行的地方——一台计算机、一部电话、一台云层工作空间。 | 选项 · 机器 |
mode | 允许的,没有问。 | 模式 |
onPermission | 问出什么事情会怎么样 | 权限权限 |
tools | 模型35中,谁知道。 | 代理工具 |
budget · maxSteps | 当循环停止时 | Budget |
memory | 对话是否在过程中得以持续。 | 届会届会届会届会届会 |
onEvent | 有效的时候你所看到的 | 事件事件事件事件 |
还有一个老旧的代理商
无 runtime, create() 构建 服务器侧边代理服务器:平台上的循环运行,工具是平台的工具,而您的代码则得到步骤。这是 工作流程步骤 使用,因为工作流程没有你运行的过程。
具有进程时优先使用本地引擎
它拥有更大的工具组, 许可回召、 检查站、 技能和子试剂。 服务器侧面存在, 用于您没有运行的 。
多少运行成本
以每步一个模式转一个, 开帐单像任何转一个模式, 再加上任何付费工具花费——搜索、页面捕捉、生成图像。 usage 与总和和 turn 时,该事件带有运行中的计数。
result.usage; // { credits: 31, turns: 6, toolCalls: 9 }result["usage"] # {"credits": 31, "turns": 6, "toolCalls": 9}