arXiv:2604.14228cs.SEcs.AI2026-04被引 30

剖析Claude Code的智能体设计,揭示安全与可控的核心架构。

Dive into Claude Code: The Design Space of Today's and Future AI Agent Systems

论文配图:Dive into Claude Code: The Design Space of Today's and Future AI Agent Systems
图 1 · 摘自论文原文
  • 以循环调用模型+工具为核心,构建可扩展的智能体系统。
  • 通过七种权限模式和五层压缩管道实现安全与上下文管理。
  • 适合关注AI代理安全、可解释性与工程落地的研究者与开发者。

Claude Code 是一个能够代为执行命令行操作、编辑文件并调用外部服务的智能体编码工具。本文通过分析其公开源码,并与两个独立开源智能体系统 OpenClaw 和 Hermes Agent 对比,探讨了当前及未来智能体系统的架构设计空间。研究识别出五大驱动设计的人类价值:人类决策权、安全性、隐私性、执行可靠性、能力增强与情境适应性,并将其转化为十三项设计原则。系统核心是一个简单循环:调用模型、执行工具、重复。大部分代码则用于支撑该循环的外围系统:包含七种权限模式与机器学习分类器的权限机制;五层压缩管道构成的上下文管理方案;四种可扩展机制(MCP、插件、技能、钩子);子代理委派与调度机制;以及追加式会话存储。对比显示,相同设计问题在三种部署环境下有不同解法:Claude Code 强调每一步操作的安全性,OpenClaw 注重边界访问控制,Hermes 则在多个界面实现每步审批。运行时层面,Claude Code 采用单一 CLI 循环,OpenClaw 将运行时嵌入网关控制平面,Hermes 使用由入口点决定角色的单一进程。上下文与扩展层面,Claude Code 扩展上下文窗口,OpenClaw 在网关级注册能力,Hermes 提供可插拔的记忆与模型后端。最后,基于近期实证、架构与政策文献,提出六个面向未来的开放设计方向。

原文摘要 · Abstract (English)

Claude Code is an agentic coding tool that can run shell commands, edit files, and call external services on behalf of the user. This study describes its architecture by analyzing the publicly available source code and comparing it with two independent open-source AI agent systems, OpenClaw and Hermes Agent, that answer many of similar or even the same design questions. Our analysis identifies five human values, philosophies, and needs that motivate the architecture: human decision authority, safety, security, and privacy, reliable execution, capability amplification, and contextual adaptability. We then trace them through thirteen design principles to implementation choices. The core of the system is a simple while-loop that calls the model, runs tools, and repeats. Most of the code, however, lives in the systems around this loop: a permission system with seven modes and an ML-based classifier, a five-layer compaction pipeline for context management, four extensibility mechanisms (MCP, plugins, skills, and hooks), a subagent delegation and orchestration mechanism, and append-oriented session storage. Comparisons with OpenClaw and Hermes Agent show that the same design questions produce different answers across three deployment contexts. Claude Code emphasizes per-action safety, OpenClaw emphasizes perimeter-level access, and Hermes renders per-action approvals across many surfaces. At the runtime layer, Claude Code uses a single CLI loop, OpenClaw embeds the runtime within a gateway control plane, and Hermes uses one process whose role is set by its entry point. At the context and extension layer, Claude Code extends the context window, OpenClaw registers gateway-wide capabilities, and Hermes provides pluggable memory and model backends. We finally identify six open design directions for future agent systems, grounded in recent empirical, architectural, and policy literature.

智能体系统安全设计架构分析AI代理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。