ChatPaper.aiChatPaper

探秘克劳德代码:当代与未来AI智能体系统的设计疆域

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

April 14, 2026
作者: Jiacheng Liu, Xiaohan Zhao, Xinyi Shang, Zhiqiang Shen
cs.AI

摘要

Claude Code是一种代理式编码工具,可代表用户执行shell命令、编辑文件及调用外部服务。本研究通过分析其公开的TypeScript源代码,并与独立开源AI代理系统OpenClaw进行对比,系统阐述了其整体架构。OpenClaw作为另一种部署情境下的多通道个人助理网关,以不同方式回应了诸多相同的设计问题。我们识别出驱动该架构的五大人本价值观、哲学理念与需求(人类决策权威、安全与保障、可靠执行、能力增强及情境适应性),并将其通过十三项设计原则映射至具体实现方案。该系统核心采用简单的循环结构:调用模型、运行工具、循环执行。但大部分代码实现在循环外围的支撑系统中:包含七种模式与基于机器学习分类器的权限系统、五层压缩流程的上下文管理机制、四种扩展机制(MCP、插件、技能与钩子)、具备工作树隔离的子代理委派机制,以及面向追加的会话存储。与多通道个人助理网关OpenClaw的对比表明,当部署情境改变时,相同的基础设计问题会催生不同的架构解决方案:从基于动作的安全分类转向边界级访问控制,从单一CLI循环演进为网关控制平面内的嵌入式运行时,从上下文窗口扩展发展为网关级能力注册。最后我们基于近期实证研究、架构设计与政策文献,为未来代理系统提出六大开放设计方向。
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 comprehensive architecture by analyzing the publicly available TypeScript source code and further comparing it with OpenClaw, an independent open-source AI agent system that answers many of the same design questions from a different deployment context. Our analysis identifies five human values, philosophies, and needs that motivate the architecture (human decision authority, safety and security, reliable execution, capability amplification, and contextual adaptability) and traces them through thirteen design principles to specific 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 mechanism with worktree isolation, and append-oriented session storage. A comparison with OpenClaw, a multi-channel personal assistant gateway, shows that the same recurring design questions produce different architectural answers when the deployment context changes: from per-action safety classification to perimeter-level access control, from a single CLI loop to an embedded runtime within a gateway control plane, and from context-window extensions to gateway-wide capability registration. We finally identify six open design directions for future agent systems, grounded in recent empirical, architectural, and policy literature.
PDF60April 18, 2026