惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
酷 壳 – CoolShell
酷 壳 – CoolShell
G
Google Developers Blog
N
Netflix TechBlog - Medium
Recorded Future
Recorded Future
S
Securelist
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Scott Helme
Scott Helme
C
Check Point Blog
量子位
月光博客
月光博客
Last Week in AI
Last Week in AI
C
Cisco Blogs
G
GRAHAM CLULEY
B
Blog RSS Feed
K
Kaspersky official blog
爱范儿
爱范儿
J
Java Code Geeks
I
Intezer
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
C
CXSECURITY Database RSS Feed - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
T
Threat Research - Cisco Blogs
N
News | PayPal Newsroom
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Security Latest
Security Latest
T
Tailwind CSS Blog
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
The Cloudflare Blog
H
Heimdal Security Blog
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
GbyAI
GbyAI
V
Visual Studio Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 聂微东
T
Tenable Blog
The Register - Security
The Register - Security
AI
AI
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
L
LangChain Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
【2026年05月07日】AI Agent 编排的 5 个血腥教训:90% 的团队用错了安全策略 🔥
· 2026-05-07 · via DEV Community

【2026年05月07日】AI Agent 编排的 5 个血腥教训:90% 的团队用错了安全策略 🔥

标签: AI, Programming, GitHub, Tutorial, Agents, 安全


"你们的 AI Agent 框架在 Demo 里看起来很美,一上生产就崩。"
—— HN 热帖 Superset:10个并行编码Agent的正确打开方式(96票)


你可能不知道:AI Agent 编排有 5 个致命陷阱

过去一周,GitHub Trending 和 HN 上最火的话题不是新的模型发布,而是 AI Agent 基础设施

  • Superset — HN 96票,Cursor 式的并行 Agent 编排工具
  • Kontext CLI — HN 70票,AI Agent 的凭证中间件
  • JACoB — HN 40票,真实生产力场景的开源 AI 编码 Agent

但我发现 90% 的开发团队在部署这些工具时,都踩了同样的坑。今天把血泪教训整理出来,看完能帮你省下至少 2 周的排错时间。


教训一:凭证管理——Agent 提示词里藏着你的 API Key

大多数团队的现状:

  • API Key 写在 .env 文件,Agent 通过 os.getenv() 读取
  • 或者更糟——直接塞进 system prompt 里

现实问题:

  • 凭证会进入 LLM 的 Context Window,一旦泄露就是明文
  • 日志、错误报告、Token 使用记录都可能暴露
  • 多人协作时,无法按 Agent 会话粒度撤销权限

正确姿势:凭证代理架构

import asyncio
from kontext import Broker  # 开源凭证代理中间件

async def agent_with_safe_credentials(user_id: str, task: str):
    """每个 Agent 会话独立凭证作用域,运行时注入,用完即销毁"""

    broker = Broker(app_name="prod-agents")

    # 凭证不在这里——Agent 只拿到临时的、作用域受限的 token
    session = await broker.get_session(user_id)

    # LLM 客户端从代理获取,从不接触原始 Key
    llm_client = session.get_llm("openai")

    # 数据库访问也是临时的、限时的 token
    db_token = session.get_credential("postgres")

    result = await llm_client.complete(task, tools=db_token.tools())

    # 用户登出时自动吊销所有 Token
    await broker.revoke_session(user_id)
    return result

# 团队成员离职?Agent 被攻破?一键吊销该用户所有会话凭证
await broker.emergency_revoke(user_id="disgruntled_employee")

Enter fullscreen mode Exit fullscreen mode

关键认知: 把 LLM 的 Context Window 视为不可信网络——永远不要把密钥放进去。


教训二:并行 Agent 隔离——同时跑10个 Agent,文件冲突怎么破?

场景: 你想让 10 个 Agent 同时重构 10 个不同的代码模块。结果:

  • Agent 3 和 Agent 7 同时修改了同一个函数
  • Agent 1 创建的分支被 Agent 5 覆盖
  • 文件锁竞争导致一半的任务静默失败

正确姿势:进程级隔离 + 协调层

import asyncio
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
import os

