Paper deep dive
Joint Workflow and Prompt Optimization for User Behavior Simulation
Nipun B Nair, Tongtong Wu, Hongzhi Yin, Hui Li, Weiqing Wang
Intelligence
Status: succeeded | Model: Gemma-4-26B-A4B | Prompt: intel-v1 | Confidence: 90%
Last extracted: 10/13/2026, 3:59:36 AM
Summary
The paper introduces SWORD, a framework for user behavior simulation that jointly optimizes multi-agent workflow topology and natural-language prompts. Unlike existing methods that rely on hand-crafted rules or static designs, SWORD uses a closed-loop optimization process guided solely by scalar task metrics (like MAE or RMSE). It employs a fixed vocabulary of eight task-agnostic agent roles (e.g., Analyzer, Planner, Critic) arranged in Directed Acyclic Graphs (DAGs). The framework autonomously discovers domain-relevant signals and rules through textual gradients, achieving statistically significant performance gains over baselines while requiring less training data and computational cost.
Entities (21)
Relation Signals (19)
Hongzhi Yin â affiliatedwith â The University of Queensland
confidence 95% · Affiliation: The University of Queensland, Brisbane, Queensland, Australia
Hui Li â affiliatedwith â Xiamen University
confidence 95% · Affiliation: Xiamen University, Department of Computer Science and Technology, Xiamen, China
Weiqing Wang â affiliatedwith â Monash University
confidence 95% · Affiliation: Monash University, Melbourne, Victoria, Australia
Nipun B Nair â affiliatedwith â Monash University
confidence 95% · Affiliation: Monash University, Melbourne, Victoria, Australia
Tongtong Wu â affiliatedwith â Monash University
confidence 95% · Affiliation: Monash University, Melbourne, Victoria, Australia
SWORD â optimizes â multi-agent workflow topology
confidence 95% · SWORD is introduced as a framework that jointly optimizes multi-agent workflow topology and natural-language prompts.
SWORD â optimizes â natural-language prompts
confidence 95% · SWORD is introduced as a framework that jointly optimizes multi-agent workflow topology and natural-language prompts.
SWORD â employs â Directed Acyclic Graph
confidence 90% · Each workflow is a directed acyclic graph (DAG) over eight task-agnostic agent roles...
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:User behavior simulation is the computational modeling of user interactions within information systems through the use of simulated agents in place of live users. It supports system testing and evaluation, decision-making and forecasting, and user experience design. Existing simulators rely on hand-crafted rules or domain expertise that transfers poorly across tasks. SWORD (Simulation-driven Workflow and Prompt Optimization with Role-based Design) is introduced as a framework that jointly optimizes multi-agent workflow topology and natural-language prompts. It is guided solely by a scalar task metric, without domain initialization or task-specific engineering. The experimental results demonstrate that SWORD achieves statistically significant gains over prompt-only, workflow-only, and staged-optimization baselines under a controlled, identical-backbone comparison. Against the strongest published domain-specific baseline, SWORD further improves accuracy while using a smaller backbone model, substantially less training data, and a very reasonable API cost (\$4--\$6 for each dataset). Beyond predictive performance, SWORD autonomously discovers domain-relevant signals, review-sentiment mapping rules and epidemiological decay priors, purely from scalar error feedback, establishing textual gradients as a mechanism for unsupervised feature-importance discovery in user behavior modeling.
Tags
Links
- Source: https://arxiv.org/abs/2610.07663v1
- Canonical: https://arxiv.org/abs/2610.07663v1
Trouble viewing inline? Open PDF directly â
Full Text
126,198 characters extracted from source content.
Expand or collapse full text
Joint Workflow and Prompt Optimization for User Behavior Simulation Journal: TOISVolume: 1118CCS: Information systems Information systems applications Nipun B Nair Note: primary author email: nipun.nair@monash.edu Affiliation: Monash University, Melbourne, Victoria, Australia , Tongtong Wu email: tongtong.wu@monash.edu Affiliation: Monash University, Melbourne, Victoria, Australia , Hongzhi Yin email: db.hongzhi@gmail.com Affiliation: The University of Queensland, Brisbane, Queensland, Australia , Hui Li email: hui@xmu.edu.cn Affiliation: Xiamen University, Department of Computer Science and Technology, Xiamen, China and Weiqing Wang email: teresa.wang@monash.edu Affiliation: Monash University, Melbourne, Victoria, Australia Abstract. User behavior simulation is the computational modeling of user interactions within information systems through the use of simulated agents in place of live users. It supports system testing and evaluation, decision-making and forecasting, and user experience design. Existing simulators rely on hand-crafted rules or domain expertise that transfers poorly across tasks. SWORD (Simulation-driven Workflow and Prompt Optimization with Role-based Design) is introduced as a framework that jointly optimizes multi-agent workflow topology and natural-language prompts. It is guided solely by a scalar task metric, without domain initialization or task-specific engineering. The experimental results demonstrate that SWORD achieves statistically significant gains over prompt-only, workflow-only, and staged-optimization baselines under a controlled, identical-backbone comparison. Against the strongest published domain-specific baseline, SWORD further improves accuracy while using a smaller backbone model, substantially less training data, and a very reasonable API cost ($4â$6 for each dataset). Beyond predictive performance, SWORD autonomously discovers domain-relevant signals, review-sentiment mapping rules and epidemiological decay priors, purely from scalar error feedback, establishing textual gradients as a mechanism for unsupervised feature-importance discovery in user behavior modeling. Keywords: user simulation, agent-based simulation, multi-agent systems, prompt optimization, workflow optimization, textual gradients, large language models, behavioral prediction, autonomous optimization 1. Introduction Figure 1. Comparison of LLM based user simulation paradigms and the SWORD framework. (A) Agent-per-User: instantiates isolated LLM agents per user, preserving personalization but sharing no knowledge. (B) Code-Generation: achieves personalization via generating executable Python simulation code for each user through shared agent workflow, while shifting the burden of workflow design and simulation logic validation to domain experts, limiting task transferability. (C) SWORD (Ours): is a further step forward compared with Code-Generation to eliminate the dependence on domain experts for different user simulation tasks via automated workflow and prompt optimization and task agnostic modular agent pool design. A three-panel diagram comparing paradigms of user behavior simulation. Panel A shows the Agent-per-User paradigm with isolated LLM agents. Panel B shows the Code-Generation paradigm where an LLM generates a shared Python execution function. Panel C shows the SWORD paradigm featuring a shared workflow DAG (Analyzer, Planner, Generator, Critic, Synthesizer) optimized via an interleaved co-evolution loop of workflow evolution and prompt optimization. User behavior simulation holds significant value in information systems in three key ways. First, it enables informed decision-making and forecasting by predicting how users will interact with system features before actual deploymentCai et al., 2025; Park, 2025. Second, it supports system testing and optimization by examining user behavior across diverse scenarios and contextsMa et al., 2025. Third, it improves user experience design by revealing how different user segments interact with systems, thereby enabling researchers to create more intuitive and responsive interfacesHe et al., 2025. Classical approaches to user behavior simulation use probabilistic frameworks, including click models, cascade models, and position-bias models, which are fitted to logged data Balog and Zhai, 2024; Dupret and Piwowarski, 2008; Maxwell and Azzopardi, 2016. Rule-based agent models extend this by encoding explicit decision logic, interaction rates, and social influence parameters specified by domain experts De Kai et al., 2020; Mortveit et al., 2022. Both families are effective within their original domain, but they transfer poorly: constructing or adapting them requires expert knowledge that is rarely available across the full range of tasks that IR and recommender-system evaluation demands Balog and Zhai, 2024. Large language models (LLMs) offer a fundamentally different path. LLMs encode rich representations of human reasoning, preferences, and social norms, enabling them to serve as the cognitive backbone of simulated users without explicit rule specification Chen and He, 2025; Gao et al., 2024; Wang et al., 2025b. Existing LLM-based user simulation approaches can be grouped into two paradigms, each with a structural limitation (Fig. 1). Agent-per-user methods Park et al., 2023 instantiate one LLM agent per simulated user, preserving personalization but sharing no knowledge across agents: users with sparse interaction histories produce unreliable predictions, and the system must be rebuilt for each new simulation domain. Moreover, the number of agents the system needs to maintain scales linearly with the number of users. Code-generation methods Hua et al., 2026 address the scaling problem by using several agents that communicate through a predefined workflow to generate Python simulation code: given user profile and history information, this code predicts behavior as a single shared function. This removes per-user specialization but shifts the burden onto workflow design (the workflow that defines how agents communicate) and code validation which usually depend on domain experts. The generated code requires iterative review and approval from a domain expert, making transferability contingent on the availability of domain experts, who are both scarce and costly. We introduce SWORD (Simulation-driven Workflow and prompt Optimization with Role-based Design), a framework for user simulation that requires no domain-expert input. SWORD achieves this via joint workflowâprompt optimization, in which the structure of the agent workflow (which agents participate and how they communicate) and the prompts (the instructions given to each agent) are co-optimized end-to-end in a single closed loop. SWORD takes user context (profile, behavioral history, social signals) as input and produces behavioral predictions as output, guided solely by a scalar task metric (MAE or RMSE). Each workflow is a directed acyclic graph (DAG) over eight task-agnostic agent roles: Analyzer, Planner, Generator, Critic, Synthesizer, Executor, Transformer, and Validator. These roles span the full cognitive space of behavioral prediction, from data parsing and planning, through generation and critique, to synthesis and output validation, and they transfer across simulation tasks without modification. Adapting SWORD to a new task requires only 30 labeled training examples and a scalar evaluation error metric, with no simulation code, domain initialization, or task-specific engineering. Contributions. (1) SWORD: a joint optimization framework for LLM-based user simulation requiring no domain-expert input. We introduce a scalable framework that interleaves DAG workflow evolution and prompt optimization within a single optimization loop, with an LLM-guided proposer generating targeted structural mutations informed by the full optimization history. A fixed vocabulary of eight roles transfers unmodified across the two user simulation tasks we evaluate, requiring no domain-expert input or per-task role engineering. (2) Workflowâprompt non-stationarity: empirical characterization and efficient search space reduction. We identify workflowâprompt non-stationarity as an important challenge in multi-agent optimization: the quality of a workflow depends on the prompts it is paired with, rendering staged optimization ineffective. We address this with a practical framework for jointly optimizing agent workflow and prompts, making end-to-end search over both structural and linguistic design spaces computationally feasible. This search space reduction is achieved through mechanisms including elitist selection, a history-conditioned workflow proposer, and worst-case gradient trace selection, as detailed in Section 4.5. (3) Unsupervised user preference discovery via textual gradients. SWORD autonomously identifies review text sentiment as the main signal for predicting user ratings. It learns precise rules that map sentiment to rating scores using only MAE feedback. This process establishes textual gradients as a mechanism for unsupervised feature-importance learning in user behavior modeling. (4) Improved efficiency through joint optimization. SWORD outperforms prior approaches while using a smaller backbone (GPT-5.4-mini) with substantially less training data and computational cost. This highlights that effective joint optimization of workflow structure and prompts can compensate for reduced model capacity and data requirements. The remainder of the paper is organized as follows. Section 2 reviews related work. Section 3 formalises the problem. Section 4 presents the SWORD framework. Section 5 describes the experimental setup. Section 6 presents results and analysis. Section 7 discusses findings. Section 8 concludes the paper. 2. Related Work Our work sits at the convergence of two research streams: user simulation for information systems, and prompt and workflow optimization for multi-agent systems. We review each in turn and identify the shared limitations that SWORD addresses. 2.1. User Simulation for Information Systems User simulation is a long-established task in information systems, including information retrieval and recommender systems Balog and Zhai, 2024. Classical simulators model userâsystem interactions through probabilistic frameworks: click models (including the position-bias model, cascade model, and user-browsing model Dupret and Piwowarski, 2008) capture how users examine and click search results from logged behavioral data. The SimIIR framework Maxwell and Azzopardi, 2016 generalizes this into a configurable toolkit for interactive IR experiments, supporting modular searcher models, stopping criteria, and query generation components. For conversational recommender systems (CRS), prior studies Zhang and Balog, 2020 demonstrate how user simulators enable scalable evaluation without real-user involvement, establishing ground-truth alignment as the central evaluation challenge. UserSimCRS Balog and Kenter, 2023 operationalises agenda-based simulation for CRS evaluation with persona modeling and natural language generation. The introduction of large language models as simulated users represents a paradigm shift in this line of workZhao et al., 2025; Zhu et al., 2025c. LLMs encode representations of human reasoning and social norms that allow them to serve as cognitive backbones for simulated users without explicit rule specification Gao et al., 2024. Existing research Park et al., 2023 demonstrate that generative agents, LLM-driven personas with memory, reflection, and planning, can simulate emergent social behaviors in a sandbox town. Previous surveys Gao et al., 2024; Guo et al., 2024b; Taillandier et al., 2025 cover LLM multi-agent systems and LLM-empowered ABM respectively. The first comprehensive framework Wang et al., 2025b has been designed specifically for user behavior simulation in recommender systems using LLM-based agents. Recent work has extended LLM simulation to user rating prediction with collaborative filtering signals Kim et al., 2024; Luo et al., 2024; Sun et al., 2024, review-based recommendations Luo et al., 2025, and large-scale social platforms Piao et al., 2025; Zhang et al., 2025f. Population-level behavioral dynamics, specifically the epidemic mask-wearing task studied in this paper, are addressed by SOCIA-â Hua et al., 2026 and LLM-ABM baselines. Across all of these systems, however, the agent workflow and agent prompts are treated as static design decisions made by domain experts. No prior work in information systems user simulation applies systematic optimization to either the workflow structure or the prompts. SWORD fills this gap. 2.2. Prompt and Workflow Optimization for Multi-Agent Systems Optimizing a multi-agent system requires improving two interdependent components: agent prompts and workflow topology. The literature has pursued these directions in parallel, holding the other component fixed. Automatic prompt optimization (APO) takes the workflow as given and searches for better instructions using model feedback Chen et al., 2025a; Tang et al., 2024. The textual-gradient paradigm, introduced by ProTeGi Pryzant et al., 2023 and generalised by TextGrad Yuksekgonul et al., 2025, propagates LLM-generated critiques through the pipeline analogously to numerical gradientsChen et al., 2025b; Cui et al., 2025; Davari et al., 2025. Prompts produced by APO methods are optimal only conditional on the fixed topology that generated the gradient signalsYin and Wang, 2025. Workflow optimization methods hold prompts generic and search over topologyLi et al., 2024; Liu et al., 2025; Zhang et al., 2025d; Qian et al., 2025; Zhang et al., 2025c. Representative approaches include AFlow Zhang et al., 2025e, which uses Monte Carlo Tree Search over code-based workflows; EvoFlow Zhang et al., 2025a, which applies evolutionary search to heterogeneous agents; and MaAS Zhang et al., 2025b, which optimizes a probabilistic supernet over architectures. Both streams share a structural limitation: each holds the other variable fixedZhu et al., 2025b, and all evaluations are restricted to reasoning, code generation, or mathematical benchmarksWang et al., 2025c; Wang et al., 2025d. None of these methods has been applied to user behavior simulation. Three recent methods attempt joint optimization but remain staged. MASS Zhou et al., 2026 sequences prompt refinement, workflow search, and global prompt refinement as three fixed phases. MASPO Wang et al., 2026 jointly refines prompts across agents but fixes the workflow throughout. MASPOB Hong et al., 2026 introduces workflow-aware prompt optimization but selects the workflow once at initialization. Because workflow and prompts are never updated simultaneously, the workflow chosen during search is always evaluated under the prompt quality available at that moment, not under the quality that optimization will eventually achieveZhang et al., 2025g; Zhang et al., 2026b. SWORD is the first to treat both as continuously co-optimized variables in a single closed loop, applied to the domain of user behavior simulation. 3. Problem Formulation and Preliminaries 3.1. Problem: Predicting User Behavior from Context User behavior simulation addresses the following prediction problem. Given a userâs profile information (demographics, preferences) and behavioral history (past interactions, ratings, social signals), a simulator must predict the userâs next behavioral output, such as a star rating or a mask-wearing decision, without observing it directly. Formally, let x denote the user context (profile, history, and any task-specific side information) and y the ground-truth behavioral output. The simulator is a function f:xâŠy^f:x y to be learned from a labeled dataset =(xi,yi)i=1ND=\(x_i,y_i)\_i=1^N. 3.2. Preliminaries In this work, we model the simulator f as a multi-agent framework in which agents communicate according to a shared workflow to accomplish the user simulation task. This framework is defined as W=(Ξ,Ï)W=(Ξ, Ï), where Ξ is the workflow defining how agents communicate with each other. More formally, Ξ=(V,E)Ξ=(V,E) is a directed acyclic graph with V denoting agents and E communication links. Ï=ÏvvâV Ï=\ _v\_vâ V are the natural-language prompts governing each agentâs reasoning. Each agent receives the outputs of its predecessors plus a portion of the user context x, processes them according to its prompt Ïv _v, and passes its output downstream. The final agent produces the behavioral prediction y y. 4. The SWORD Framework Algorithm 1 SWORD: Self-Optimizing Workflow Discovery Require : Training set D, metric âłM, candidate workflows P Output : Optimized model â=(â,Ïâ) W^*=(Ξ^*,Ï^*) 1 Initialize P with K random DAG workflows (2â8 agents), each using generic prompts ÏÏ 2 sââââs^*â-â; nnoâ-âimproveâ0n_no -improveâ 0 3 for t=1t=1 to T do 4 for each Ξkâ _k in parallel do 5 Evaluate Ξk _k on D to obtain score sks_k and traces Ïk _k 6 end for 7 Sort P by descending sks_k; (Ξbest,sbest)âargâĄmaxkâĄsk( _best,s_best)â _k\,s_k 8 if sbest>sâs_best>s^* then 9 (Ξâ,Ïâ)â(Ξbest,Ίbest)(Ξ^*,Ï^*)â( _best, _best) 10 sââsbests^*â s_best; nnoâ-âimproveâ0n_no -improveâ 0 11 else 12 nnoâ-âimproveânnoâ-âimprove+1n_no -improveâ n_no -improve+1 13 end if 14 if nnoâ-âimproveâ„Pn_no -improveâ„ P then 15 break 16 end if 17 for each elite topology Ξeâtop-âEâ of â _eâ\top-E of P\ do 18 ÏeââÏe(iâ) _e^-â _e^(i^*) where iâ=argâĄminiâĄse(i)i^*= _i\,s_e^(i) 19 for each agent aâΞeaâ _e do 20 faâAttributeFeedbackâ(a,Ïeâ)f_aâ AttributeFeedback(a,\, _e^-) 21 gaâComputeGradientâ(Ïa,Ïeâ,fa,sbest,âalast-3)g_aâ ComputeGradient( _a,\, _e^-,\,f_a,\,s_best,\,H_a^last-3) 22 ÏaâApplyGradientâ(Ïa,ga) _aâ ApplyGradient( _a,\,g_a) 23 Append (Ïa,sbest,fa)( _a,s_best,f_a) to trajectory history âaH_a 24 end for 25 end for 26 nextâΞe.Clone():Ξeâtop-E elitesP_nextâ\ _e. Clone(): _e -E elites\ 27 for j=1j=1 to KâEK-E do 28 ΞnewâLLMProposeâ(context,ranked) _newâ LLMPropose(D_context,\,P_ranked) 29 if proposal invalid then 30 ΞnewâMutateâ(TournamentSelectâ()) _newâ Mutate( TournamentSelect(P)) 31 end if 32 nextânextâȘΞnewP_next _nextâȘ\ _new\ 33 end for 34 ânextP _next 35 end for 36 if Ξâ=â Ξ^*= then 37 ΞâââĄ[1]Ξ^* [1]; ÏââÏa:aâΞâÏ^*â\ _a:aâΞ^*\ 38 end if 39 Apply ÏâÏ^* to ΞâΞ^* 40 return Wâ=(Ξâ,Ïâ)W^*=(Ξ^*,Ï^*) SWORD operates as a single closed loop that jointly evolves agent workflows and optimizes agent prompts across T iterations. Algorithm 1 illustrates the full pipeline. At initialization, candidate workflows Ξ1,âŠ,ΞK\ _1,âŠ, _K\ are constructed by sampling subsets and orderings of the eight task-agnostic agents (Analyzer, Planner, Generator, Critic, Synthesizer, Executor, Transformer, Validator), and each agent is paired with a default prompt for every active role. A key challenge SWORD is designed to address is workflow rank inversion: as prompt quality improves through optimization, the workflow that performed best under generic initial prompts is no longer optimal under refined prompts. The closed-loop design of SWORD addresses rank inversion directly: by never committing to a fixed workflow, every iteration can discover a new best structure as prompts evolve, keeping the workflow and prompts mutually aligned throughout optimization. (This phenomenon is documented empirically in Section 6.5 and analysed mechanistically in Section 7.3.) 4.1. Workflow Representation Each workflow Ξk _k is a named directed acyclic graph Chen et al., 2024; Hong et al., 2024; Zhuge et al., 2024 over the fixed vocabulary of eight agent roles. Structural constraints are enforced at proposal time as explained in Section D.0.2: âą At least 2 and at most 8 agents (balancing expressiveness vs. computational cost). âą A single source node receiving the raw task input x, and a single sink node producing the prediction. âą Strict DAG structure: no cycles, verified by topological sort before acceptance. SWORD constrains workflows to directed acyclic graphs (DAGs) to prevent agents from overwriting or corrupting each otherâs intermediate outputs, which would degrade prediction fidelity. Each valid workflow is further required to have a single source node, which receives all user context, and a single sink node, which produces the behavioral prediction. This design enforces a clear division of labor across the pipeline. This acyclic single-sourceâsingle-sink structure also ensures that gradient signals propagate unambiguously from the prediction error back through the graph, enabling targeted prompt optimization at each agentâs structural role. 4.2. Task-Agnostic Agent Roles SWORD defines a fixed vocabulary of eight named roles: Analyzer, Planner, Generator, Critic, Synthesizer, Executor, Transformer, and Validator. The vocabulary is grounded in the structure of the user simulation problem. Predicting user behavior requires four functional stages: interpreting user history, forming a prediction strategy, generating a behavioral output, and validating it against task constraints. These stages map directly to Analyzer, Planner, Generator, and Validator. The remaining four roles cover auxiliary operations that arise in behavioral modeling. Synthesizer integrates signals from multiple upstream agents (e.g., combining interaction history with social influence data). Critic checks consistency between a candidate prediction and established user behavioral patterns. Transformer resolves data representation mismatches between agents (e.g., converting raw interaction logs to structured feature vectors). Executor handles deterministic computation such as aggregating population-level statistics. Together the eight roles form a complete functional basis for user simulation without encoding assumptions about any specific task, metric, or user population. The same vocabulary applies unchanged to rating prediction on Agent Society and adoption modeling on Mask Adoption, with the optimization process determining which subset to include and how to connect them. Fixing the vocabulary to eight roles bounds the structural search space without restricting expressiveness. Initial prompts are given in Section D.0.5. 4.3. Workflow-Conditioned Textual Gradient Prompt Update Each iteration, SWORD selects the single worst-performing training example and issues a per-agent gradient call for each agent in the elite workflow. For agent v, this proceeds as three sequential LLM calls: feedback attribution (AttributeFeedback), gradient computation (ComputeGradient), and prompt rewriting (ApplyGradient). The prompts used here are shown in Section D.0.1. AttributeFeedback takes the global evaluation feedback produced by scoring the workflow against the worst-performing training example and attributes it to a specific agent v. It receives the agentâs name, role, and outputs, together with the global feedback string, and uses an LLM to extract only the portions of that feedback relevant to vâs contribution. The result is rephrased as direct feedback to v: if no part of the global feedback is attributable to vâs outputs, the call returns "No specific issues." This step is necessary because global feedback critiques the workflowâs final prediction error without distinguishing which agent caused it. AttributeFeedback performs that attribution before the gradient is computed. ComputeGradient produces a structured gradient with four fields: âą EA (Error Analysis): what agent v output, and how it contributed to the final error. âą GD (Gradient Direction): the semantic direction in which Ïv _v should change to reduce error. âą M (Magnitude): whether the change warrants a major rewrite, moderate update, or minor calibration. âą SC (Specific Changes): concrete before/after edits to Ïv _v. ApplyGradient then takes the current prompt Ïa _a and gradient gag_a and rewrites Ïa _a in the direction given by GD, at the severity given by M, incorporating the edits in SC while preserving the agentâs core role identity. The gradient call is workflow-conditioned: it supplies agent vâs upstream agents and their outputs alongside the four gradient fields, ensuring that the critique is grounded in the actual inputs v received rather than its role in isolation. As a result, the same named role receives different gradient signals depending on where it sits in the workflow. This design is the key distinction from fixed-architecture methods such as DSPy Khattab et al., 2024 and MIPRO Opsahl-Ong et al., 2024. For example, an Analyzer that is the sole upstream agent in a compact two-agent workflow receives gradients emphasizing feature completeness, since downstream prediction depends entirely on its output. The same Analyzer in a larger workflow, mediated by a Planner before reaching the Generator, instead receives gradients emphasizing signal selectivity, since over-complete output burdens the Planner unnecessarily. The workflow context is thus constitutive of the gradient, not incidental to it. To prevent gradient drift, each agent maintains a trajectory history âaH_a of previous promptâscoreâfeedback triples. ComputeGradient conditions on only the last three entries of âaH_a: enough to detect oscillation (a score declining after a prompt update) and reinforce a consistent improvement direction, without the context overhead of the full history. Within each iteration, the gradient is computed from a single example: the worst-performing one in the training set. This example maximizes the gap between prediction and ground truth, which in turn makes the resulting error attribution to individual agents more discriminative than gradients computed on near-correct examples. 4.4. LLM-Guided Workflow Evolution At each iteration, SWORD maintains a set of K candidate workflow topologies, all evaluated concurrently on the training set using a thread pool. Exploiting the I/O-bound nature of LLM API calls, this achieves near-linear speedup across the set without violating API rate limits. An LLM proposer can reason about which functional configurations make sense for user behavior prediction in a way that random mutation cannot Fernando et al., 2024; Shang et al., 2025. Elitist selection. The top E scoring topologies are cloned unchanged into the next generation, guaranteeing that the optimization front is monotonically non-decreasingGuo et al., 2024a; Liu et al., 2024a. This is particularly consequential in user behavior simulation: a poorly matched topology mutation can cause output schema mismatches or cascading format errors that collapse predictions across all training examples for an entire iteration. Retaining the elite set as a guaranteed fallback prevents valid behavioral structure discovered in earlier iterations from being discarded. History-conditioned LLM proposer. The remaining KâEK-E slots are filled by a Workflow proposer, an LLM that receives two inputs: (1) the task description, and (2) a compact ranked summary of the entire current candidate set, where each entry contains the topologyâs rank, mean score, per-example score standard deviation, agent list as name,role\name,role\ pairs, edge list, and the feedback string from its worst-performing example. Feedback strings are truncated to 200 characters per topology to keep the proposer prompt within a predictable context budget while still conveying the dominant failure mode. Providing the full ranked candidate set rather than only the best topology allows the proposer to reason about which structural regions have already been explored and which remain promising, functioning as an implicit history-conditioned search memoryHu et al., 2025a; Hu et al., 2025b. The proposer returns a structured JSON specification containing a one-sentence reasoning trace, a list of named agentârole pairs, an edge list, and a designated entry and exit node. This output format enforces the single-sourceâsingle-sink DAG constraint directly in the LLMâs generation space and makes proposals machine-parseable without natural-language post-processing. Refer to Section D.0.3 for implementation. Robustness and fallback. Because LLM outputs are not guaranteed to be valid JSON, the proposer pipeline applies a sequence of recovery steps: regex extraction of JSON substrings, removal of trailing commas, and normalisation of single-quoted keys and values. Any proposal that cannot be recovered, specifies fewer than two agents, or references an invalid role is silently rejected and replaced by a random mutation of a tournament-selected parent from the current candidate set. This dual-path design ensures the evolution loop never stalls regardless of LLM output quality. Structural validity enforcement. After every proposal or mutation, three invariants are enforced before evaluation: the entry agent has at least one outgoing edge, the exit agent has at least one incoming edge, and a directed path exists from every entry to every exit. Violations are repaired by adding the minimum number of edges necessary without removing any edges contributed by the proposal. Cycle detection is performed by depth-first search prior to every edge insertion, maintaining acyclicity throughout. This proposer is conceptually related to the evolutionary operators in EvoFlow Zhang et al., 2025a and the MCTS expansion policy in AFlow Zhang et al., 2025e, but conditions on task-specific metric signals and per-agent execution traces rather than code coverage scores or tree rewards. It also relates to the Socratic dialogue planning of MARS Zhang et al., 2026a, but operates at the workflow structural level rather than the prompt level. An example of the evolution is given in Section B. 4.5. Search Space Reduction Joint optimization over workflow topologies and natural-language prompts is in principle intractable: the space of DAGs over 8 named roles is combinatorial, and the space of natural-language prompts is unbounded. SWORD reduces this space through five complementary mechanisms. (1) Fixed role vocabulary. Workflows are constrained to DAGs over a closed vocabulary of 8 task-agnostic roles. In user behavior simulation, the cognitive operations requiredâobserving user context, planning behavioral trajectories, generating behavioral predictions, critiquing outputs, and validating against task constraintsâmap naturally onto these roles. This bounds the structural search to ordered subsets and topologies over a finite, semantically grounded vocabulary rather than over arbitrary agent specifications. (2) DAG structural constraints. Every candidate workflow must satisfy three hard constraints enforced before evaluation: at least 2 and at most 8 agents, a single source node (ensuring all agents receive the same user context), and a single sink node (ensuring a unified behavioral prediction output), with no directed cycles (preventing infinite reasoning loops that would block output). These constraints prune a large fraction of the combinatorial graph space before any LLM call is made. (3) Elitist selection. The current best workflow is preserved unchanged across every iteration. Only KâEK-E new candidates are generated per round. In user simulation, a single bad structural mutation can collapse predictions across all training users for an entire iteration; elitist retention guarantees that at least E high-quality candidates always survive, making the optimization monotonically non-decreasing in performance. Elitist selection is not merely a variance-reduction device. It ensures that prompt gradient updates accumulate on persistent topologies, preventing the investment of three LLM gradient calls from being discarded when a workflow is replaced. (4) History-conditioned workflow proposer. The LLM proposer receives a compact ranked summary of the current candidate set: for each topology, the entry contains its rank, mean score, per-example score standard deviation, agent list as name, role pairs, edge list, and a 200-character feedback string truncated from its worst-performing example. Providing the full ranked candidate set rather than only the best topology allows the proposer to infer which structural regions have already been explored, functioning as an implicit search memory. Refer to Section D.0.3 for implementation. (5) Gradient trace selection. For prompt optimization, the gradient is computed from the single worst-performing training example per iteration, the example where the gap between prediction and ground truth is largest, and therefore where the error signal attributable to individual agents is most discriminative. This focuses the prompt update on the failure mode that most urgently requires correction, rather than averaging over examples where the workflow already performs adequately. Mechanisms (1)â(2) reduce the structural search space; mechanisms (3)â(4) focus the search trajectory; mechanism (5) reduces the effective dimensionality of the prompt update at each step. Together they make joint optimization tractable and reliably convergent within T=5T=5 iterations (Section 6.7). 5. Experimental Setup 5.1. Research Questions The experiments address four research questions that correspond directly to the four contributions stated in Section 1. RQ1 (User simulation performance).: How does SWORD perform on user behavior simulation tasks compared with existing methods? RQ2 (Joint optimization superiority and efficiency).: Does jointly optimizing workflow topology and prompts in a single closed loop outperform prompt-only, workflow-only, and staged optimization baselines, and can workflowâprompt coupling non-stationarity explain why staged approaches fail while five complementary search space reduction mechanisms make joint co-optimization computationally efficient? RQ3 (Unsupervised preference discovery).: Without any task-specific initialization, can metric-conditioned textual gradients autonomously discover the task-relevant user preference signals such as review-text sentiment for rating prediction, or epidemiological decay dynamics for behavioral adoption? RQ4 (Model and data efficiency).: Does SWORDâs joint co-optimization strategy yield competitive or superior performance compared to state-of-the-art baselines that use a stronger backbone model, at a lower API cost? Table 1 summarises which experimental section addresses each question. Table 1. Research question to section mapping. RQ Addressed in Evidence RQ1 §6.1,6.2 Tables 2, 3 RQ2 §6.5 Table 5 RQ3 §6.6 Figure 2, Table 6 RQ4 §6.7 Table 8 5.2. Tasks and Datasets We use two user simulation tasks to evaluate our model: Mask Adoption and rating prediction on the Agent Society dataset Hua et al., 2026.11 1 https://github.com/cruiseresearchgroup/SOCIA/tree/odd-dev Mask Adoption (RMSEâ ). Daily population-level mask-wearing rate prediction over a synthetic population of 1000 agents. The dataset is structured around three complementary files. agent_attributes.csv records per-agent demographics (age group, occupation, and risk perception for each of the 1000 agents). daily_aggregate_data.csv provides ground-truth population-level mask rates and information-spread rates per day. Days 0 to 29 are used as the training horizon and days 30 to 39 as the held-out test horizon. train_data.csv supplies 1000 agent-level observations per training day for the SWORD optimization loop. The social contact structure is encoded in a four-layer network (family, work/school, community, and full) loaded from social_network.pkl. Ground truth is generated by an agent-based model calibrated on COVID-19 behavioral dynamics De Kai et al., 2020; Mortveit et al., 2022. Agent Society (MAEâ ). Star rating prediction (1â5) across three platforms: Amazon, Goodreads, and Yelp. For each platform, independent train and test JSON splits are provided. Each record contains a user_id, item_id, ground-truth stars, and full review text. Supplementary metadata files (user_sample.json, item_sample.json) supply user-level and item-level metadata that serve as additional workflow inputs. Ground truth is drawn from the AgentSociety benchmark Piao et al., 2025. This task is related to LLM-based rating evaluation Kang et al., 2023. 5.3. Baselines Baselines are selected to provide one representative from each of the four research streams reviewed in Section 2, so that SWORD can be evaluated against the current state of the art in every relevant category. User simulation systems (Section 2.1). SOCIA-â Hua et al., 2026 applies textual gradient descent directly to generated Python simulation code on the same benchmarks, using GPT-5-class models. It is the strongest domain-specific competitor. The following five code-generation user simulator results are sourced from the SOCIA-â paper. AI Scientist-v2 Yamada et al., 2025 uses agentic tree search to iteratively propose and refine simulation code. YuLan-OneSim Wang et al., 2025a generates LLM-driven social simulation scripts from natural-language task descriptions. G-SIM-ES and G-SIM-SBI Holt et al., 2025 calibrate LLM-generated simulators via evolutionary search and simulation-based inference respectively. Reflexion Shinn et al., 2023 improves generated simulation logic through iterative verbal self-reflection without weight updates. Automatic prompt optimization (Section 2.2). Prompt-Only (e.g., Chen et al., 2025c) fixes the workflow to the initial template throughout and optimizes prompts alone, providing the fairest test of whether joint optimization adds value beyond prompt tuning. Multi-agent workflow search (Section 2.2). Workflow-Only (e.g., Zhang et al., 2025e) runs topology search with prompts kept generic throughout, testing whether structural diversity alone is sufficient. Joint prompt and workflow optimization (Section 2.2). Staged Optimization (e.g., Zhou et al., 2026) uses both components sequentially: Phase 1 searches workflows with generic prompts frozen; Phase 2 then optimizes prompts with the selected workflow frozen. Any advantage SWORD holds over it is attributable solely to interleaving versus staging. Together, these four baseline categories form a controlled ablation. They allow us to attribute SWORDâs gains precisely to the joint closed-loop design, rather than to data, backbone, or task-specific engineering choices. 5.4. Evaluation Protocol For each task we reserve a fixed held-out test set of NtestN_test examples that is never accessed during the optimization loop for any model. All models are evaluated on two metrics: Mean Absolute Error (MAE) for rating prediction on Agent Society, and Root Mean Square Error (RMSE) for population modeling on Mask Adoption. These metrics are chosen because they are the widely recognised evaluation standards for their respective user simulation tasks Hua et al., 2026, and because both reduce to a single scalar signal that can be used directly to guide optimization without task-specific engineering. Statistical protocol. All comparisons are run for n=10n=10 independent seeds, with every method evaluated on identical seeds so that runs are paired. We report means, standard deviations, and 95% confidence intervals of the paired differences, computed as ί±t0.975,nâ1â sÎ/n ± t_0.975,\,n-1· s_ / n. Significance is assessed with two-sided paired t-tests; within each benchmark we correct for the three pairwise comparisons against SWORD using the HolmâBonferroni procedure at family-wise α=0.05α=0.05. Effect sizes are reported as Cohenâs d on paired differences (d=ÎÂŻ/sÎd= /s_ ). Exact p-values are reported throughout so readers may apply alternative correction schemes (Section C). 5.5. Implementation Details Backbone model. In SWORD, all agent calls use GPT-5.4-mini via the OpenAI API. SOCIA-â Hua et al., 2026 uses the stronger GPT-5 model, meaning SWORD achieves its reported gains despite operating at a disadvantage in backbone capacity. To isolate SWORDâs optimization strategy from backbone capability, all ablation comparisons are run on the identical GPT-5.4-mini backbone under identical conditions ensuring full parity in Table 3. The statistical significance tests reported in Section 6 are therefore fully controlled comparisons. The comparison against SOCIA-â in Table 2 uses a stronger backbone and is reported separately as a cost-efficiency benchmark. The controlled head-to-head comparison of SWORD vs. SOCIA with an identical GPT-5.4-mini backbone is reported in Table 4. The ablation implementation is described in Section E, and results are described in Section 6.3. Hyperparameter choices. The candidate set size K controls how many workflow topologies are maintained and evaluated per iteration, while the elite size E determines how many top-ranked topologies are carried over unchanged. We set K=4K=4 and E=2E=2, choosing K=4K=4 empirically as the minimum population size at which workflow diversity meaningfully improves over a single-workflow baseline while keeping the per-iteration cost tractable. This choice was motivated by an observed failure mode with K=1K=1, in which a poor workflow mutation occasionally degraded performance for the entire iteration because no alternative candidate was available; using K=4K=4 eliminated this instability by ensuring that at least one prior workflow remained available when a mutation degraded performance. We did not evaluate K>4K>4 because each additional candidate requires a full training-set evaluation and therefore increases the per-iteration cost substantially; K=4K=4 keeps the number of evaluation calls within our computational budget. The choice E=2E=2 provides sufficient elitism to distinguish which topologies should be retained or discarded while limiting redundant evaluations. We report these choices as the configuration used throughout the paper rather than as the product of a formal sweep over K and E; the one hyperparameter we do sweep systematically is the iteration budget T, reported as a training-score sensitivity analysis in §6.7. Early stopping is triggered after P=8P=8 consecutive iterations without improvement, a patience value chosen to tolerate the score variance expected from only ntrain=30n_train=30 training examples per task. In the main experiments, we set the maximum number of iterations to T=5T=5 as a costâaccuracy trade-off: the steepest gains are captured within five iterations, whereas increasing the budget to T=10T=10 yields only a marginal improvement of +0.01+0.01 in training score (Table 8) relative to the doubled evaluation cost. Workflow topology size is bounded to [2,8][2,8] agents. The lower bound guarantees a meaningful distinction between entry and exit agents, whereas the upper bound limits prompt-context growth caused by large upstream fan-in. Upstream fan-in is itself limited to max_edges_per_node=4 per node. The LLM sampling temperature is fixed at 1.01.0 for all agent executions and proposer calls. Finally, the random seed is offset for each repeat as 42+rep+rep_offset42+rep+rep\_offset, making each run individually deterministic while decorrelating repeats for variance estimation across n=10n=10 runs. Initialization. The K initial workflow topologies are sampled randomly: each workflow draws a random agent count from [2,8][2,8], assigns roles by sampling from the fixed role vocabulary, and connects agents with random edges subject to the DAG constraints in Sections 4.1 and 4.2. Initial prompts. All agents start with a generic two-sentence prompt of the form: âYou are a [role] agent in a multi-agent workflow. Your task is to process the upstream input and produce a structured output in JSON format [output schema].â No task-specific knowledge is provided at initialization; all domain-specific behavior is discovered through the optimization loop. Refer to Section D.0.5 for full prompts. Computational cost. A full call-count breakdown is provided in Appendix A; in brief, workflow scoring (TĂNtrainĂKĂAÂŻâ5Ă30Ă4Ă5=3,000TĂ N_trainĂ KĂ Aâ 5Ă 30Ă 4Ă 5=3,000 calls), prompt gradient steps (TĂ3ĂEĂAÂŻâ150TĂ 3Ă EĂ Aâ 150 calls), and topology proposals (TĂ(KâE)=10TĂ(K-E)=10 calls) sum to approximately 3,1603,160 LLM calls per run. At GPT-5.4-mini pricing ($0.75/1M input, $4.5/1M output tokens as of mid-2026), the total cost of a full training-and-testing run of SWORD is approximately $4â$6 USD. 6. Results and Analysis Table 2. Main results on Agent Society (MAEâ ) and Mask Adoption (RMSEâ ). Results for prior work are sourced from SOCIA-â Hua et al., 2026. Note: prior-work baselines use GPT-5-class models; SWORD uses GPT-5.4-mini, so this comparison is a cost-efficiency benchmark rather than a controlled accuracy head-to-head. Table 3 provides backbone-controlled ablation comparisons. Best result per column in bold. SWORD results are means over n=10n=10 seeds. Category Method Agent MAEâ Mask RMSEâ Prior work AI Scientist-v2 Yamada et al.,2025 0.89±0.100.89_± 0.10 0.45±0.070.45_± 0.07 YuLan-OneSim Wang et al.,2025a 0.72±0.080.72_± 0.08 0.42±0.040.42_± 0.04 G-SIM-ES Holt et al.,2025 0.60±0.070.60_± 0.07 0.30±0.080.30_± 0.08 G-SIM-SBI Holt et al.,2025 0.69±0.080.69_± 0.08 0.20±0.100.20_± 0.10 Reflexion Shinn et al.,2023 0.57±0.080.57_± 0.08 0.36±0.040.36_± 0.04 LLM-based SOCIA-â (as reported) Hua et al.,2026 0.54±0.060.54_± 0.06 0.22±0.070.22_± 0.07 Ours SWORD 0.257±0.1050.257_± 0.105 0.0217±0.00170.0217_± 0.0017 6.1. Joint Optimization Superiority Table 2 reports primary metrics on both benchmarks across all methods, providing the primary evidence for RQ1 (joint optimization superiority, Contribution 1) and RQ4 (model and data efficiency, Contribution 4). On Mask Adoption, SWORD achieves RMSE =0.0217±0.0017=0.0217± 0.0017, a 90% improvement over SOCIA-â (0.220 ± 0.07). On Agent Society, SWORD achieves MAE =0.257±0.105=0.257± 0.105, a 52% improvement over SOCIA-â (0.540 ± 0.06) and a nominal 15% improvement over the strongest ablation, Prompt-Only (0.301 ± 0.087) (Section 7.2). We emphasize that comparisons against prior work use different backbone models and are therefore cost-efficiency benchmarks. The controlled evidence for SWORDâs design comes from the same-backbone ablations in Table 3. Three patterns are notable. First, SWORD is the only method that ranks first on both benchmarks simultaneously, demonstrating that joint workflowâprompt optimization yields more consistent gains than optimising either component in isolation. Second, on Mask Adoption the standard deviation of SWORD is substantially lower than all baselines. SWORDâs standard deviation across n=10n=10 seeds is 0.00170.0017 versus 0.070.07 for SOCIA-â, roughly a 40Ă reduction. This stability indicates that the joint optimization loop reliably converges to similar solutions regardless of random seed, whereas code-generation baselines are sensitive to stochastic code synthesis. Third, the performance gap between SWORD and Staged Optimization is large on both tasks: on Mask Adoption SWORD achieves RMSE 0.02170.0217 vs. Staged 0.1800.180, an 8.3Ă8.3Ă difference, and on Agent Society MAE 0.2570.257 vs. Staged 0.5100.510, a 2.0Ă2.0Ă difference. The very high variance of Staged Optimization (±0.170± 0.170 RMSE, ±0.274± 0.274 MAE) reflects seed-dependent workflow lock-in: in seeds where Phase 1 selects a suboptimal workflow, Phase 2 prompt updates actively degrade performance (see Section 6.5), producing bimodal outcomes (analyzed further in Section 7.6). 6.2. Relative Contribution of Prompt vs. Workflow Table 3. Ablation study (n=10n=10 seeds, Ntrain=30N_train=30, Ntest=100N_test=100). All methods share the identical GPT-5.4-mini backbone and identical seeds (paired design). We report mean ± std and the 95% confidence interval of the paired difference vs. SWORD (Î , positive means worse than SWORD; undefined for SWORD itself). SWORDâs own 95% CIs of the mean are [0.0206,0.0229][0.0206,0.0229] RMSE and [0.182,0.332][0.182,0.332] MAE (Appendix C). â marks comparisons significant after per-benchmark HolmâBonferroni correction (α=0.05α=0.05). Best per column in bold. Method Mask RMSEâ Î [95% CI] Agent MAEâ Î [95% CI] Workflow-Only (e.g., Zhang et al., 2025e) 0.0686±0.07220.0686_± 0.0722 [â0.004,0.098][-0.004,0.098] 0.456±0.1290.456_± 0.129 [0.061,0.336]â[0.061,0.336]^* Prompt-Only (e.g., Chen et al., 2025c) 0.0232±0.00210.0232_± 0.0021 [0.0002,0.0026]â[0.0002,0.0026]^* 0.301±0.0870.301_± 0.087 [â0.040,0.128][-0.040,0.128] Staged Opt. (e.g., Zhou et al., 2026) 0.1795±0.16980.1795_± 0.1698 [0.036,0.279]â[0.036,0.279]^* 0.510±0.2740.510_± 0.274 [0.079,0.427]â[0.079,0.427]^* SWORD (Ours) 0.0217±0.00170.0217_± 0.0017 â 0.257±0.1050.257_± 0.105 â Table 3 isolates the contribution of each component, directly addressing RQ1: it quantifies how much each design decision contributes to the final performance. Prompt-Only (fixed workflow, optimized prompts) achieves relatively better performance (RMSE 0.02320.0232, MAE 0.3010.301) compared to Workflow-Only (optimized workflow, generic prompts) (RMSE 0.06860.0686, MAE 0.4560.456) by a factor of 1.51.5 to 3.0Ă3.0Ă. These results establish that prompt quality is a primary performance driver. SWORD captures both: by jointly evolving workflow and prompts, it reaches a result unavailable to either component operating alone. 6.3. Comparison with SOCIA Table 2 reports SOCIA-ââs own published numbers Hua et al., 2026. To obtain a backbone-controlled comparison instead, we separately re-executed SOCIA-ââs released implementation: we replaced its configured model with gpt-5.4-mini and evaluated it on the same two tasks and the same held-out data splits used throughout this paper. All numbers in this subsection and Table 4 are from this backbone-matched re-execution. Table 4. SWORD vs. SOCIA-â (our backbone-matched re-execution) on both tasks. SWORD statistics are mean ± std over n=10n=10 independent trials; the re-executed baseline reflects a single successfully executed, non-placeholder run (n=1n=1) due to run-to-run execution instability in its automated code generation. Task Metric SWORD SOCIA-â (reproduced) agent_society MAE â 0.2567±0.10490.2567± 0.1049 0.22750.2275 (n=1n=1) mask_adoption RMSE â 0.0217±0.00170.0217± 0.0017 0.55470.5547 (n=1n=1) Comparison with SOCIA (code-generation baseline). On mask_adoption, SOCIAâs RMSE of 0.5547 is roughly 25Ă higher than SWORDâs 0.0217, with the generated simulator converging to near-total adoption across the prediction window and failing to capture gradual adoption dynamics. This is a clear, unambiguous advantage for SWORD on this task. On agent_society, the comparison is less favorable to SWORD, and we report it plainly rather than understate it: SOCIAâs single successfully-verified run achieves MAE =0.2275=0.2275, numerically better than SWORDâs mean of 0.25670.2567, though inside SWORDâs 95% confidence interval of [0.182,0.332][0.182,0.332] (Table 4), so the two are not straightforwardly distinguishable as a single point estimate against a distribution. We do not read this as evidence that SOCIAâs code-generation approach matches SWORDâs accuracy on this task, for two reasons. First, SOCIA succeeded on only 1 of 8 attempts on agent_society (below), so this MAE is a single draw from a highly unreliable process rather than a representative estimate; the n=1n=1 comparison in Table 4 cannot support a claim about central tendency the way SWORDâs n=10n=10 paired trials can, and we do not attempt a significance test against it. Second, SOCIAâs own evaluator flagged this runâs review-text output as markedly weaker in quality, consistent with coarse rating calibration that matches the numeric target without the qualitative behavioral understanding SWORDâs agents produce (Appendix B). We therefore treat SWORDâs demonstrated advantage on agent_society as a reliability advantage rather than a proven point-estimate accuracy advantage, and we treat the mask_adoption result as the stronger and less ambiguous evidence of SWORDâs advantage in this comparison. SOCIAâs generated programs frequently failed at code verification or runtime on the same data, which is itself the more consistent finding across both tasks (See section E). Limitation: generation reliability appears sensitive to backbone capacity. SOCIAâs execution success rates differed sharply by task. Execution was successful in mask_adoption but only in 1 of 8 attempts on agent_society. Failures on agent_society were diverse (missing attributes, malformed fields, function-signature errors), suggesting backbone-capacity constraints rather than systematic bugs. The pattern is consistent with gpt-5.4-mini handling uniform data schemas (single time-series forecasting) more reliably than heterogeneous schemas (three-platform review/rating pipelines with inconsistent data types). We did not test with a larger backbone to verify this explanation; it is left to future work. 6.4. Variance and Stability Analysis The low cross-seed variance of SWORD (±0.0017± 0.0017 on Mask Adoption) warrants explicit discussion. Code-generation baselines produce variance one to two orders of magnitude larger because their performance is coupled to whether the generated Python simulator compiles and executes correctly, a stochastic event that varies across seeds. SWORD bypasses code generation entirely, so its only source of variance is the LLMâs sampling noise during prompt updates and workflow proposals. In each iteration, the textual gradient step selects the training example with the largest prediction error, i.e., the example the model performs worst on; focusing on this single example provides a strong, clear learning signal. It avoids averaging the gradients from many examples that are already predicted correctly, which can weaken the learning signal and increase the effect of random seed-level noise. This stability is practically significant: a practitioner can obtain reliable behavioral predictions from a single SWORD run without needing multiple seeds for uncertainty estimation. Statistical significance. We report two-sided paired t-tests between SWORD and each ablation across n=10n=10 independent seeds, with per-benchmark HolmâBonferroni correction for the three comparisons against SWORD (Section 5.4). This correction follows established guidance that uncontextualized significance testing without adjustment for multiple comparisons risks inflated false-positive rates in IR and NLP evaluation Ferro and Sanderson, 2024. Per-seed results are listed in Appendix C. On Agent Society, SWORD significantly outperforms Staged Optimization (Î =0.253=0.253, 95% CI [0.079,0.427][0.079,0.427], tâĄ(9)=3.29t(9)=3.29, p=0.0093p=0.0093, d=1.04d=1.04), Workflow-Only (Î =0.199=0.199, 95% CI [0.061,0.336][0.061,0.336], tâĄ(9)=3.27t(9)=3.27, p=0.0096p=0.0096, d=1.04d=1.04), and Prompt-Only (Î =0.044=0.044, 95% CI [â0.040,0.128][-0.040,0.128], tâĄ(9)=1.18t(9)=1.18, p=0.268p=0.268, d=0.37d=0.37) at n=10n=10. On Mask Adoption, SWORD significantly outperforms Staged Optimization (Î =0.158=0.158, 95% CI [0.036,0.279][0.036,0.279], tâĄ(9)=2.94t(9)=2.94, p=0.0165p=0.0165, d=0.93d=0.93) and Prompt-Only (Î =0.0014=0.0014, 95% CI [0.0002,0.0026][0.0002,0.0026], tâĄ(9)=2.73t(9)=2.73, p=0.0233p=0.0233, d=0.86d=0.86); both survive Holm correction. The comparison with Workflow-Only shows a medium-to-large effect (Î =0.047=0.047, 95% CI [â0.004,0.098][-0.004,0.098], tâĄ(9)=2.08t(9)=2.08, p=0.067p=0.067, d=0.66d=0.66) (Appendix C). 6.5. Workflow Rank Inversion and Task-Aware Discovery RQ2 asks whether workflowâprompt coupling non-stationarity occurs in practice, and whether the same optimization framework discovers task-appropriate structure without explicit task-specification. We document rank inversions: iterations where the best-performing topology changes (e.g., Topology 0 at iteration T becomes suboptimal at T+1T+1, replaced by Topology 1). Rank inversions occur because improving prompts alter which workflow structure best leverages the new feedback signals, demonstrating that topology rankings are non-stationary. Table 5 documents rank inversions across all 10 seeds: workflow topology changes during joint optimization that correlate with performance gains. The patterns reveal sharply divergent discovery processes across tasks, providing direct evidence for task-aware workflow discovery and rank inversion. The patterns differ across tasks. Agent Society exhibits substantial structural diversity across seeds, with changes in both agent composition and execution order. Mask Adoption shows greater similarity in the agent sets used by the final workflows, although the execution order and agent composition still vary across seeds. Thus, the optimization process does not converge to a single universal workflow structure; instead, the discovered structures depend on the task and optimization trajectory. Convergent vs. heterogeneous discovery. The two tasks exhibit different degrees of structural consistency. Mask Adoption more frequently converges toward workflows containing a similar core set of agents, although the ordering of these agents varies across seeds. In contrast, Agent Society exhibits greater variation in both workflow composition and ordering. These results suggest that the optimization landscape may differ across tasks, with Mask Adoption exhibiting stronger structural consistency and Agent Society permitting a broader range of effective configurations. However, the table alone does not establish the existence of a single attractor or multiple comparable optima. Reorganization, not simply size, drives improvement. Performance improvements are not consistently associated with increasing or decreasing the number of agents. Across the observed transitions, improvements occur when agents are added, removed, or retained while their execution order changes. This indicates that agent count alone is insufficient to explain performance changes. Instead, the results point to the importance of workflow composition and, particularly, agent sequencing. The order in which reasoning, generation, critique, validation, and synthesis occur determines how feedback is propagated through the workflow and can therefore affect task performance (see Table 5). Task-aware discovery without task specification. The differing structural patterns across the two tasks provide evidence that SWORD can discover task-dependent workflow structures from optimization feedback without being given explicit task-specific structural rules. Mask Adoption tends toward greater consistency in workflow composition, whereas Agent Society exhibits more heterogeneous structures. Importantly, these differences emerge from the same optimization framework rather than from manually specified task constraints. Thus, the results support task-aware structural discovery through feedback-driven optimization. Seed Task Iter Pre Workflow Post Workflow Improvement 1 Agent Society T0âT1 pâaâsâcâg pâaâgâtâe +17.3% 1 Mask Adoption T1âT2 aâpâgâcâvâs aâpâgâvâs +11.9% 2 Agent Society T2âT3 aâpâgâtâcâvâs aâpâgâtâvâs +12.7% 2 Mask Adoption T0âT1 sâaâgâtâe aâpâgâcâvâs +1.2% 3 Agent Society T2âT3 aâgâs aâpâgâvâs +1.9% 3 Mask Adoption T2âT3 aâpâgâcâvâs aâpâgâcâtâvâs +7.8% 4 Agent Society T2âT3 aâgâs aâpâgâvâs +1.9% 4 Mask Adoption T2âT3 aâcâgâs aâpâgâcâtâvâs +7.8% 5 Agent Society T0âT1 pâe pâeâv +6.5% 5 Mask Adoption T0âT1 pâeâsâg aâpâtâvâs +18.5% 6 Agent Society T0âT1 pâeâc pâe +6.5% 6 Mask Adoption T2âT4 aâtâs pâaâtâvâcâs +2.2% 7 Agent Society T3âT4 aâpâeâtâs aâgâtâeâs +9.2% 7 Mask Adoption T2âT4 aâpâeâtâs pâaâtâvâcâs +2.2% 8 Agent Society T0âT1 pâtâe pâe +6.5% 8 Mask Adoption T3âT4 aâpâgâcâvâtâs aâpâtâgâcâvâs +0.9% 9 Agent Society T1âT2 pâe pâtâe +0.9% 9 Mask Adoption T2âT4 aâpâeâg pâaâtâvâcâs +2.2% 10 Agent Society T0âT1 aâpâe aâpâeâvâcâs +6.5% 10 Mask Adoption T2âT4 pâaâtâcâs pâaâtâvâeâs +2.2% Table 5. Rank Inversion Analysis: All 10 seeds (n=10n=10) showing workflow transitions that drive performance improvements. Notation: abbreviated agent names (a=analyzer, p=planner, g=generator, c=critic, v=validator, s=synthesizer, e=executor, t=transformer) connected by â showing execution order. Improvements are percentage gains in task score (Agent Society: MAE reduction; Mask Adoption: RMSE reduction). 6.6. Workflow-Conditioned Gradient Mechanism RQ3 asks whether metric-conditioned textual gradients autonomously discover task-relevant user preference signals. The workflow-conditioning of gradient signals shapes prompt updates qualitatively differently for the same named agent role across structurally different contexts. The content of those gradients reveals what domain knowledge the system has independently recovered from the scalar metric signal alone, with no task-specific initialization. Gradient content across the optimization trajectory. Figure 2 confirms the two-phase dynamic predicted in Section 7.3: role-reframing gradients dominate in iterations 0â1 (34% of calls) and nearly vanish by iteration 4 (<<5%), replaced by calibration and signal-prioritization gradients. For Agent Society, 72% of gradients across all iterations are sentiment-related, autonomously discovering that review text sentiment is the primary feature for rating prediction without any task-specific initialization. Figure 2. Textual gradient content taxonomy across optimization iterations. Left: Mask Adoption. Role-reframing gradients dominate early and fade as workflow grows more complex, confirming the coarse-to-fine dynamic. Right: Agent Society. 72% of gradients are sentiment-related, autonomously discovered from MAE signals without task-specific initialization.Heat map showing gradient direction category distributions across iterations for both tasks. Cross-task autonomous knowledge discovery. The gradient content is task-specific in a semantically meaningful sense. On Mask Adoption, the dominant directions encode epidemiological dynamics (intervention decay, peer influence, historical trend extrapolation, zero-history fallback priors), knowledge captured in the prompts entirely through RMSE loss signals over 30 training examples. On Agent Society, the gradient mechanism discovers that review text sentiment is the primary feature for rating prediction, producing increasingly precise sentiment-to-score mapping rules (Appendix A). This unsupervised domain knowledge extraction from metric-conditioned textual gradients is a distinct capability of the SWORD framework. Qualitative prompt evolution. Table 6 traces the Generator prompt across four iterations on Mask Adoption. The prompt evolves from a generic âcombine signalsâ instruction to a domain-calibrated policy encoding the causal structure of epidemic mask adoption. Key epidemiologically-meaningful rules emerge: exponential intervention decay, zero-history fallback priors, intervention timing (effects near-zero before day 10), and the distinction between weak signals (network degree, flagged as low-confidence) and strong signals (historical trend, intervention decay). All of this is discovered purely from the RMSE loss signal over 30 training examples, with no domain-expert input. To verify that the discovered rules are epidemiologically correct and not artifacts of overfitting to the 30 training examples, we cross-reference each emergent rule against the SOCIA paper Hua et al., 2026. All five rules SWORD discovered from RMSE signals alone are consistent with peer-reviewed epidemiological findings, providing external validation that the gradient mechanism recovers scientifically meaningful structure rather than spurious correlations. Table 6. Generator prompt evolution across iterations on Mask Adoption. Epidemiological domain knowledge (decay, prior, timing) emerges from RMSE signals alone. Iter Prompt excerpt 0 âYou are a generator agent. Combine all upstream signals into ONE final prediction.â 1 âPriority: (1) historical_rates + recent_trend, (2) intervention status + decay, (3) population priors. Do not omit peer influence or habit dynamics.â 2 âPriority: (1) historical_rates + recent_trend, (2) intervention status + decay, (3) population priors. Do not omit peer influence or habit dynamics.â 3 âIf historical_rates empty, apply low-baseline prior (0.08â0.10). In zero-history/no-intervention cases, do not infer high adoption. Intervention effects near-zero before day 10.â 4 âDecision hierarchy: 1) historical/recent trend 2) intervention (exponential decay from start) 3) conservative baseline 4) small population adjustments 5) calibrated params as weak diagnostics only. Clamp to [0, 1].â 6.7. Convergence and Cost Efficiency The following analysis provides evidence for RQ4: whether joint co-optimization captures principal gains within the first few iterations, bounding the cost of a full SWORD run. 6.7.1. Multi-seed convergence (n=10n=10, primary evidence). Table 7 reports best-so-far scores across n=10n=10 seeds (mean ± std) for T=1T=1 through T=5T=5, providing the primary convergence evidence. Low cross-seed variance (e.g., ±0.0167± 0.0167 Mask Adoption at T=5T=5; ±0.0097± 0.0097 Agent Society at T=5T=5) confirms convergence is robust and not seed-dependent. Agent Society saturates by T=2T=2 across all seeds; Mask Adoption continues gradual improvement through T=5T=5, consistent with task complexity differences. These multi-seed trajectories establish that SWORDâs rapid saturation is a general property, not an artifact of a single favorable seed. Table 7. Best-so-far score across n=10n=10 seeds (mean ± std per iteration). Low variance confirms robust, seed-independent convergence by T=5T=5. Task T=1T=1 T=2T=2 T=3T=3 T=4T=4 T=5T=5 Mask Adoption 0.8037±0.00950.8037± 0.0095 0.8127±0.01080.8127± 0.0108 0.8217±0.01210.8217± 0.0121 0.8380±0.01450.8380± 0.0145 0.8450±0.01670.8450± 0.0167 Agent Society 0.8950±0.00890.8950± 0.0089 0.8952±0.00910.8952± 0.0091 0.8955±0.00930.8955± 0.0093 0.8958±0.00950.8958± 0.0095 0.8960±0.00970.8960± 0.0097 6.7.2. Extended-horizon trajectory (single seed, supplementary). To assess saturation beyond T=5T=5, Table 8 extends to Tâ1,2,3,5,7,10Tâ\1,2,3,5,7,10\ using a single seed (multi-seed runs are costly beyond T=5T=5). On Mask Adoption, improvement decelerates after T=5T=5 (0.8450 to 0.8565 by T=10T=10). On Agent Society, performance plateaus by T=2T=2 (0.8950 to 0.8967 by T=10T=10). This single-seed extension is consistent with the multi-seed saturation pattern, confirming that principal gains are captured early. Table 8. Extended convergence trajectory (single seed). Shows saturation persists beyond T=5T=5. Task T=1T=1 T=2T=2 T=3T=3 T=5T=5 T=7T=7 T=10T=10 Mask Adoption 0.8037 0.8127 0.8217 0.8450 0.8533 0.8565 Agent Society 0.8950 0.8952 0.8955 0.8960 0.8967 0.8967 6.7.3. Cost efficiency and implications. SWORD Pareto-dominates SOCIA-â on cost-performance: using GPT-5.4-mini (vs. GPT-5-class), SWORD achieves 90% RMSE reduction on Mask Adoption and 52% MAE reduction on Agent Society at a fraction of the estimated API cost. Since multi-seed convergence demonstrates saturation by T=5T=5, SWORD recovers nearly all obtainable gains from the first few workflowâprompt co-adaptation steps, bounding computational cost without sacrificing quality. 7. Discussion 7.1. Why Joint Optimization Escapes the Staged Failure Mode When the workflow changes, the inputs received by each agent also change. For example, a Planner upstream can provide structured information that a raw Analyzer would not receive. Because the textual gradient critiques an agentâs output conditional on its input, the prompt gradient is therefore dependent on the workflow context. Formally, for agent v, the gradient âÏvâ _ _vL depends on the workflow Ξ; when workflows Ξa _a and Ξb _b differ upstream of v, their corresponding gradient directions can differ. This creates a failure mode for staged optimization. If prompts are optimized under workflow Ξa _a and the subsequent workflow search selects Ξb _b, the learned prompts were optimized for Ξa _aâs information flow rather than Ξb _bâs. Consequently, a workflow that is suboptimal under the initial prompts may become preferable after prompt refinement. Our results show workflow transitions accompanied by performance improvements across all experimental seeds (Section 6.5), consistent with this workflowâprompt coupling non-stationarity. Three mechanisms explain the RMSE gap between SWORD and Staged Optimization on Mask Adoption (0.0217 vs. 0.1795, a difference of 0.158; Table 3). (i) Structural adaptation during prompt optimization. SWORD evaluates all K=4K=4 candidate workflows at every iteration while jointly updating prompts. As the preferred workflow changes across iterations (Table 5), subsequent prompt updates are therefore conditioned on the new structural context. In contrast, Staged Optimization performs Phase 2 prompt optimization under a single workflow selected before prompt refinement. (i) Improved prompts during workflow search. Because prompts are updated at the end of each iteration, workflows proposed in iteration t+1t+1 are evaluated using the refined prompts from iteration t. This allows increasingly specialized workflows to be evaluated with increasingly specialized prompts, rather than requiring complex workflows to perform well under generic initial prompts. (i) Coupled improvement of structure and prompts. Workflow refinement and prompt refinement can reinforce one another. A more structured workflow can create more specialized agent roles, making prompt refinement more targeted. In turn, improved prompts produce better intermediate outputs, allowing subsequent workflow evaluations to more accurately identify useful structural changes. This feedback loop is unavailable when workflow and prompt optimization are performed sequentially. Thus, the ablation gap is not simply a difference in optimization quality; it reflects the interaction between workflow structure and prompt quality. The fitness landscape over workflows can change as prompts improve, making a workflow selected early in optimization potentially different from the workflow preferred after prompt refinement. Joint optimization allows both components to adapt to one another, whereas staged optimization fixes one component while optimizing the other. This distinction is relevant to methods such as DSPy Khattab et al., 2024, TextGrad Yuksekgonul et al., 2025, and MIPRO Opsahl-Ong et al., 2024: prompts optimized for a fixed architecture need not remain optimal when the architecture itself is allowed to change. 7.2. When Prompt Optimization Alone Is Competitive The Agent Society results reveal a complementary insight: when workflow search has little headroom beyond a well-optimized fixed structure, prompt optimization alone can be nearly as good as full joint optimization. On Agent Society, SWORDâs advantage over Prompt-Only (fixed workflow, optimized prompts) is small and does not survive multiple-comparison correction (Î =0.044=0.044, 95% CI [â0.040,0.128][-0.040,0.128], p=0.268p=0.268; Table 3, §6.1), even though SWORDâs advantage over Staged Optimization on the same task is large and statistically significant (Î =0.253=0.253, p=0.0093p=0.0093). This asymmetry indicates that on Agent Society, most of SWORDâs benefit over naive baselines comes from prompt optimization itself and from avoiding the workflow-lock failure mode that harms Staged Optimization (§7.1), rather than from workflow search discovering structures a well-tuned fixed workflow could not already reach. Consistent with this, the workflows discovered on Agent Society vary considerably across seeds (2â6 agents, §6.5) without a single structural pattern that is clearly superior, unlike the convergent topology SWORD finds on Mask Adoption. This is consistent with broader recent observations that well-tuned, simpler agent configurations can rival more elaborate multi-agent workflow structures in some settings Xu et al., 2026, reinforcing that workflow complexity should be justified empirically rather than assumed. Practitioners should prefer full joint optimization when: (a) the task involves complex behavioral dynamics with many interacting signals, as in Mask Adoption, where SWORDâs advantage over every ablation is large and significant, (b) the optimal agent composition is unknown, or (c) rapid cross-task transfer is needed without hand-redesigning the workflow. Prompt-only optimization remains a reasonable, lower-cost alternative when early experimentation suggests a fixed workflow already performs well across prompt regimes, though it forfeits SWORDâs markedly lower run-to-run variance (§6.4) and its ability to discover better structures automatically if task requirements later shift. Staged optimization and Workflow-only ablations, by contrast, are dominated by both alternatives on the evidence in Table 3 and is not a recommended baseline on either task. 7.3. Mechanistic Basis: Workflow Rank Inversion Rank inversion arises from three coupled mechanisms that the SWORD framework is designed to exploit rather than avoid. (1) Role specialization. In a 2-agent workflow, agent v must simultaneously extract features and produce the final behavioral prediction. In a 5-agent workflow, v need only extract features, delegating prediction to a downstream Synthesizer. The optimal prompt for these two roles is qualitatively different, corresponding to high structural divergence ÎâĄ(Ξa,Ξb,v) ( _a, _b,v). (2) Upstream context shift. When the workflow changes, the inputs arriving at v change: a Planner upstream may have already structured the raw user context, narrowing variance in vâs input distribution and enabling more targeted calibration. This reduces the entropy of vâs input under the new workflow, shrinking gradient misalignment once the new structure is adopted, consistent with the calibration-dominated gradients we observed in Section 6.5 and Appendix A. (3) Gradient direction shift. The textual gradient critiques agent output given its observed inputs. Both changes above produce structurally different gradients: âreframe from feature extraction to direct predictionâ (2-agent context) vs. âcalibrate forecasting precision within your extraction roleâ (5-agent context) point in incompatible directions in prompt space. These mechanisms collectively predict an observable trajectory: gradient content should shift from role-reframing (early iterations, when the workflow is simple) to calibration (later iterations, when roles are specialized and the workflow is stable). 7.4. Implications for Information Systems User Simulation Research SWORD enables researchers to obtain accurate behavioral predictions from an agent-based system without specifying any domain rules in advance. Prior work in information systems/information retrieval user simulationâfrom classical click models Dupret and Piwowarski, 2008 to agenda-based simulators Balog and Kenter, 2023 to code-generation approaches Hua et al., 2026 requires researchers to either hand-code behavioral rules, calibrate probabilistic interaction models, or validate generated code against domain knowledge. SWORD requires only a task metric (RMSE or MAE) and some labeled training examples. The epidemiological rules SWORD discovered for Mask Adoption without domain expert inputâintervention timing thresholds, exponential efficacy decay, zero-history priors, peer influence weightingâare consistent with the ABM model Mortveit et al., 2022, reached from 30 training examples and an RMSE loss signal alone. For Agent Society, SWORD discovered that review text sentiment is the primary rating signal with zero task-specific initialization. These findings have direct practical implications. User simulation researchers studying conversational recommenders Balog and Kenter, 2023; Zhang and Balog, 2020, preference elicitation, and behavioral adoption no longer need to pre-specify agent logic or validate generated code. SWORD provides a general-purpose optimizer that adapts its simulation strategy to any evaluation metric. 7.5. Implications for Joint Optimization Research SWORDâs gradient mechanism contributes two insights to prompt optimization for multi-agent information systems. First, workflow-conditioning is a principled extension of textual gradients: the same role can receive qualitatively different and incompatible gradient signals depending on its structural context. Second, the autonomous discovery of domain knowledge through metric-conditioned gradients suggests that textual gradients are a viable mechanism for unsupervised feature-importance learning when the evaluation metric is well-defined. Practitioners building multi-agent systems for information systems or information retrieval tasks with DSPy or MIPRO should treat workflow as a co-optimization variable rather than a design decision made before optimization begins. 7.6. Failure Case Analysis for SWORD Analysis of failure cases reveals two systematic patterns in SWORDâs errors. Seed-specific prompt bias. In the Agent Society task, a subset of seeds shows consistent underestimation on clearly positive reviews: seeds 1 and 10 both underpredict unambiguously positive (5-star) ratings, indicating that certain learned prompt formulations can introduce a systematic bias rather than random noiseZhang et al., 2025h. This pattern is reproducible across all three review platforms (Amazon, Goodreads, and Yelp), suggesting the bias originates in the learned sentiment-to-score calibration rather than in platform-specific data characteristics. Trend extrapolation versus single-day anomalies. On Mask Adoption, day 33 exhibits a dip that breaks the otherwise increasing trend across the test horizon, and SWORD consistently mispredicts this point. Because its agents predict from recent history and trend signals, any topology extrapolating from the days 30â32 plateau (â0.59â 0.59) converges to a prediction near that plateau regardless of prompt content, workflow structure, or random seedZhou and Yu, 2025. This is a structural limitation of trend-following prediction rather than a failure specific to any one optimized configuration. 7.7. Limitations and Future Directions Two key challenges emerge from our failure case analysis that point toward future research: Prompt robustness across agent configurations. While SWORD successfully optimizes prompts for most seeds, certain configurations exhibit systematic bias like underestimation on high-confidence positive sentiment across multiple review sources. This suggests that prompt optimization landscapes may contain local regions where gradient-based refinement fails to escape low-sensitivity zones. Future work should investigate adaptive prompt initialization strategies and multi-start optimization to improve convergence robustness across diverse seed configurations. Temporal prediction under anomalous ground-truth signals. SWORDâs performance on transient anomalies like single-day deviations from established trends reveals a challenge in agent-based simulation. Since trend-following agents naturally extrapolate from historical plateaus, improving this requires either better ground-truth curation or agent designs that incorporate uncertainty quantification. Integrating confidence intervals and anomaly detection into agent reasoning would advance both SWORD and broader user behavior modeling methodology. Both limitations highlight open questions in agent optimization that extend beyond this work and warrant investigation by the community. 8. Conclusion We have presented SWORD, a framework for jointly optimizing multi-agent workflows and prompts for user behavior simulation in information systems. By interleaving workflow evolution with prompt optimization in a single closed loop, SWORD escapes the fundamental suboptimality of staged approaches caused by workflowâprompt coupling non-stationarity. We validate this empirically in experimental seeds (Table 5), and find staged prompt update steps degrade performance relative to joint optimization by a large, statistically significant margin on both benchmarks (Table 3, §6.1). In backbone-controlled ablations against prompt-only, workflow-only, and staged baselines under an identical GPT-5.4-mini backbone, SWORD significantly outperforms in controlled comparisons (§6.1â§6.2). Against the strongest published domain-specific baseline, SOCIA-â, SWORD achieves a 52% MAE reduction and a 90% RMSE reduction while using a smaller backbone model and a fraction of the API cost (Table 2); because that comparison spans different backbone models, we report it as a cost-efficiency result rather than a controlled accuracy comparison. The autonomous discovery of epidemiological decay rules and sentiment-to-score mappings from 30 training examples and a scalar metric signal alone demonstrates that workflow-conditioned textual gradients are a viable mechanism for unsupervised feature-importance learning in multi-agent user simulation. These results establish SWORD as a transferable, domain-knowledge-free framework for agent-based user simulation in information systems. Future work will extend SWORD to conversational recommender system evaluation Zhang and Balog, 2020; Balog and Kenter, 2023; Zhu et al., 2025a, preference elicitation tasks, and broader social simulation domains. Acknowledgements. The authors thank Monash University for infrastructure support and the SOCIA research group for releasing their benchmark datasets and code. References Balog and Kenter (2023) K. Balog and T. Kenter UserSimCRS: a user simulation toolkit for evaluating conversational recommender systems. In Proceedings of the Sixteenth ACM International Conference on Web Search and Data Mining, p. 1160â1163. External Links: Document Cited by: §2.1, §7.4, §7.4, §8. Balog and Zhai (2024) K. Balog and C. Zhai User simulation for evaluating information access systems. Foundations and Trends in Information Retrieval 18 (1-2), p. 1â261. External Links: Document Cited by: §1, §2.1. Cai et al. (2025) S. Cai, J. Zhang, K. Bao, C. Gao, Q. Wang, F. Feng, and X. He Agentic feedback loop modeling improves recommendation and user simulation. In Proceedings of the 48th International ACM SIGIR conference on Research and Development in Information Retrieval, p. 2235â2244. Cited by: §1. Chen et al. (2025a) B. Chen, Z. Zhang, N. LangrenĂ©, and S. Zhu Unleashing the potential of prompt engineering for large language models. Patterns 6 (6). Cited by: §2.2. Chen et al. (2025b) M. Chen, R. Jin, W. Deng, Y. Chen, Z. Huang, H. Yu, and X. Li Can textual gradient work in federated learning?. In The Thirteenth International Conference on Learning Representations (ICLR), Cited by: §2.2. Chen and He (2025) R. Chen and C. He Fostering collective intelligence in cpss: an llm-driven multi-agent cooperative tuning framework. Frontiers in Physics 13, p. 1613499. Cited by: §1. Chen et al. (2024) W. Chen, Y. Su, J. Zuo, C. Yang, C. Yuan, C. Chan, H. Yu, Y. Lu, Y. Hung, C. Qian, Y. Qin, X. Cong, R. Xie, Z. Liu, M. Sun, and J. Zhou AgentVerse: facilitating multi-agent collaboration and exploring emergent behaviors. In The Twelfth International Conference on Learning Representations (ICLR), External Links: Link Cited by: §4.1. Chen et al. (2025c) W. Chen, S. Koenig, and B. Dilkina RePrompt: planning by automatic prompt engineering for large language models agents. arXiv:2406.11132. Cited by: §5.3, Table 3. Cui et al. (2025) A. Cui, P. Nandyalam, A. Rufail, E. Cheung, A. Lei, K. Zhu, and S. OâBrien Momentum-aided natural language gradient descent for prompt optimization. arXiv:2410.19499. Cited by: §2.2. Davari et al. (2025) M. Davari, U. Garg, W. Cai, and E. Belilovsky Rethinking prompt optimization: reinforcement, diversification, and migration in blackbox llms. arXiv:2507.09839. Cited by: §2.2. De Kai et al. (2020) De Kai, G. Goldstein, A. Morgunov, V. Nangalia, and A. Rotkirch Universal masking is urgent in the covid-19 pandemic: seir and agent based models, empirical validation, policy recommendations. arXiv:2004.13553. Cited by: §A.1, §1, §5.2. Deng et al. (2024) Z. Deng, Y. Zhu, Z. Dou, and J. Wen From novice to expert: llm agent policy optimization via step-wise reinforcement learning. arXiv:2411.03817. Cited by: §A.1. Dupret and Piwowarski (2008) G. E. Dupret and B. Piwowarski A user browsing model to predict search engine click data from past observations. In Proceedings of the 31st Annual International ACM SIGIR Conference on Research and Development in Information Retrieval, p. 331â338. External Links: Document Cited by: §1, §2.1, §7.4. Fernando et al. (2024) C. Fernando, D. Banarse, H. Michalewski, S. Osindero, and T. RocktĂ€schel Promptbreeder: self-referential self-improvement via prompt evolution. In Proceedings of the 41st International Conference on Machine Learning (ICML), Cited by: §4.4. Ferro and Sanderson (2024) N. Ferro and M. Sanderson Uncontextualized significance considered dangerous. In Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval, SIGIR â24, p. 261â270. External Links: Document Cited by: §6.4. Gao et al. (2024) C. Gao, X. Lan, N. Li, Y. Yuan, J. Ding, Z. Zhou, F. Xu, and Y. Li Large language models empowered agent-based modeling and simulation: a survey and perspectives. Humanities and Social Sciences Communications. Cited by: §1, §2.1. Guo et al. (2024a) Q. Guo, R. Wang, J. Guo, B. Li, K. Song, X. Tan, G. Liu, J. Bian, and Y. Yang Connecting large language models with evolutionary algorithms yields powerful prompt optimizers. In The Twelfth International Conference on Learning Representations (ICLR), Cited by: §4.4. Guo et al. (2024b) T. Guo, X. Chen, Y. Wang, R. Chang, S. Pei, N. V. Chawla, O. Wiest, and X. Zhang Large language model based multi-agents: a survey of progress and challenges. In Proceedings of the 33rd International Joint Conference on Artificial Intelligence, p. 8048â8057. External Links: Document Cited by: §2.1. He et al. (2025) T. He, L. Liao, M. Liu, and B. Qin Simulating before planning: constructing intrinsic user world model for user-tailored dialogue policy planning. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval, p. 645â655. Cited by: §1. Holt et al. (2025) S. Holt, M. Ruiz Luyten, A. Berthon, and M. van der Schaar G-Sim: generative simulations with large language models and gradient-free calibration. In Proceedings of the 42nd International Conference on Machine Learning, Proceedings of Machine Learning Research, Vol. 267, p. 23513â23561. External Links: Link Cited by: §5.3, Table 2, Table 2. Hong et al. (2024) S. Hong, M. Zhuge, J. Chen, X. Zheng, Y. Cheng, J. Wang, C. Zhang, Z. Wang, S. K. S. Yau, Z. Lin, L. Zhou, C. Ran, L. Xiao, C. Wu, and J. Schmidhuber MetaGPT: meta programming for a multi-agent collaborative framework. In The Twelfth International Conference on Learning Representations (ICLR), External Links: Link Cited by: §4.1. Hong et al. (2026) Z. Hong, Q. Zhang, J. Sun, Z. Shang, M. Kong, X. Wang, Y. Shu, and Z. Dai MASPOB: bandit-based prompt optimization for multi-agent systems with graph neural networks. arXiv:2603.02630. Cited by: §2.2. Hu et al. (2025a) S. Hu, C. Lu, and J. Clune Automated design of agentic systems. In The Thirteenth International Conference on Learning Representations (ICLR), Cited by: §4.4. Hu et al. (2025b) Y. Hu, J. Liu, K. Wang, J. Zheng, W. Shi, M. Zhang, Q. Dou, R. Liu, A. Zhou, and H. Li LM-Searcher: cross-domain neural architecture search with LLMs via unified numerical encoding. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing (EMNLP), Cited by: §4.4. Hua et al. (2026) Y. Hua, S. Weatherhead, M. Jafari, H. Xue, and F. D. Salim SOCIA-â: textual gradient meets multi-agent orchestration for automated simulator generation. In AAMAS, Cited by: §1, §2.1, §5.2, §5.3, §5.4, §5.5, §6.3, §6.6, Table 2, Table 2, §7.4. Kang et al. (2023) W. Kang, J. Ni, N. Mehta, M. Sathiamoorthy, L. Hong, E. Chi, and D. Z. Cheng Do llms understand user preferences? evaluating llms on user rating prediction. arXiv:2305.06474. Cited by: §A.2, §5.2. Khattab et al. (2024) O. Khattab, A. Singhvi, P. Maheshwari, Z. Zhang, K. Santhanam, S. Vardhamanan, S. Haq, A. Sharma, T. T. Joshi, H. Moazam, H. Miller, M. Zaharia, and C. Potts DSPy: compiling declarative language model calls into self-improving pipelines. In ICLR, Cited by: §A.1, §4.3, §7.1. Kim et al. (2024) S. Kim, H. Kang, S. Choi, D. Kim, M. Yang, and C. Park Large language models meet collaborative filtering: an efficient all-round LLM-based recommender system. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, p. 1395â1406. External Links: Document Cited by: §A.2, §2.1. Li et al. (2024) Z. Li, S. Xu, K. Mei, W. Hua, B. Rama, O. Raheja, H. Wang, H. Zhu, and Y. Zhang AutoFlow: automated workflow generation for large language model agents. arXiv:2407.12821. Cited by: §2.2. Liu et al. (2024a) F. Liu, X. Tong, M. Yuan, X. Lin, F. Luo, Z. Wang, Z. Lu, and Q. Zhang Evolution of heuristics: towards efficient automatic algorithm design using large language model. In Proceedings of the 41st International Conference on Machine Learning (ICML), Cited by: §4.4. Liu et al. (2025) S. Liu, J. Fang, H. Zhou, Y. Wang, and Z. Meng SEW: self-evolving agentic workflows for automated code generation. arXiv:2505.18646. Cited by: §2.2. Liu et al. (2024b) Z. Liu, H. Zhang, K. Dong, and Y. Fang Collaborative cross-modal fusion with large language model for recommendation. In Proceedings of the 33rd ACM International Conference on Information and Knowledge Management, p. 1565â1574. Cited by: §A.2. Luo et al. (2025) J. Luo, L. Song, and R. Sun EvolutionAgent: a large model-based framework for user behavior modeling and self-evolving intelligent agents. In Companion Proceedings of the ACM Web Conference, Cited by: §2.1. Luo et al. (2024) S. Luo, J. Wang, A. Zhou, L. Ma, and L. Song Large language models augmented rating prediction in recommender system. In ICASSP, Cited by: §A.2, §2.1. Ma et al. (2025) C. Ma, Z. Xu, Y. Ren, D. Hettiachchi, and J. Chan PUB: an llm-enhanced personality-driven user behaviour simulator for recommender system evaluation. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval, p. 2690â2694. Cited by: §1. Maxwell and Azzopardi (2016) D. Maxwell and L. Azzopardi Simulating interactive information retrieval: SimIIR: a framework for the simulation of interaction. In Proceedings of the 39th International ACM SIGIR Conference on Research and Development in Information Retrieval, p. 1141â1144. External Links: Document Cited by: §1, §2.1. Mortveit et al. (2022) H. S. Mortveit, S. Adams, F. Dadgostari, S. Swarup, and P. Beling BESSIE: a behavior and epidemic simulator for use with synthetic populations. arXiv:2203.11414. Cited by: §1, §5.2, §7.4. Opsahl-Ong et al. (2024) K. Opsahl-Ong, M. J. Ryan, J. Purtell, D. Broman, C. Potts, M. Zaharia, and O. Khattab Optimizing instructions and demonstrations for multi-stage language model programs. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, p. 4484â4500. Cited by: §4.3, §7.1. Park (2025) C. Park LLM as user simulator: towards training news recommender without real user interactions. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval, p. 3080â3084. Cited by: §1. Park et al. (2023) J. S. Park, J. OâBrien, C. J. Cai, M. R. Morris, P. Liang, and M. S. Bernstein Generative agents: interactive simulacra of human behavior. In Proceedings of the 36th Annual ACM Symposium on User Interface Software and Technology, External Links: Document Cited by: §1, §2.1. Piao et al. (2025) J. Piao, Y. Yan, J. Zhang, N. Li, J. Yan, X. Lan, Z. Lu, Z. Zheng, J. Y. Wang, D. Zhou, et al. AgentSociety: large-scale simulation of llm-driven generative agents advances understanding of human behaviors and society. arXiv:2502.08691. Cited by: §2.1, §5.2. Pryzant et al. (2023) R. Pryzant, D. Iter, J. Li, Y. T. Lee, C. Zhu, and M. Zeng Automatic prompt optimization with gradient descent and beam search. In EMNLP, Cited by: §2.2. Qian et al. (2025) C. Qian, Z. Xie, Y. Wang, W. Liu, K. Zhu, H. Xia, Y. Dang, Z. Du, W. Chen, C. Yang, Z. Liu, and M. Sun Scaling large language model-based multi-agent collaboration. In The Thirteenth International Conference on Learning Representations (ICLR), External Links: Link Cited by: §2.2. Shang et al. (2025) Y. Shang, Y. Li, K. Zhao, L. Ma, J. Liu, F. Xu, and Y. Li AgentSquare: automatic LLM agent search in modular design space. In The Thirteenth International Conference on Learning Representations (ICLR), External Links: Link Cited by: §4.4. Shinn et al. (2023) N. Shinn, F. Cassano, A. Gopinath, K. Narasimhan, and S. Yao Reflexion: language agents with verbal reinforcement learning. In Advances in Neural Information Processing Systems, Vol. 36, p. 8634â8652. Cited by: §5.3, Table 2. Sun et al. (2024) Z. Sun, Z. Si, X. Zang, K. Zheng, Y. Song, X. Zhang, and J. Xu Large language models enhanced collaborative filtering. In Proceedings of the 33rd ACM International Conference on Information and Knowledge Management, p. 2178â2188. External Links: Document Cited by: §A.2, §2.1. Taillandier et al. (2025) P. Taillandier, J. D. Zucker, A. Grignard, B. Gaudou, N. Q. Huynh, and A. Drogoul Integrating llm in agent-based social simulation: opportunities and challenges. arXiv preprint arXiv:2507.19364. Cited by: §2.1. Tang et al. (2024) X. Tang, X. Wang, W. X. Zhao, S. Lu, Y. Li, and J. Wen Unleashing the potential of large language models as prompt optimizers. AAAI 2025. Cited by: §2.2. Wang et al. (2025a) L. Wang, H. Gao, X. Bo, X. Chen, and J. Wen Yulan-onesim: towards the next generation of social simulator with large language models. In Workshop on Scaling Environments for Agents, Cited by: §5.3, Table 2. Wang et al. (2025b) L. Wang, J. Zhang, H. Yang, Z. Chen, J. Tang, Z. Zhang, et al. User behavior simulation with large language model-based agents. ACM Transactions on Information Systems. Cited by: §1, §2.1. Wang et al. (2025c) Y. Wang, S. Liu, J. Fang, and Z. Meng EvoAgentX: an automated framework for evolving agentic workflows. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, p. 643â655. Cited by: §2.2. Wang et al. (2025d) Y. Wang, L. Yang, G. Li, M. Wang, and B. Aragam ScoreFlow: mastering llm agent workflows via score-based preference optimization. arXiv:2502.04306. Cited by: §2.2. Wang et al. (2026) Z. Wang, X. Liu, L. Wang, Z. Shan, Y. Wang, Z. Song, and M. Zhang MASPO: joint prompt optimization for llm-based multi-agent systems. arXiv preprint arXiv:2605.06623. Cited by: §2.2. Xu et al. (2026) J. Xu, A. Koesdwiady, S. Bei, Y. Han, B. Huang, D. Wang, Y. Chen, Z. Wang, P. Wang, P. Li, et al. Rethinking the value of multi-agent workflow: a strong single agent baseline. arXiv preprint arXiv:2601.12307. Cited by: §7.2. Yamada et al. (2025) Y. Yamada, R. T. Lange, C. Lu, S. Hu, C. Lu, J. Foerster, J. Clune, and D. Ha The AI scientist-v2: workshop-level automated scientific discovery via agentic tree search. arXiv preprint arXiv:2504.08066. Cited by: §5.3, Table 2. Yin and Wang (2025) L. Yin and Z. Wang LLM-autodiff: auto-differentiate any llm workflow. arXiv:2501.16673. Cited by: §2.2. Yuksekgonul et al. (2025) M. Yuksekgonul, F. Bianchi, J. Boen, S. Liu, P. Lu, Z. Huang, C. Guestrin, and J. Zou Optimizing generative AI by backpropagating language model feedback. Nature 639, p. 609â616. Cited by: §2.2, §7.1. Zhang et al. (2025a) G. Zhang, K. Chen, G. Wan, H. Chang, H. Cheng, K. Wang, S. Hu, and L. Bai EvoFlow: evolving diverse agentic workflows on the fly. arXiv:2502.07373. Cited by: §2.2, §4.4. Zhang et al. (2025b) G. Zhang, L. Niu, J. Fang, K. Wang, L. Bai, and X. Wang Multi-agent architecture search via agentic supernet. In International Conference on Machine Learning (ICML), Cited by: §2.2. Zhang et al. (2025c) G. Zhang, Y. Yue, Z. Li, S. Yun, G. Wan, K. Wang, D. Cheng, J. Yu, and T. Chen Cut the crap: an economical communication pipeline for LLM-based multi-agent systems. In The Thirteenth International Conference on Learning Representations (ICLR), p. 75389â75428. External Links: Link Cited by: §2.2. Zhang et al. (2025d) G. Zhang, Y. Yue, X. Sun, G. Wan, M. Yu, J. Fang, K. Wang, T. Chen, and D. Cheng G-Designer: architecting multi-agent communication topologies via graph neural networks. In Proceedings of the 42nd International Conference on Machine Learning (ICML), Proceedings of Machine Learning Research, Vol. 267, p. 76678â76692. External Links: Link Cited by: §2.2. Zhang et al. (2026a) J. Zhang, Z. Wang, H. Zhu, K. Cheng, K. He, B. Li, Q. Lin, J. Liu, and E. Cambria Mars: multi-agent adaptive reasoning with socratic guidance for automated prompt optimization. In Proceedings of the AAAI Conference on Artificial Intelligence, Vol. 40, p. 16307â16315. Cited by: §4.4. Zhang et al. (2025e) J. Zhang, J. Xiang, Z. Yu, F. Teng, X. Chen, J. Chen, M. Zhuge, X. Cheng, S. Hong, J. Wang, et al. AFlow: automating agentic workflow generation. In ICLR, Cited by: §2.2, §4.4, §5.3, Table 3. Zhang and Balog (2020) S. Zhang and K. Balog Evaluating conversational recommender systems via user simulation. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, p. 1512â1520. External Links: Document Cited by: §2.1, §7.4, §8. Zhang et al. (2025f) X. Zhang, J. Lin, X. Mou, S. Yang, X. Liu, L. Sun, H. Lyu, Y. Yang, W. Qi, Y. Chen, et al. SocioVerse: a world model for social simulation powered by llm agents and a pool of 10 million real-world users. arXiv:2504.10157. Cited by: §2.1. Zhang et al. (2025g) X. Zhang, R. Dou, E. Hu, M. Zhao, Y. Ding, and Z. Dou Collaborative optimization approach for workflow agents in user behavior modeling. In Companion Proceedings of the ACM Web Conference, Cited by: §2.2. Zhang et al. (2026b) Z. Zhang, L. Ge, H. Li, W. Zhu, C. Zhang, and Y. Ye Mapro: recasting multi-agent prompt optimization as maximum a posteriori inference. In Findings of the Association for Computational Linguistics: EACL 2026, p. 4458â4480. Cited by: §2.2. Zhang et al. (2025h) Z. Zhang, S. Liu, Z. Liu, R. Zhong, Q. Cai, X. Zhao, C. Zhang, Q. Liu, and P. Jiang LLM-powered user simulator for recommender system. Proceedings of the AAAI Conference on Artificial Intelligence 39 (12), p. 13339â13347. External Links: Document Cited by: §7.6. Zhao et al. (2025) R. Zhao, H. Yang, M. Gu, J. Wang, W. Long, and Z. Deng USHB: a unified framework for simulating human behaviors in agent society through user-and-item modeling. In Companion Proceedings of the ACM Web Conference, Cited by: §2.1. Zhou et al. (2026) H. Zhou, X. Wan, R. Sun, H. Palangi, S. Iqbal, I. VuliÄ, A. Korhonen, and S. Ă. Arık Multi-agent design: optimizing agents with better prompts and topologies. In International Conference on Learning Representations (ICLR), Cited by: §2.2, §5.3, Table 3. Zhou and Yu (2025) Z. Zhou and R. Yu Can LLMs understand time series anomalies?. In International Conference on Learning Representations (ICLR), Cited by: §7.6. Zhu et al. (2025a) L. Zhu, X. Huang, and J. Sang A llm-based controllable, scalable, human-involved user simulator framework for conversational recommender systems. In The ACM Web Conference, Cited by: §8. Zhu et al. (2025b) R. Zhu, B. Jiang, L. Mei, F. Yang, L. Wang, H. Gao, F. Bai, P. Zhao, Q. Lin, S. Rajmohan, and D. Zhang AdaptFlow: adaptive workflow optimization via meta-learning. In Findings of the Association for Computational Linguistics: EMNLP 2025, p. 3287â3302. Cited by: §2.2. Zhu et al. (2025c) S. Zhu, B. Xu, Y. Yuan, B. Xie, Y. Li, and H. Shen Unveiling the potential of llms in simulated society: a knowledge-driven llm agent framework for user modeling. In Companion Proceedings of the ACM Web Conference, Cited by: §2.1. Zhuge et al. (2024) M. Zhuge, W. Wang, L. Kirsch, F. Faccio, D. Khizbullin, and J. Schmidhuber GPTSwarm: language agents as optimizable graphs. In Proceedings of the 41st International Conference on Machine Learning (ICML), Proceedings of Machine Learning Research, Vol. 235, p. 62743â62767. External Links: Link Cited by: §4.1. Appendix A Extended Gradient Log Analysis LLM calls arise from three distinct code paths, each with different example coverage: Source Examples touched Calls Workflow scoring All 30, all K topologies Ă5=3,0005\!Ă\!30\!Ă\!4\!Ă\!5=3,000 Gradient 1 worst, elite only Ă5=1505\!Ă\!3\!Ă\!2\!Ă\!5= 0,0150 Topology proposal None Ă2=105\!Ă\!2= 3,010 Total â3,160â 3,160 AÂŻâ5 Aâ 5 (mean agents, range [2,8][2,8]); F=1F=1 (gradient runs every iteration); gradient targets single worst-scoring example. where AÂŻâ5 Aâ 5 is the mean agent count over the [2,8][2,8] range. Prompt optimization runs every iteration (F=1F=1); the gradient step targets the single worst-performing example, not the full training batch. A.1. Mask Adoption Gradient Taxonomy Table 9. Gradient direction taxonomy for Mask Adoption. The high proportion of role-reframing gradients (34%) at early iterations confirms that SWORD discovers qualitatively new specialisations, not merely incremental calibrations. Category % Iter Example direction Role reframing 34 0â1 âShift from extraction to direct predictionâ Calibration 28 2â4 âAdd low-baseline prior for zero-history casesâ Schema alignment 18 0â2 âOutput single float, not multi-field JSONâ Signal priority 12 2â4 âhistorical_rates >> intervention >> network degreeâ Intervention hdl 8 1â4 âApply decay only if applied=true and day â„ startâ The high proportion of role-reframing gradients in early iterations (34%) and their near-disappearance by iteration 4 (<<5%) follows a characteristic learning curve: the model first establishes the correct agent identity, then shifts to calibrating within that identity. This mirrors the coarse-to-fine optimization pattern observed in DSPy Khattab et al., 2024âs compilation pipeline and the ânovice-to-expertâ progression of StepAgent Deng et al., 2024. The 8% of intervention-handling gradients encode epidemiologically meaningful rules (timing, decay, peer effects) consistent with the ABM model De Kai et al., 2020, demonstrating that SWORD extracts domain knowledge from the metric signal alone. A.2. Agent Society Gradient Taxonomy On Agent Society, gradient categories reflect the multi-signal rating-prediction structure studied extensively in LLM-based recommendation Kang et al., 2023; Kim et al., 2024; Liu et al., 2024b; Luo et al., 2024; Sun et al., 2024. Table 10. Gradient direction taxonomy for Agent Society. The dominance of sentiment-related gradients (72% combined) shows the textual gradient mechanism correctly identifies review text as the most informative feature. Category % Iter Example direction Sentiment prioritisation 41 0â1 âWeight review sentiment above numeric priorsâ Sentiment mapping 31 1â4 âStrongly positive review: add ++0.8â1.2 starsâ Conflict resolution 16 2â4 âIf sentiment disagrees with rating, weight sentiment 2:1â Calibration 12 3â4 âPlatform-mean anchor adjustment: ± 0.1â The dominance of sentiment-related gradients (72% combined) is striking: without any task-specific initialization, the textual gradient mechanism autonomously discovers that review text is the primary signal for rating prediction. This unsupervised discovery via gradient feedback demonstrates the power of task-metric-conditioned textual gradients as a mechanism for feature-importance learning. Appendix B Additional Qualitative Examples B.1. Workflow Proposer Reasoning Below are verbatim excerpts from the LLM workflow proposer on Mask Adoption, showing how it conditions structural proposals on task-specific metric feedback. These examples illustrate that the proposer generates domain-informed structural mutations, not random workflow permutations: Iteration 1: âThe current 2-agent workflow requires generator to both extract signals and produce the prediction. The RMSE of 0.1830 suggests the system is over-predicting mask rates. Adding an explicit validator after generator that checks the predicted rate against known boundary conditions (mask rate cannot exceed 1.0; cannot increase by >>0.3 in one day without intervention) should constrain over-prediction. Proposed: [Analyzerâ â â ].â Iteration 3: âThe current workflow produces RMSE 0.1735 on intervention days. The prompt gradient for generator indicates it is struggling to model exponential decay of intervention effects. Adding a planner that converts the raw intervention parameters into a âresidual effect scheduleâ before generator sees them should simplify the generatorâs task. Proposed: [Analyzerâ â â â ].â These proposals use domain-specific language (exponential decay, boundary conditions, residual effect schedule) drawn directly from the RMSE error signal, confirming that the proposer genuinely conditions on task-level feedback. B.2. Representative Learned Prompt Below is the final prompt for the Analyzer agent in the winning 5-agent workflow on Mask Adoption (Seed 1, iteration 4). This prompt was generated entirely by the textual gradient process without any domain-expert input: âYou are the Analyzer agent responsible for extracting epidemiologically relevant signals from the provided context. Your output is consumed by a downstream Planner and must follow the schema exactly. Signal extraction rules: (1) Compute the 3-day moving average of historical_rates. (2) Identify the trend direction (increasing / stable / decreasing) based on recent_trend; use >+0.02>+0.02 for increasing, <â0.02<-0.02 for decreasing. (3) If intervention_info.applied = true, extract the decay factor and days-since-start; compute residual effect as effect_size Ă decaydays^days. (4) From population_summary, extract network_degree and risk_perception; note that network_degree is a weak signal and must be flagged as low-confidence. Do NOT extrapolate. Output JSON with fields: moving_avg, trend_direction, residual_intervention, population_signals (with low_confidence flag for network_degree), data_quality_flag (True if >>3 historical rates available; False otherwise).â The prompt encodes the epidemiological structure of the taskâexponential decay of interventions, weak vs. strong signals, moving averagesâknowledge derived purely from RMSE loss signals over 30 training examples. Appendix C Full Per-Seed Results (n=10) Tables 11 and 12 list the complete per-seed results underlying Table 3. All methods were run on identical seeds (paired design); seeds were collected in three batches (1, 3, and 6 runs) under identical configuration. Table 11. Per-seed Agent Society MAEâ for all methods. Seed SWORD Staged Prompt-Only Workflow-Only 1 0.2445 0.4310 0.3249 0.2965 2 0.3122 0.5078 0.3404 0.3618 3 0.2502 0.7685 0.4649 0.4222 4 0.2000 0.1311 0.2944 0.6161 5 0.1870 0.7424 0.3214 0.4384 6 0.1611 0.2248 0.2562 0.7424 7 0.3310 0.9810 0.3535 0.4343 8 0.2174 0.4992 0.1374 0.4075 9 0.1581 0.2089 0.2162 0.4127 10 0.5052 0.6044 0.2958 0.4233 Mean± 0.2567±0.10490.2567_± 0.1049 0.5099±0.27360.5099_± 0.2736 0.3005±0.08700.3005_± 0.0870 0.4555±0.12870.4555_± 0.1287 95% CI [0.182,0.332][0.182,0.332] [0.314,0.706][0.314,0.706] [0.238,0.363][0.238,0.363] [0.363,0.548][0.363,0.548] Table 12. Per-seed Mask Adoption RMSEâ for all methods. Seed SWORD Staged Prompt-Only Workflow-Only 1 0.0217 0.2977 0.0218 0.0902 2 0.0201 0.4194 0.0249 0.0254 3 0.0207 0.4194 0.0217 0.0430 4 0.0200 0.0227 0.0230 0.0220 5 0.0202 0.0678 0.0206 0.0394 6 0.0219 0.0200 0.0221 0.0269 7 0.0237 0.0218 0.0231 0.2503 8 0.0236 0.1880 0.0250 0.0381 9 0.0210 0.0230 0.0221 0.0244 10 0.0246 0.3154 0.0275 0.1261 Mean± 0.0217±0.00170.0217_± 0.0017 0.1795±0.16980.1795_± 0.1698 0.0232±0.00210.0232_± 0.0021 0.0686±0.07220.0686_± 0.0722 95% CI [0.0206,0.0229][0.0206,0.0229] [0.058,0.301][0.058,0.301] [0.0217,0.0247][0.0217,0.0247] [0.017,0.120][0.017,0.120] Paired test summary. Two-sided paired t-tests of each ablation vs. SWORD (n=10n=10), with per-benchmark HolmâBonferroni correction: Agent Society â Staged (tâĄ(9)=3.29t(9)=3.29, p=0.0093p=0.0093, d=1.04d=1.04, significant), Workflow-Only (tâĄ(9)=3.27t(9)=3.27, p=0.0096p=0.0096, d=1.04d=1.04, significant), Prompt-Only (tâĄ(9)=1.18t(9)=1.18, p=0.268p=0.268, d=0.37d=0.37, n.s.); Mask Adoption â Staged (tâĄ(9)=2.94t(9)=2.94, p=0.0165p=0.0165, d=0.93d=0.93, significant), Prompt-Only (tâĄ(9)=2.73t(9)=2.73, p=0.0233p=0.0233, d=0.86d=0.86, significant), Workflow-Only (tâĄ(9)=2.08t(9)=2.08, p=0.067p=0.067, d=0.66d=0.66, n.s.). Appendix D Implementation Details for Reproducibility This section specifies the exact prompt templates used by SWORDâs textual-gradient prompt optimizer, the procedure used to generate the initial population of workflow topologies, and the JSON output schema each agent role is instructed to produce. All templates below are reproduced verbatim from the released implementation (core/prompt_optimizer.py, core/sword.py, core/agents.py) rather than paraphrased, so that the optimization procedure can be reproduced exactly. D.0.1. Prompt templates for textual-gradient optimization Each prompt-optimization step consists of three sequential LLM calls, implemented in PromptOptimizer and TextualGradientComputer (core/prompt_optimizer.py). (1) ATTRIBUTE FEEDBACK. Before an agentâs prompt is updated, task-level evaluation feedback (produced by the task evaluator, not by SWORDâs core loop) is attributed to the specific agent by asking the LLM to isolate the portion of that feedback relevant to the agentâs role and outputs: ## Agent Name: agent_name Role: agent_role ## Agent Outputs agent_outputs as indented JSON ## Global Evaluation Feedback global_feedback ## Instructions Extract only the parts of the feedback that are relevant to this specific agentâs outputs and role. Rephrase as direct feedback to this agent. If none, say "No specific issues." This call uses no dedicated system prompt (PromptOptimizer._attribute_feedback). (2) COMPUTE GRADIENT. The attributed, per-agent feedback is then used to compute a textual gradient: a natural-language description of how the agentâs system prompt should change. This call is issued with a fixed system prompt, You are a prompt optimization expert. Your job is to analyze why an agentâs system prompt led to suboptimal performance and produce a "textual gradient" --- a precise, actionable description of how the prompt should change. Think like a gradient: identify the direction and magnitude of change needed. Be specific about what to add, remove, or rephrase. and a user prompt that supplies the agentâs current system prompt, the task context, the agentâs inputs/outputs on the most recent evaluated example, the numeric evaluation score and per-agent feedback from step (1), and up to the three most recent prompt trajectories (prior prompt, score, and feedback) for that agent. The model is instructed to return four structured sections: ERROR_ANALYSIS, GRADIENT_DIRECTION, MAGNITUDE, and SPECIFIC_CHANGES (TextualGradientComputer.compute_gradient). (3) APPLY GRADIENT. The computed gradient is then applied to produce the new system prompt, again with a fixed system prompt, You are a prompt engineering expert. Given a system prompt and a textual gradient describing how to improve it, produce an updated system prompt that incorporates the gradient. Rules: - Preserve the core role and intent of the agent - Incorporate all specific suggestions from the gradient - Make the prompt clear, specific, and actionable - Do not make the prompt excessively long - Output ONLY the new system prompt, no explanations and a user prompt containing the current prompt, the textual gradient from step (2), and a scalar learning_rate (default 1.01.0) included as context for the magnitude of the requested edit; the learning rate is not applied numerically, since the update is itself a free-text LLM rewrite rather than a parametric step (PromptOptimizer.optimize). The resulting prompt, score, and feedback are appended to that agentâs trajectory history, and PromptOptimizer.get_best_prompt can retrieve the highest-scoring prompt observed for any agent across the run. D.0.2. Initial workflow topology generation Unlike the prompt-update steps above, the initial population of workflow topologies is generated procedurally rather than by an LLM call, in SWORD._initialize_population (core/sword.py). For each of topology_population_size individuals, the number of agents is drawn uniformly from 2,âŠ,8\2,âŠ,8\; each agentâs role is sampled uniformly at random from the eight available roles (§D.0.4), with the first agent in sampling order designated the entry point and the last designated the exit point; between 11 and 2ân2n random directed edges are then added (subject to the acyclicity and max-in-degree constraints enforced by WorkflowTopology.add_edge). Finally, WorkflowTopology.ensure_data_flow is invoked to repair the random graph so that (i) the entry agent has at least one outgoing edge, (i) the exit agent has at least one incoming edge, and (i) a directed path exists from every entry point to every exit point â guaranteeing that task input can reach the final output before the topology is ever evaluated, so that a topologyâs fitness reflects prediction quality rather than an accidentally disconnected graph. Later generations are produced from the elite set of the previous generation via WorkflowTopology.mutate, which applies one of add_agent, remove_agent, add_edge, remove_edge, or rewire, followed by the same ensure_data_flow repair step. D.0.3. Prompt to propose workflow from feedback user_msg = (f"TASK: task_evaluator.get_task_context() f"CURRENT POPULATION (ranked bestâworst): " f"json.dumps(pop_summary, indent=2) " "Propose one new topology that addresses the weaknesses above.") SYSTEM_TOPO = ( "You are a workflow optimizer. " "Propose a better multi-agent topology based on scores and feedback. " "Roles: analyzer, planner, generator, critic, synthesizer, " "executor, transformer, validator. " "Rules: 2-8 agents, one entry, one exit, no cycles. " âReturn ONLY JSON: "reasoning":"1 sentence","agents":[â â"name":"x","role":"y"],"edges":[["src","tgt"]],â â"entry":"name","exit":"name"â ) raw = self.llm.chat( messages=[ "role": "system", "content": self.SYSTEM_TOPO, "role": "user", "content": user_msg, ], max_completion_tokens=2000, ) D.0.4. Agent output JSON schemas Every agent is instantiated with one of eight fixed roles (GeneralAgent.ROLE_TEMPLATES in core/agents.py); the role template supplies the agentâs default system prompt, including an explicit required output schema, unless a role-specific prompt has already been produced for that agent by the optimizer described above. The eight schemas are: analyzer: "signals": [...], "key_values": ..., "pattern": "...", "recommendation": "...", "confidence": "high|medium|low" planner: "steps": [...], "strategy": "...", "predicted_value": "<numeric estimate>", "adjustment_reason": "..." generator: free-form JSON combining upstream key_values, recommendation, predicted_value, and critic corrections into one final prediction (no fixed key set; the agent is instructed to produce the taskâs final answer). critic: "issues": [...], "corrections": ..., "quality_score": "<float 0.0--1.0>", "revised_recommendation": "..." synthesizer: free-form JSON that must explicitly reference every upstream agentâs output, with conflicting signals weighted critic >> analyzer >> planner. executor: free-form JSON encoding the result of following the upstream plannerâs steps, incorporating critic corrections. transformer: free-form JSON reformatted to match the taskâs required output schema exactly. validator: "valid": "true|false", "violations": [...], "corrected_output": "<corrected answer if invalid, else original>" Four of the eight roles (generator, synthesizer, executor, transformer) are deliberately left schema-free at the template level because their required output shape is task-dependent (e.g. a numeric adoption rate for mask_adoption versus a star rating and review string for agent_society); for these roles the task-specific output format is instead communicated through task_context, which is prepended to every agentâs prompt by WorkflowTopology.execute. Every agent, regardless of role, is additionally instructed at the end of its prompt (GeneralAgent.run) to "Respond with ONLY a valid JSON object. No markdown, no explanation." Responses are parsed by GeneralAgent._parse_response, which attempts, in order: (i) a fenced ââjson ⊠ââ| block, (i) any fenced ââ ⊠ââ| block, (i) the first top-level âŠ| substring, and (iv) the raw response as JSON; if all four attempts fail, the raw text is wrapped as "output": response, "raw": response rather than raising, so a malformed response degrades to a low-scoring but well-typed output instead of crashing the workflow. Full, unabbreviated source for all three prompt templates and the eight role schemas is included in the supplementary code release (core/prompt_optimizer.py, core/agents.py), which we consider the authoritative reference over this description. D.0.5. Initial (pre-optimization) role prompts Every agent is assigned one of eight fixed roles at creation time. Unless a role-specific prompt has already been produced for that agent by the textual-gradient optimizer described above, its system prompt defaults to the corresponding entry of GeneralAgent.ROLE_TEMPLATES (core/agents.py), reproduced verbatim below. These are the exact prompts every agent starts from at iteration 00, before any optimization has occurred. analyzer: You are an analyzer agent. Read the task_input carefully and extract key signals. You MUST return ONLY this JSON structure --- no other text: "signals": ["signal1", "signal2"], "key_values": "metric1": value, "metric2": value, "pattern": "one sentence describing the main pattern", "recommendation": "what the next agent should focus on", "confidence": "high|medium|low" planner: You are a planner agent. Read all upstream outputs and create an action plan. You MUST return ONLY this JSON structure --- no other text: "steps": ["step1", "step2", "step3"], "strategy": "one sentence strategy", "predicted_value": "<numeric estimate based on upstream signals>", "adjustment_reason": "why you adjusted from upstream recommendation" generator: You are a generator agent. Your job is to produce the FINAL answer. You MUST read all upstream agent outputs and use them to inform your answer. Specifically: use key_values and recommendation from analyzers, use predicted_value from planners, use corrections from critics. Combine all upstream signals into ONE final prediction. Return ONLY valid JSON with your final output. critic: You are a critic agent. Read the upstream agent outputs and evaluate them. You MUST return ONLY this JSON structure --- no other text: "issues": ["issue1", "issue2"], "corrections": "field1": "corrected_value", "quality_score": "<float 0.0-1.0>", "revised_recommendation": "improved version of upstream recommendation" synthesizer: You are a synthesizer agent. Combine ALL upstream agent outputs into one final answer. You MUST explicitly reference each upstream agent output in your synthesis. Weight conflicting signals: critics >> analyzers >> planners. Return ONLY valid JSON with the final synthesized output. executor: You are an executor agent. Apply the plan from upstream agents step by step. You MUST follow the steps from any planner upstream, incorporating corrections from any critic upstream. Return ONLY valid JSON with the execution result. transformer: You are a transformer agent. Convert upstream outputs into the format the task requires. Read all upstream key_values and recommendations, then reformat them to match the task output schema exactly. Return ONLY valid JSON matching the task output format. validator: You are a validator agent. Check the upstream agent output against the task constraints. You MUST return ONLY this JSON structure --- no other text: "valid": "true|false", "violations": ["violation1"], "corrected_output": "<corrected final answer if invalid, else original>" Four roles â generator, synthesizer, executor, and transformer â are deliberately left without a fixed output schema in their initial prompt, since their required output shape is task-dependent (e.g. a numeric adoption rate for mask_adoption versus a star rating and review string for agent_society); for these roles the task-specific output format is instead communicated at run time through task_context, which WorkflowTopology.execute prepends to every agentâs prompt regardless of role. Every agent, irrespective of role, additionally receives a final instruction appended by GeneralAgent.run at the end of its prompt: âRespond with ONLY a valid JSON object. No markdown, no explanation.â None of these eight prompts are hand-tuned per task; the only task-specific signal an agent receives is task_context and the upstream outputs passed to it at run time, so any task-specific behavior visible in our results emerges either from this shared context or from the textual-gradient optimization process described above, not from prompt engineering per task. Appendix E SOCIAâSWORD Ablation Study The released implementation is designed to execute and verify generated simulation code inside an isolated Docker container. Because Docker was unavailable in our evaluation environment, the implementationâs documented fallback was to ask the underlying LLM to approximate the result that code execution would have produced. We do not consider this fallback suitable for evaluation against held-out ground truth, because an LLM-generated execution estimate does not provide a reliable basis for assessing the actual behavior of the generated program. We therefore modified two call sites in the released implementation: the simulation-execution step and a code-verification smoke test. Both require Docker and provide no independent non-Docker execution path. When Docker was unavailable, we instead executed the generated code as a native Python subprocess. This modification differs from the authorsâ documented fallback and should therefore be understood as a change to the evaluation protocol rather than a correction to the released implementation. All results reported in this ablation were obtained by genuinely executing the generated programs and evaluating their outputs against held-out data, but under native, unsandboxed execution rather than the original Docker-based execution and verification environment. Unlike SWORD, SOCIA-â regenerates its implementation from scratch on each invocation and additionally requires the generated code to pass an automated verification stage before execution. Across the evaluation attempts, runs failed either during verification or during execution, including runtime failures in generated data-preprocessing code such as attempts to process non-numeric fields. One additional run was excluded because the frameworkâs evaluator flagged its reported score as ungrounded in the held-out data. We therefore report the first run that both completed execution successfully and produced a result that was not flagged as unverified. Only 1 of 8 attempts satisfied both criteria. Consequently, these results should be interpreted as single-run point estimates (n=1n=1), rather than replicated statistics. This contrasts with the n=10n=10 paired trials used for SWORD and limits the strength of conclusions that can be drawn from the SOCIA-â comparison. Appendix F Code Repository of SWORD https://anonymous.4open.science/r/SWORD-8686/README.md