Skip to main content
Glama

LoopIn

用于 AI 智能体的人机交互中断 API。

LoopIn 让 AI 智能体能够在关键决策点暂停,请求人工审核,并根据人类的决定恢复执行。不再让智能体独自做出高风险决策。


为什么选择 LoopIn?

自主智能体功能强大——直到它们遇到不应在没有人类参与的情况下做出的决策。LoopIn 为每个智能体提供了一个安全出口:

  1. 智能体到达决策点 → 调用 POST /interrupts

  2. LoopIn 通知人类 → 通过 Webhook 或直接审核 URL

  3. 人类批准或拒绝 → 通过审核页面或 POST /interrupts/:id/decide

  4. 智能体轮询决策 → GET /interrupts/:id

  5. 智能体恢复 → 使用该决策(以及人类提供的任何修改后的参数)


Related MCP server: turn-mcp-web

端点

POST /interrupts

创建新的中断请求。

请求:

{
  "agentId": "agent-payments-v2",
  "userId": "user-123",
  "action": "Transfer $4,200 to vendor account ending in 9821",
  "context": {
    "vendor": "Acme Supplies",
    "amount": 4200,
    "currency": "USD",
    "invoiceId": "INV-2024-0892",
    "accountLast4": "9821"
  },
  "urgency": "high",
  "expiresIn": 1800,
  "callbackUrl": "https://my-agent.example.com/webhooks/loopin"
}

响应:

{
  "interruptId": "3f4e2a1b-...",
  "status": "pending",
  "expiresAt": "2024-04-12T14:30:00Z",
  "reviewUrl": "http://localhost:3002/review/3f4e2a1b-..."
}

GET /interrupts/:interruptId

轮询当前状态和决策。

响应(待处理):

{
  "interruptId": "3f4e2a1b-...",
  "status": "pending",
  "action": "Transfer $4,200 to vendor account ending in 9821",
  "context": { ... },
  "urgency": "high",
  "createdAt": "2024-04-12T13:00:00Z",
  "expiresAt": "2024-04-12T14:30:00Z",
  "reviewUrl": "http://localhost:3002/review/3f4e2a1b-..."
}

响应(已解决):

{
  "interruptId": "3f4e2a1b-...",
  "status": "approved",
  "decision": "approved",
  "decidedAt": "2024-04-12T13:07:22Z",
  "reason": "Invoice verified, proceed."
}

POST /interrupts/:interruptId/decide

提交人类决策。

请求:

{
  "decision": "approved",
  "reason": "Invoice verified, proceed.",
  "modifiedParams": { "amount": 4200 }
}

响应:

{
  "interruptId": "3f4e2a1b-...",
  "status": "resolved",
  "decision": "approved",
  "decidedAt": "2024-04-12T13:07:22Z"
}

GET /interrupts/pending/:userId

列出所有等待用户审核的待处理中断。

响应:

[
  {
    "interruptId": "3f4e2a1b-...",
    "action": "Transfer $4,200 to vendor...",
    "urgency": "high",
    "createdAt": "...",
    "expiresAt": "...",
    "reviewUrl": "..."
  }
]

DELETE /interrupts/:interruptId

取消待处理的中断(智能体不再需要该决策)。


GET /analytics/:userId

使用统计信息。

响应:

{
  "userId": "user-123",
  "totalInterrupts": 47,
  "approvalRate": 0.83,
  "avgResponseTimeMs": 142000,
  "byStatus": { "approved": 39, "rejected": 8 },
  "byUrgency": { "high": 12, "medium": 28, "low": 7 },
  "topActionTypes": [
    { "action": "Send payment", "count": 18 },
    { "action": "Delete records", "count": 9 }
  ]
}

审核页面

每个中断都有一个人类可读的审核 URL:

GET /review/:interruptId

这将渲染一个 HTML 页面,显示:

  • 智能体想要做什么

  • 所有上下文数据(格式化的 JSON)

  • 紧急程度徽章

  • 批准 / 拒绝 按钮

  • 可选的理由文本框

将此 URL 分享给需要审核请求的任何人。默认无需登录。


MCP 工具

LoopIn MCP 服务器公开了 6 个工具,供任何兼容 MCP 的 AI 客户端(Claude Desktop、Cursor 等)使用:

工具

描述

create_interrupt

智能体创建新的中断请求

get_interrupt_status

智能体轮询决策

list_pending_interrupts

人类查看需要审核的内容

decide_interrupt

人类批准或拒绝

cancel_interrupt

智能体取消待处理请求

get_interrupt_analytics

使用统计信息

MCP 服务器设置 (stdio)

{
  "mcpServers": {
    "loopin": {
      "command": "npx",
      "args": ["-y", "@colossal-api/loopin-mcp"],
      "env": {
        "LOOPIN_API_URL": "https://your-loopin-instance.railway.app",
        "LOOPIN_API_KEY": "your-key"
      }
    }
  }
}

智能体使用模式

1. Agent reaches a decision point
   → POST /interrupts { agentId, userId, action, context, urgency }
   ← { interruptId, reviewUrl }

2. Agent saves interruptId and pauses
   → (optionally: notify human via other channels with reviewUrl)

3. Agent polls until resolved
   → GET /interrupts/:interruptId
   ← { status: "pending" }   ← keep polling
   ← { status: "approved", decision, modifiedParams }  ← resume

4. Agent resumes execution
   → use modifiedParams if provided, otherwise proceed as planned

人类使用模式

选项 A — 审核 URL(最简单)

  1. 从智能体接收 reviewUrl(通过电子邮件、Slack 等)

  2. 在任何浏览器中打开该 URL

  3. 查看上下文,点击“批准”或“拒绝”,添加可选理由

  4. 完成 — 智能体将在下一次轮询时获得决策

选项 B — 列出待处理(仪表板)

  1. GET /interrupts/pending/:userId — 查看所有打开的请求

  2. 打开单独的 reviewUrl 或直接调用 POST /interrupts/:id/decide


环境变量

变量

默认值

描述

PORT

3002

API 服务器端口

LOOPIN_BASE_URL

http://localhost:3002

审核链接的公共基础 URL

API_KEY_SECRET

(无)

可选:要求所有请求包含 X-API-Key 标头


Colossal API 产品组合

LoopIn 是 Colossal API 基础设施 API 套件的一部分,专为 AI 智能体设计:

  • SubRadar — 订阅检测与取消

  • MeetSync — 日程协商与安排

  • LoopIn — 人机交互中断与审批

所有产品共享相同的设计理念:简单的 REST API 和 MCP 服务器封装,以便智能体可以原生使用它们。

Related MCP Connectors

Related MCP Servers