AGENT_SANDBOX = Path("/tmp/ai_agents_sandbox")
AGENT_SANDBOX.mkdir(exist_ok=True)

async def run_sandboxed_agent(agent_id: int, task: str) -> dict:
    """每个 Agent 有自己独立的文件系统空间和工作目录"""

    workdir = AGENT_SANDBOX / f"agent_{agent_id:03d}"
    workdir.mkdir(exist_ok=True)

    # 构建隔离沙箱
    sandbox_config = {
        "workspace_root": str(workdir),
        "allowed_paths": [str(workdir)],      # 只能读写自己的目录
        "env_vars": {**os.environ, "AGENT_ID": str(agent_id)},
        "max_file_ops": 200,                   # 防止异常 Agent 读写过多文件
    }

    loop = asyncio.get_event_loop()
    result = await loop.run_in_executor(
        ProcessPoolExecutor(max_workers=1),
        execute_agent_in_sandbox,
        agent_id, task, sandbox_config
    )
    return result

async def batch_refactor(module_tasks: list[tuple[int, str]]):
    """10 个 Agent 同时开工,互不干扰"""
    results = await asyncio.gather(
        *[run_sandboxed_agent(aid, task) for aid, task in module_tasks],
        return_exceptions=True
    )
    return results

# 场景:10 个模块同时重构
tasks = [
    (0, "重构 auth 模块为 JWT RS256"),
    (1, "重构 payment 模块对接 Stripe v3"),
    (2, "重构日志模块为结构化 JSON"),
    # ... 同时跑,互不干扰
]
results = asyncio.run(batch_refactor(tasks))

Enter fullscreen mode Exit fullscreen mode

这就是 JACoB 和 Superset 的核心架构 — 没有隔离层的并行 Agent 是一场灾难。


教训三:MCP Server 安全审计——每个 MCP 工具都是潜在的横向移动路径

MCP(Model Context Protocol)现在是 AI 工具标配。问题是:

当你给 Agent 添加一个 MCP 工具时,你实际上给了它该工具所拥有的所有权限

  • 一个 filesystem MCP 工具 = Agent 有完整的文件系统读写权限
  • 一个 postgres-mcp 工具 = Agent 可以读写你的整个数据库
  • 一个 network-mcp 工具 = Agent 可以对你的内网发起任意请求

正确的审计流程:

// mcp_audit.js — 扫描所有已安装 MCP Server 的权限清单
import { readFileSync } from 'fs';

const DANGEROUS_PERMISSIONS = [
  'filesystem:write',    // 写任意文件
  'network:all',          // 任意网络请求
  'exec:run',             // 执行任意命令
  'credential:read',      // 读取存储凭证
];

function auditMcpServer(manifestPath) {
  const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
  const issues = [];

  for (const tool of manifest.tools || []) {
    const perms = tool.permissions || [];
    const danger = perms.filter(p => DANGEROUS_PERMISSIONS.includes(p));

    if (danger.length > 0) {
      issues.push({
        tool: tool.name,
        dangerous: danger,
        recommendation: suggest_minimal_permissions(tool)
      });
    }
  }

  return issues;
}

// 批量审计:npm install 后自动运行
// $ node mcp_audit.js ./node_modules/*/mcp-manifest.json

Enter fullscreen mode Exit fullscreen mode

安装任何 MCP Server 之前,先问自己:给它这些权限合理吗? 这就是为什么 Palo Alto Networks 说"AI Agent 是 2026 年最大的内部威胁"。


教训四:Flow State 协议——Agent 也需要"休息",大多数人不知道

这是最反直觉的一点:AI Agent 需要在任务之间"清空大脑"

如果一个 Agent 连续运行超过 90 分钟,它的输出质量会持续下降——变得越来越泛化,越来越缺乏任务针对性。这和人脑的注意力衰减曲线高度吻合。

Flow State Session 管理:

import time
from dataclasses import dataclass, field
from typing import Optional

