The proliferation of Large Language Models (LLMs) has catalyzed a shift towards autonomous agents capable of complex reasoning and tool use. However, current agent architectures are frequently constructed using imperative, ad hoc patterns. This results in brittle systems plagued by difficulties in state management, error handling, and concurrency. This paper introduces Monadic Context Engineering (MCE), a novel architectural paradigm leveraging the algebraic structures of Functors, Applicative Functors, and Monads to provide a formal foundation for agent design. MCE treats agent workflows as computational contexts where cross-cutting concerns, such as state propagation, short-circuiting error handling, and asynchronous execution, are managed intrinsically by the algebraic properties of the abstraction. We demonstrate how Monads enable robust sequential composition, how Applicatives provide a principled structure for parallel execution, and crucially, how Monad Transformers allow for the systematic composition of these capabilities. This layered approach enables developers to construct complex, resilient, and efficient AI agents from simple, independently verifiable components. We further extend this framework to describe Meta-Agents, which leverage MCE for generative orchestration, dynamically creating and managing sub-agent workflows through metaprogramming. Project Page: https://github.com/yifanzhang-pro/monadic-context-engineering.


翻译:大型语言模型(LLM)的激增推动了能够进行复杂推理和工具使用的自主智能体的发展。然而,当前的智能体架构通常采用命令式的、临时性的模式构建。这导致了脆弱的系统,普遍存在状态管理、错误处理和并发控制方面的困难。本文提出了单子上下文工程(MCE),这是一种新颖的架构范式,它利用函子、应用函子和单子的代数结构,为智能体设计提供了形式化基础。MCE将智能体工作流视为计算上下文,其中横切关注点——如状态传播、短路错误处理和异步执行——由抽象的代数属性进行内禀管理。我们论证了单子如何实现健壮的顺序组合,应用函子如何为并行执行提供原则性结构,以及关键地,单子变换器如何允许对这些能力进行系统性组合。这种分层方法使开发者能够从简单的、可独立验证的组件出发,构建复杂、鲁棒且高效的人工智能体。我们进一步扩展此框架以描述元智能体,它利用MCE进行生成式编排,通过元编程动态创建和管理子智能体工作流。项目页面:https://github.com/yifanzhang-pro/monadic-context-engineering。

0
下载
关闭预览

相关内容

【WWW2024】动态图信息瓶颈
专知会员服务
23+阅读 · 2024年2月13日
专知会员服务
38+阅读 · 2021年9月15日
【CVPR 2021】变换器跟踪TransT: Transformer Tracking
专知会员服务
22+阅读 · 2021年4月20日
【NeurIPS2019】图变换网络:Graph Transformer Network
专知会员服务
112+阅读 · 2019年11月25日
【NeurIPS2019】图变换网络:Graph Transformer Network
PointNet系列论文解读
人工智能前沿讲习班
17+阅读 · 2019年5月3日
误差反向传播——CNN
统计学习与视觉计算组
30+阅读 · 2018年7月12日
论文浅尝 | Know-Evolve: Deep Temporal Reasoning for Dynamic KG
开放知识图谱
36+阅读 · 2018年3月30日
Mask R-CNN 论文笔记
统计学习与视觉计算组
11+阅读 · 2018年3月22日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
17+阅读 · 2008年12月31日
Arxiv
0+阅读 · 12月29日
Arxiv
0+阅读 · 12月29日
VIP会员
相关VIP内容
【WWW2024】动态图信息瓶颈
专知会员服务
23+阅读 · 2024年2月13日
专知会员服务
38+阅读 · 2021年9月15日
【CVPR 2021】变换器跟踪TransT: Transformer Tracking
专知会员服务
22+阅读 · 2021年4月20日
【NeurIPS2019】图变换网络:Graph Transformer Network
专知会员服务
112+阅读 · 2019年11月25日
相关资讯
【NeurIPS2019】图变换网络:Graph Transformer Network
PointNet系列论文解读
人工智能前沿讲习班
17+阅读 · 2019年5月3日
误差反向传播——CNN
统计学习与视觉计算组
30+阅读 · 2018年7月12日
论文浅尝 | Know-Evolve: Deep Temporal Reasoning for Dynamic KG
开放知识图谱
36+阅读 · 2018年3月30日
Mask R-CNN 论文笔记
统计学习与视觉计算组
11+阅读 · 2018年3月22日
相关论文
相关基金
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
17+阅读 · 2008年12月31日
Top
微信扫码咨询专知VIP会员