Postal是一个用于实现两个智能体之间通信的邮箱系统,它借助SQLite支持的消息队列在智能体之间传递消息,能有效解决智能体间的信息交互问题,为智能体协作提供有力支持。
Postal创建了一个基于SQLite的消息队列,用于在智能体之间传递消息。MCP服务器仅支持HTTP协议,这意味着所有智能体共享相同的数据库和队列。以下是Claude指导Gemini编写单元测试的示例:
智能体之间的通信流程可以用以下Mermaid图表示:
graph LR
subgraph Claude
ccli[CLI]--send-->csm["send_message()"]
crec["check_mailbox()"]
end
subgraph Gemini
gcli[CLI]--send-->gsm["send_message()"]
grec["check_mailbox()"]
end
postal[(postal)]
csm-->postal-->crec-->ccli
gsm-->postal-->grec-->gcli
send_message(agent_name, message):用于向指定智能体发送消息。check_mailbox():该方法会阻塞,直到在自己的邮箱中收到消息。智能体可以自由地相互发送消息,以下是一个使用示例:
PROMPT="Notice that you have two tools, check_mail and send_to_agent. You should get **all** instructions from check_mail. And you should get **all** clarification by using send_to_agent to reply to the agent that gave you a task. Your goal is to keep completing tasks forever and never ask the user for anything. Only talk to agents. You are gemini"
gemini --yolo --prompt "$PROMPT"
以下是一个使用Postal进行智能体通信的示例:
PROMPT="Notice that you have two tools, check_mail and send_to_agent. You should get **all** instructions from check_mail. And you should get **all** clarification by using send_to_agent to reply to the agent that gave you a task. Your goal is to keep completing tasks forever and never ask the user for anything. Only talk to agents. You are gemini"
gemini --yolo --prompt "$PROMPT"
MCP服务器以可流式传输的HTTP方式提供服务,路径格式为 /agents/{name}/mcp/。以下是两种不同的配置示例:
{
"mcpServers": {
"postal": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://0.0.0.0:7777/agents/gemini/mcp", "--allow-http", "--transport", "http-only"]
}
}
}
{
"mcpServers": {
"postal": {
"url": "http://0.0.0.0:7777/agents/gemini/mcp",
"transport": "http"
}
}
}
需要注意的是,"http" 的指定方式存在一些差异,有时是 "streamable-http",有时键名为 "type"。
Postal通过SQLite支持的消息队列来实现智能体之间的消息传递。MCP服务器仅支持HTTP协议,确保所有智能体共享相同的数据库和队列。
Gemini CLI的使用效果较好,没有太多问题。
Claude代码在返回邮箱方面存在一定困难,需要大量的提示。