学习笔记 · Obsidian

Fleet:工具、Skills、MCP 与 Computer Use

LangChainLangSmithMCP

Fleet 的能力面由四类组件叠加:内置 integrations 提供受管工具;remote MCP 扩展外部系统;skills 按需提供流程知识;Computer Use 提供持久、隔离的执行环境。生产设计要把“知识”“动作”“凭据”“执行环境”分开治理。

内置工具与连接范围

工具既可从 Fleet > Integrations 连接到 workspace,也可从 Agent 侧栏只加到单个 Agent。移除 Agent 中的 connection/tool 不等于删除 workspace 级配置。文档列出的内置类别包括:

  • Google:Gmail、BigQuery、Calendar、Docs、Sheets;
  • Microsoft:Excel、Outlook、PowerPoint、SharePoint、Teams、Word;
  • 协作与工程:GitHub、Linear、Slack、Pylon;
  • 搜索与社交:Exa、Tavily、LinkedIn、X。

列表只是子集,准确能力、授权 scope 和可用地区应以 Fleet Integrations UI 为准。工具名称相同也不代表读写能力、幂等性或审批默认值相同;逐工具核对 input schema、side effect、账户主体与 Auto/Ask。

Skills:按需加载的流程资产

Skill 默认存于 memories/skills/<skill-name>。启动时只加载 name 与 description,Agent 判断相关后才加载完整 SKILL.md,被引用的资源再按需读取。这种渐进加载可以节省 token,并降低无关规则挤占上下文导致的错误。

私有与共享

类型作用域更新语义
Private skill单个 Agent 的长期记忆随 Agent 独立演进
Shared skill整个 workspace,可被多个 Agent 使用只有创建者可编辑/删除;更新会同步到使用它的 Agent;中央 Chat 自动可用

删除 private skill 不可恢复;删除 shared skill 会从 workspace 和所有引用 Agent 中移除,也不可恢复。共享 skill 因此应有 owner、版本、变更记录、回滚副本与兼容性评审。

描述决定路由

Description 应写“何时使用”,而不是抽象标签。例如用“当需要起草、回复或总结邮件时使用,覆盖语气、跟进和 inbox triage”,而不是“帮助处理邮件”。描述过宽或与其他 skill 重叠会导致漏选、误选或冲突。

可通过 AI、模板或手工建立 skill;额外资源必须由 SKILL.md 引用,否则 Agent 不知道它们存在。修复重复错误时,可让 Agent 把纠正后的稳定流程沉淀为 skill,但在共享前要人工审查,防止一次偶发上下文被固化为错误规则。

拉取到本地开发

LangSmith CLI 可把 workspace skill 拉到本地 coding Agent:

langsmith fleet skills pull web-research --format pretty

默认保存到 ~/.agents/skills/<name>/ 并链接到 ~/.claude/skills/;--global=false 改为项目级目录,--agent 选目标 Agent,--copy 禁用符号链接。生产仓库应明确全局/项目级来源,不要让共享 skill 在无评审时悄然改变构建行为。

Remote MCP:Fleet 是客户端,不执行远端工具

Remote MCP server 运行在 LangSmith 外部,自己负责 authentication/authorization。Fleet 通过标准协议发现工具、转发 call,再把结果交回 Agent;workspace 配置的 headers 同时用于 discovery 与 invoke。

sequenceDiagram
    participant A as Fleet Agent
    participant F as Fleet MCP client
    participant M as Remote MCP server
    A->>F: 选择工具
    F->>M: tools/list + headers
    M-->>F: 工具 schema
    F->>M: tools/call + headers
    M-->>F: result / error
    F-->>A: 结构化结果

可从单 Agent 的 Connections 或 workspace 的 Fleet > Integrations / Settings > MCP servers 添加;需要 MCP Server Create 权限。认证类型:

  • Headers:每次请求附带静态 KV,例如 Authorization: Bearer ...;
  • OAuth 2.1 Auto:服务器支持 dynamic client registration;
  • OAuth 2.1 Manual:预先提供 client ID/secret,provider 必须启用 PKCE。

修改 custom MCP URL 会破坏已有 Agent,因为工具引用按 server URL 保存。正确迁移是:更新 server URL,逐 Agent 移除旧工具、重新 discovery/添加,再执行契约测试。不要直接原地换 URL 后假设引用自动迁移。

生产 MCP server 还应实现 TLS、最小 scope、短期 token、输入验证、调用幂等、限流、超时、审计、schema/version 兼容和可撤销授权。Static headers 适合 service credential,不适合冒充最终用户身份。

LangSmith Tool Server:自建 toolkit 与 gateway

Tool Server 是独立 Python MCP framework,不是 Fleet 使用 built-in/remote MCP 的必需组件。适用于:

  • 用 @tool 建立自定义 toolkit,并接 LangSmith Agent Auth;
  • 给 Fleet 外部的自建 Agent 建一个聚合 MCP gateway。

