Every major LLM agent framework gives the LLM the role of orchestrator; the model decides what to do next, when to call tools, and when to stop. We argue that token explosion, control-flow hallucination, and unreliable completion are not implementation bugs but architectural consequences of assigning the deterministic work of looping, branching, and sequencing to a probabilistic system. A better prompt or a stronger model cannot guarantee the reliability of the LLM agent. We therefore propose Agentic Programming, in which the program governs all control flow, and the LLM is itself part of it, an adaptive component we call LLM-as-Code and invoke only where a task calls for reasoning or generation. Within each call the model keeps full flexibility, but it cannot alter the program's execution path. With control in the program, the LLM's context is built from the execution history's call tree and forms a directed acyclic graph (DAG). Each call's context length is then determined by its call depth rather than by accumulation over steps. A case study of computer-use agents shows that the design is practical, not just a theoretical stance, substantially improving the stability of long visual operation sequences.
翻译:每个主流大语言模型智能体框架都将LLM赋予编排者的角色:由模型决定下一步行动、何时调用工具以及何时终止。我们认为,令牌爆炸、控制流幻觉和不可靠完成并非实现缺陷,而是将循环、分支和排序等确定性工作分配给概率系统所导致的架构性后果。即便使用更优的提示或更强的模型,也无法保证LLM智能体的可靠性。为此,我们提出智能体编程方法,即由程序主导所有控制流,而LLM作为其中的自适应组件,我们称之为“LLM作为代码”,仅在任务需要推理或生成时才被调用。在每次调用中,模型保持完全灵活性,但无法改变程序的执行路径。由于控制权归属于程序,LLM的上下文通过执行历史中的调用树构建,形成有向无环图(DAG)。每次调用的上下文长度由其调用深度决定,而非随步骤累积。针对计算机使用智能体的案例研究表明,该设计不仅是理论立场,更具实践可行性,能显著提升长视觉操作序列的稳定性。