@dataclass
class FlowSession:
    """专注会话 + 自动上下文重置机制"""
    session_id: str
    started_at: float = field(default_factory=time.time)
    token_budget: int = 8000          # 每会话 Token 上限
    checkpoint_interval: int = 2000    # 每 2000 Token 保存一次
    checkpoints: list = field(default_factory=list)

    def should_save_checkpoint(self, tokens_used: int) -> bool:
        return tokens_used % self.checkpoint_interval == 0

    def needs_reset(self) -> bool:
        """90 分钟是经过验证的人类心流周期——对 AI Agent 同样适用"""
        return time.time() - self.started_at > 90 * 60

async def agent_flow_session(agent, task: str, session: FlowSession):
    """Agent 在专注会话中运行,达到阈值后自动重置状态"""

    tokens_consumed = 0

    while tokens_consumed < session.token_budget:
        chunk = await agent.run(task, max_tokens=1000)
        tokens_consumed += chunk.token_count

        if session.should_save_checkpoint(tokens_consumed):
            session.checkpoints.append(agent.capture_state())
            print(f"[{session.session_id}] Checkpoint saved at {tokens_consumed} tokens")

        # 时间到 or Token 用完 → 重置 Agent 状态
        if session.needs_reset() or session.token_budget - tokens_consumed < 500:
            print(f"[{session.session_id}] Flow cycle complete. Resetting agent state...")
            await save_checkpoint(session.session_id, session.checkpoints[-1])
            agent.reset()  # 清空上下文,重新开始
            session.started_at = time.time()  # 新周期
            session.checkpoints.clear()

    return session.checkpoints

Enter fullscreen mode Exit fullscreen mode


教训五:动态模型路由——别让简单任务占用 Claude Opus 的配额

Dev.to 本周最热门文章标题告诉我们一个真相:

"AI 不笨,是你的配置笨。"(97 reactions)

实测数据: 简单任务(修 typo、重命名变量、格式化代码)用 gpt-4o-miniclaude-opus-4 便宜 75 倍,效果几乎一样。

from enum import Enum
from typing import Literal

class TaskComplexity(Enum):
    TRIVIAL    = ("gpt-4o-mini", 0.001)   # 每千 Token 成本(美元)
    STANDARD  = ("gpt-4o", 0.015)
    COMPLEX   = ("claude-sonnet-4", 0.015)
    EXPERT    = ("claude-opus-4", 0.075)

def assess_complexity(task: str) -> TaskComplexity:
    """简单关键词匹配 — 生产环境建议换成 LLM 分类器"""
    t = task.lower()

    if any(k in t for k in ["typo", "rename", "format", "lint", "单行修改"]):
        return TaskComplexity.TRIVIAL
    if any(k in t for k in ["refactor", "重构", "redesign", "重设计"]):
        return TaskComplexity.COMPLEX
    if any(k in t for k in ["security", "安全", "audit", "审计", "compliance"]):
        return TaskComplexity.EXPERT
    return TaskComplexity.STANDARD

def execute_routed(task: str, router_llm) -> dict:
    level = assess_complexity(task)
    model, cost = level.value

    result = router_llm.complete(task, model=model)

    return {
        "model": model,
        "cost_per_1k": cost,
        "complexity": level.name,
        "result": result
    }

# 效果:60-90% 的 Token 成本降低,响应速度提升 3-5 倍

Enter fullscreen mode Exit fullscreen mode


行业反馈

"在发现 Kontext CLI 之前,光是凭证问题就花了我 2 周。Credential 管理和 Agent 编排是分不开的。" —— HN 热评

"Superset 的设计思路很清晰:把 Cursor 的并行会话模型扩展到 10+ Agent,加上 Git 冲突自动解决。" —— HN 热评

"MCP Server 就是新时代的 npm 包——没人审计权限就往 Agent 里塞。" —— HN 热评


总结

Demo 里完美的 Agent 框架,上生产就崩——根本原因是 安全策略、隔离机制、上下文管理、凭证路由 这四件事没做对。

这 5 个教训来自过去一周 HN 最火的 Agent 基础设施讨论:Kontext CLI、Superset、JACoB,以及正在崛起的 MCP 安全审计生态。

推荐工具:


关联阅读


你们团队在 Agent 生产部署中踩过哪些坑?评论区见——凭证管理和并行隔离的话题特别想听听大家的实战经验。