基本流程:安装 langsmith-tool-server 与 langchain-cli-v2,执行 langchain tools new,在 TOOLS 中注册函数,以 langchain tools serve 启动,默认 http://localhost:8000、MCP endpoint 为 /mcp。

toolkit.toml 可同时聚合 streamable_http 和 stdio MCP servers;输出工具会加 server name 前缀,例如 weather_get_forecast,用于避免名称冲突。第三方 OAuth 工具在装饰器声明 auth_provider、scopes、integration,第一个参数必须是 Context,并用 context.token 访问 API。

自定义 request auth 可在 auth.py 注册 handler。它每个请求都执行,必须验证 token 并返回含 identity、可选 permissions 的 dict。示例代码只是骨架;实际必须验证 issuer、audience、签名、过期、撤销与 tenant,不能只判断 Bearer 前缀。

Computer Use:隔离计算与凭据注入

Computer Use 在 Plus/Enterprise 提供虚拟计算机,能运行代码、管理文件、安装包和调用外部 API。凭据可以通过 access profile 的代理注入 header,不暴露给语言模型。

两种不可变模式

模式状态范围生命周期使用建议
Shared computer同一 Agent 的所有 threads 共享 filesystem、包与进程不自动删除需要跨会话积累环境;必须防止线程间数据泄漏和状态污染
Computer per thread每个 thread 独立,空闲后归档停止后按 cleanup 删除并行、写密集、软件工程或要求线程隔离

模式在 Agent 创建时确定,之后不能切换;需要更改就新建 Agent。共享计算机不能把 thread privacy 等同为 filesystem privacy,因为多个 thread 看到同一磁盘。

Access profile

Profile 由 Custom rules 构成:Match Hosts 支持 *.example.com;credential source 可为用户 OAuth Connection 或 Workspace Secret;Inject Headers 可用 {access_token} 等模板。请求到匹配 host 时经过代理注入,模型不直接拿到 secret。

Network scope 默认是 None (all traffic allowed),这里的 None 不是“无网络”。生产应收窄 allowlist,防 SSRF、数据外传、通配 host 过宽和重定向绕过,并验证 DNS/子域控制权。

生命周期与 snapshot

  • idle timeout 默认 15 分钟:暂停并归档 disk,之后可恢复;
  • stopped cleanup 默认 14 天,只适用于 per-thread,届时永久删除 disk;
  • shared computer 不会自动删除;
  • snapshot 是新 computer 的启动镜像。更换 snapshot 只影响后续新实例,既有 shared computer 永远保留原镜像。

需要建立镜像版本、漏洞扫描、包来源控制、磁盘加密、恶意文件扫描、持久进程清理与数据保留策略。Snapshot 更新不能修复已长期运行的 shared computer,应安排重建。

Arcade:托管 MCP gateway

Arcade 通过 managed MCP gateways 把 GitHub、Gmail、Slack、Notion、Jira、Salesforce 等工具接到 Fleet。Workspace admin 先以 OAuth 选择 Arcade organization/project,再安装其中的 gateways;普通成员必须加入同一 project,并各自连接 Arcade account,因此 tool call 使用成员自己的凭据而不是 admin 凭据。

只有 admin 能更改 workspace 的 Arcade org/project。变更会删除所有已安装 MCP servers,之后必须从新 project 重装,属于高影响操作,应先导出清单、通知 Agent owner 并准备回滚。普通 Disconnect 只撤销当前用户 OAuth token,不改变 workspace 配置或其他用户。

Salesforce:只读集成与两阶段安装

Salesforce 工具当前提供只读查询:标准/自定义对象、schema 关系和字段,可用于 thread 或 scheduled run。首次连接故意失败,用来在 Salesforce org 注册 LangChain Fleet Connector;随后 System Administrator 或具备 Approve Uninstalled Connected Apps 的用户安装 connected app,以 permission set 预授权目标用户,再回 Fleet 重新连接。

Agent 只能读取连接用户本身有权访问的 object/field。排障顺序:

  1. 首次失败是否只是预期注册步骤;
  2. Connector 是否安装;
  3. 用户是否分配正确 permission set;
  4. 自定义 domain/SSO 是否从 Use Custom Domain 登录;
  5. Salesforce profile/permission set 是否允许读取具体对象和字段。

不要为了让 Agent“看得见”而给用户 System Administrator。连接账户权限就是 Agent 数据边界,应最小化并用 Salesforce audit + LangSmith trace 做双向追踪。

生产检查

  • Skill 负责知识与流程,tool 负责动作,MCP/auth 负责边界,computer 负责执行;不要混为一个“能力开关”。
  • 每个 tool 明确 side effect、账户、scope、超时、重试、幂等和 approval。
  • Remote MCP URL、schema 与认证变更走版本化迁移;先在测试 Agent re-discover。
  • Access profile 网络默认实际上是全开放,必须显式收窄。
  • Shared computer 定期重建;per-thread cleanup 与业务数据保留保持一致。
  • Workspace skill、Arcade project 与 Salesforce permission 都是共享治理对象,删除/切换前做依赖清单。