@ antseed/ ant- agent (英语)
Ant Seed的蚂蚁代理运行时间. 让种子跑跑者将知识货币化,方法是将任何提供者包装成一个人物、护栏、点播知识模块和定制工具.
蚂蚁剂是 只读,知识强化的AI服务. 它不代表用户行事——它利用创作者包并维护的被整理出的专门知识来回答问题.
如何运作
- 创建者定义代理: persona + guardrails + 知识模块( markdown 文件)
- 根据买方的每一项请求,个人、护栏和
antseed_load_knowledge输入工具 - LLM 决定何时加载知识——它使用模块名称调用工具并接收内容
- 代理环路执行内部工具调用并重新提示, 直到 LLM 生成最终文本响应
- 买方得到干净的流程反应——没有内部工具或循环文物
当没有定义知识模块时,没有注入工具,并且是单调的注射(只使用人称+护栏).
代理目录结构
my-agent/
agent.json # manifest
persona.md # who the agent is
knowledge/ # knowledge modules
linkedin-posting.md
content-strategy.md
tools/ # custom tool scripts (optional)
fetch-trends.js
探员. json
{
"name": "social-media-advisor",
"persona": "./persona.md",
"guardrails": [
"Never write posts without explicit request",
"Always disclose AI-generated content when asked"
],
"knowledge": [
{
"name": "linkedin-posting",
"description": "Creating and optimizing LinkedIn posts",
"file": "./knowledge/linkedin-posting.md"
},
{
"name": "content-strategy",
"description": "Content calendars and strategy frameworks",
"file": "./knowledge/content-strategy.md"
}
],
"tools": [
{
"name": "fetch_trends",
"description": "Fetch trending topics for a platform",
"parameters": {
"type": "object",
"properties": { "platform": { "type": "string" } },
"required": ["platform"]
},
"execute": "./tools/fetch-trends.js"
}
]
}
| 外地 | 需求 | 说明 |
|---|---|---|
name | 对 | 代理名称 |
persona | 没有 | 使用代理系统的标记下文件的路径 : |
guardrails | 没有 | 代理商必须遵守的硬规则 |
knowledge | 没有 | 需求加载的知识模块阵列 |
knowledge[].name | 对 | 模块的独特标识符 |
knowledge[].description | 对 | 简短说明——向LLM显示以确定相关性 |
knowledge[].file | 对 | 包含全部内容的标记下文件路径 |
tools | 没有 | LLM 可调用的自定义工具阵列 |
tools[].name | 对 | 工具名( 自动前缀为 antseed_(中文(简体) ) |
tools[].description | 对 | 向 LLM 显示描述 |
tools[].parameters | 没有 | JSON Schema 工具参数( 默认为空对象) |
tools[].execute | 对 | 导入默认函数的 JS 文件路径 |
confidentialityPrompt | 没有 | 自定义保密指令( 有合理的默认) |
使用量
程序化
import { loadAntAgent, AntAgentProvider } from '@antseed/ant-agent';
// Load agent (knowledge + tools from agent.json)
const agent = await loadAntAgent('./my-agent');
const boundProvider = new AntAgentProvider(innerProvider, agent);
// Per-service agents
const socialAgent = await loadAntAgent('./social-agent');
const codingAgent = await loadAntAgent('./coding-agent');
const boundProvider = new AntAgentProvider(innerProvider, {
'social-model-v1': socialAgent,
'coding-model-v1': codingAgent,
'*': socialAgent,
});
node.registerProvider(boundProvider);
国 际
添加 agentDir 给你的蚂蚁配置。 单个代理(所有服务)使用字符串,或每个服务代理的地图:
{
"seller": {
"agentDir": "./my-agent"
}
}
服务人员:
{
"seller": {
"agentDir": {
"social-model-v1": "./agents/social",
"coding-model-v1": "./agents/coding",
"*": "./agents/default"
}
}
}
这个 "*" 键是对没有明确代理的服务的一种倒置。 没有匹配代理的服务没有变化.
然后运行 antseed seller start 和往常一样.
知识加载
在界定知识单元时 antseed_load_knowledge 工具与任何购买工具一起注入请求中。 工具描述包括一个可用模块名称和描述的目录.
LLM根据对话决定要加载哪些模块. 它可以:
- 装入一个模块,获取内容,然后回复
- 通过连续的工具调用加载多个模块
- 如果问题不需要专业知识,直接回答而不装入任何模块
这使背景保持重点——只有LLM法官的相关知识才能被加载. 买家问起LinkedIn不会得到X/Twitter知识 膨胀上下文.
自定义工具
除了知识加载,创建者还可以添加LLM在代理循环期间可以调用的自定义工具. 定义工具 agent.json 带有 execute 字段指联署文件:
{
"tools": [{
"name": "fetch_trends",
"description": "Fetch trending topics for a platform",
"parameters": {
"type": "object",
"properties": { "platform": { "type": "string" } },
"required": ["platform"]
},
"execute": "./tools/fetch-trends.js"
}]
}
JS 文件导出一个接收工具参数并返回字符串的默认函数:
// tools/fetch-trends.js
export default async function(args) {
const res = await fetch(`https://api.example.com/trends/${args.platform}`);
return await res.text();
}
工具名自动前缀 antseed_ 注射时(例如, fetch_trends 变成 antseed_fetch_trends) (中文(简体) ). LLM 可以看到所有内部工具与买入工具, 并附有系统快速使用指令 antseed_* 仅按要求提供用于上下文收集和购买工具的工具.
如果一个工具的执行函数抛出,错误消息会作为出错结果返回到LLM,这样它就可以优雅地恢复.
程序工具
工具也可以通过选项参数在程序上添加(当工具需要访问运行时状态) :
import { AntAgentProvider, loadAntAgent, type AntAgentTool } from '@antseed/ant-agent';
const customTool: AntAgentTool = {
name: 'lookup_user',
description: 'Look up user details',
parameters: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] },
execute: async (args) => db.users.findById(args.id),
};
const agent = await loadAntAgent('./my-agent');
new AntAgentProvider(innerProvider, agent, { tools: [customTool] });
明确的工具和方案工具合并在一起.
注射什么药
系统提示器按此顺序组装:
- 个人a - 代理人的身份和专门知识
- 工具集指令 ——告诉LLM如何使用
antseed_工具对购买工具(仅在存在知识模块的情况下) - 护栏 - 硬规则
- 及时保密 ——防止LLM披露注入内容
此外, antseed_* 将工具与买方提供的任何工具一起添加到请求的工具清单中。 包括内置 antseed_load_knowledge (在定义知识模块时)和任何通过选项传递的自定义工具.
买方自身的系统即时(如果有的话)在代理人内容后保留.