关于 messaging-agents
messaging-agents 是 Letta Code 技能,可通过 conversations API 向同一 Letta 服务器上的其他 Agent 发消息。它支持发起和延续对话,并说明消息沟通不会赋予对方访问本地环境的权限。
主要功能
- 01发起 Agent 间对话
- 02按 ID 延续对话
- 03查找 Agent 和历史消息
- 04查看隐藏对话记录
适用场景
- 01向具备专门知识的 Agent 提问
- 02获取其他 Agent 记忆中的信息
- 03协调多个 Agent 的任务
- 04查看 Agent 间的对话记录
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ letta-ai/ letta-code --skill messaging-agents安装后在 Claude Code 中输入/messaging-agents确认已加载。
详细介绍
消息 Agent
此技能可让你使用线程安全的对话 API,向同一 Letta 服务上的其他 Agent 发送消息。
何时使用此技能
- 你需要向另一个 Agent 提问
- 你想查询具有专门知识的 Agent
- 你需要获取另一个 Agent 记忆中的信息
- 你想与另一个 Agent 协调任务
目标 Agent 可以和不可以做什么
目标 Agent 不可以:
- 访问你的本地环境(读取或写入代码库中的文件)
- 在你的机器上执行 shell 命令
- 使用你的工具(Bash、Read、Write、Edit 等)
目标 Agent 可以:
- 使用自己的工具(其配置的任何工具)
- 访问自己的记忆块
- 使用 Web/API 工具进行 API 调用
- 使用 Web 搜索工具搜索网页
- 根据自己的知识或记忆提供信息
重要提示: 此技能用于与其他 Agent 通信,而非委派本地工作。目标 Agent 在自己的环境中运行,无法与你的代码库交互。
需要本地访问权限? 如果你需要目标 Agent 访问你的本地环境(读取或写入文件、运行命令),请改用 Agent 工具,将其作为子 Agent 部署:
Agent({
agent_id: "agent-xxx", // Deploy this existing agent
subagent_type: "general-purpose", // read-write access to your local tools
prompt: "Look at the code in src/ and tell me about the architecture"
})
这样,Agent 作为子 Agent 运行时即可访问你的代码库。
查找要联系的 Agent
如果你没有特定的 Agent ID,请使用以下技能查找:
按名称或标签查找
加载 finding-agents 技能来搜索 Agent:
letta agents list --query "agent-name"
letta agents list --tags "origin:letta-code"
按讨论过的主题查找
加载 searching-messages 技能,查找处理过某项工作的 Agent:
letta messages search --query "topic" --all-agents
结果中会包含每条匹配消息对应的 agent_id。
CLI 用法(Agent 对 Agent)
开始新对话
letta -p --from-agent $LETTA_AGENT_ID --agent <id> "message text"
参数:
| 参数 | 必填 | 说明 |
|---|---|---|
--agent <id> | 是 | 要联系的目标 Agent ID |
--from-agent <id> | 是 | 发送方 Agent ID(注入 Agent 对 Agent 的系统提醒) |
"message text" | 是 | 消息正文(位于标志之后的位置参数) |
示例:
letta -p --from-agent $LETTA_AGENT_ID \
--agent agent-abc123 \
"What do you know about the authentication system?"
响应:
{
"conversation_id": "conversation-xyz789",
"response": "The authentication system uses JWT tokens...",
"agent_id": "agent-abc123",
"agent_name": "BackendExpert"
}
继续对话
letta -p --from-agent $LETTA_AGENT_ID --conversation <id> "message text"
参数:
| 参数 | 必填 | 说明 |
|---|---|---|
--conversation <id> | 是 | 现有对话 ID |
--from-agent <id> | 是 | 发送方 Agent ID(注入 Agent 对 Agent 的系统提醒) |
"message text" | 是 | 后续消息(位于标志之后的位置参数) |
示例:
letta -p --from-agent $LETTA_AGENT_ID \
--conversation conversation-xyz789 \
"Can you explain more about the token refresh flow?"
理解响应
- 脚本仅返回助手的最终消息(不包含工具调用或推理过程)
- 目标 Agent 可能会使用工具、思考和推理,但你只能看到其最终响应
- 如需查看完整对话记录(包括工具调用),请使用
searching-messages技能,并通过letta messages list --agent <id>指定另一个 Agent
工作原理
发送消息时,目标 Agent 会收到一条系统提醒:
<system-reminder>
This message is from "YourAgentName" (agent ID: agent-xxx), an agent currently running inside the Letta Code CLI (docs.letta.com/letta-code).
The sender will only see the final message you generate (not tool calls or reasoning).
If you need to share detailed information, include it in your response text.
</system-reminder>
这有助于目标 Agent 理解上下文,并以适当的格式回复。
隐藏对话
Agent 对 Agent 的对话(通过 --from-agent 发起)会在目标 Agent 上创建为隐藏对话。它们不会显示在目标 Agent 的 ADE 默认对话列表中,因此自动化的 Agent 间消息不会让界面变得杂乱。
查看这些对话的方法:
- 通过 API 使用
archive_status=archived(或all)列出隐藏对话 - 使用
letta messages transcript --conversation <id>直接获取对话记录 - 发送消息时返回的
conversation_id就是你需要的句柄
使用 --conversation <id> 继续隐藏对话会使其保持隐藏状态——只有归档状态会受到影响,消息功能仍可正常使用。
相关技能
- finding-agents:按名称、标签或模糊搜索查找 Agent
- searching-messages:搜索各 Agent 的过往消息,或查看完整对话记录