arXiv:2609.00621cs.AISep 2026

Manuscript Offprint

arXiv:2609.00621

Control-Data Flow Separation: Stable Prompt Optimization in Multi-Agent LLMs

Wentao Zhang, Syed Shariyar Murtaza, Junaid Ahmad Bhatti, Utkarsh Soni, Yifan Nie, Eugene Wen, Yuntian Deng

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Prompt optimization can improve multi-agent LLM systems, but the prompts being optimized often serve two entangled roles: generating task-relevant content and specifying execution-critical protocols, such as message routing, output formatting, and termination signals, on which the underlying code relies. As a result, a prompt edit intended to improve content generation can inadvertently corrupt the protocol and cause the entire agent pipeline to fail. Our key observation is that these two roles have different representations: execution protocols are typically structured, while task-relevant content is usually expressed in unstructured language. Based on this, we propose control-data flow separation, where execution-critical control is represented as typed, validated program objects, while task-relevant language remains the optimizable data flow for agent communication. This design allows optimizers to improve multi-agent behavior without exposing the routing or formatting interface to prompt drift. Across synthetic reasoning, collaborative review generation, and insurance rating workflows, our framework empirically achieves 100% eventual protocol validity while consistently improving task performance.

1 Introduction

Language-model-based multi-agent systems (Wu et al., 2023; Hong et al., 2024; Qian et al., 2024; Li et al., 2023; Gan et al., 2025; Zheng et al., 2025), where specialized agents collaborate to solve complex tasks, are increasingly used in applications such as review generation (D'Arcy et al., 2024) and software engineering (Yang et al., 2024b; Xia et al., 2024; Wang et al., 2025; Antoniades et al., 2025; Chen et al., 2024a). In these systems, the behavior of each agent is usually defined by a prompt that specifies its role, responsibilities, and communication behavior. While many existing systems rely on manually written prompts, prompt

optimization offers a natural route for improving them: instead of hand-tuning each agent, methods such as APE (Zhou et al., 2023), OPRO (Yang et al., 2024a), TextGrad (Yuksekgonul et al., 2025), DSPy (Khattab et al., 2024; Opsahl-Ong et al., 2024), and GEPA (Agrawal et al., 2026) treat prompts as parameters and optimize them using feedback from downstream task performance.

However, applying prompt optimization directly to multi-agent systems introduces a distinct failure mode. The difficulty is that prompts in these systems often serve two entangled roles. On the one hand, they guide the production of task-relevant data, such as explanations, summaries, critiques, and intermediate results. On the other hand, they specify execution-critical protocols on which the surrounding program relies, such as output formats, routing commands, and termination signals. For example, a leader agent may be instructed to output a JSON object containing an action field and a target-agent field, which a Python controller then parses to decide which worker agent should act next. In such a system, the prompt is not merely an instruction for producing task-relevant data; it is also part of the interface between the LLM and the program that executes the agent pipeline.

This entanglement makes prompt optimization fragile. A prompt edit intended to improve the agent's substantive output can inadvertently change the protocol instructions that the controller depends on. The resulting failure is not simply a lower-quality answer, but a broken execution trace: messages may be mis parsed, routed to nonexistent agents, or cause the program to crash entirely. As we show empirically, this is not a hypothetical concern: in a multi-agent review-generation pipeline, naive prompt optimization corrupts the format instructions and causes the system to collapse to zero usable output during the optimization process.

Our key observation is that these two roles have different natural representations and different con-sumers. Execution protocols are typically structured: they consist of discrete actions, routing targets, stop signals, and other fields that are read by code to control the agent workflow. Task-relevant data, by contrast, is usually unstructured: it consists of explanations, arguments, critiques, and other information that is read by other agents and by the prompt optimizer, but should not be parsed by the program controller for execution decisions. This distinction suggests that the two should not be entangled in a single textual output field.

We therefore propose control-data flow separation, a framework in which each agent output is divided into two channels: a control channel and a data channel. The control channel is a typed, validated program object consumed by the controller; it is not editable by agents or prompt optimizers. It specifies execution-critical information such as routing and termination, and is constrained by a schema that is validated at runtime. The data channel is a free-form message consumed by other agents and by the optimizer, and remains the surface on which end-to-end prompt optimization operates. In other words, the program reads structured control, while agents and optimizers read task-relevant data.

This design preserves the expressiveness of agent systems while preventing prompt optimization from corrupting the underlying execution protocol. Agents can still exchange rich natural-language messages, optimizers can still improve their prompts based on feedback, and the interaction graph can still depend on agent decisions. At the same time, routing targets, output formats, and termination signals are validated through typed program objects rather than fragile natural-language conventions.

Control-data separation follows established software-engineering principles rather than introducing a new type system or separation principle. Our contribution is to make this separation explicit and enforceable for prompt optimization in Python-controlled multi-agent systems, formalize the resulting program-safety property, implement it in cdsep, and evaluate it empirically.

We evaluate this idea on four settings (BBH single-agent reasoning, MARG review generation, and synthetic + industry-verified insurance underwriting), and complement them with a three-family LLM robustness study on MARG (OpenAI, Anthropic, and Google). Across the four settings, our framework empirically achieves 100% eventual protocol validity, while naive TextGrad sometimes collapses entirely. On review generation, our method improves Jaccard from 31.0 to 44.4, outperforming DSPy's BootstrapFewShot and MIPROv2 teleprompters on the same benchmark with the same base LLM. Beyond the empirical evaluation, we implement the framework as a Python library, cdsep, whose interface supports complete multi-agent pipelines in fewer than 40 lines of Python (Listing 3). Our code is available at https://github.com/yuntian-group/cdsep.