DD-GEPA: Prompt Optimization for Dialogue Disentanglement Focusing on Task Instruction and Utterance Representation Naoki Takada and Tatsunori Mori Yokohama National University, Japan {takada-naoki-xs, tmori}@ynu.jp
arXiv:2606.07894v1 [cs.SE] 5 Jun 2026
Abstract
In multi-party chat, such as Slack and Internet Relay Chat(IRC), multiple dialogues are entangled. Because many users send messages simultaneously, multiple dialogues can proceed in parallel and become entangled. Such entanglement can also lead to failures in automatic analysis, because utterances from unrelated dialogues can be mistaken for relevant context. To address this problem, dialogue disentanglement was proposed (Elsner and Charniak, 2010). As shown in Figure 1, dialogue disentanglement is the task of partitioning entangled utterance sequence into coherent dialogue clusters whose utterances are connected by reply-to relations. This task is an important preprocessing for downstream applications such as dialogue state tracking (Ouyang et al., 2020) and response generation (Cai et al., 2022). A common approach to disentangle is to identify reply-to relations between utterances (Elsner and Charniak, 2010). For each utterance, we determine whether the utterance is (1) begginning of a new dialogue or (2) reply to a previous utterance, and then construct the each disentangled dialogues by linking these reply-to relations. Large language models (LLMs) have strong contextual reasoning capabilities, suggesting that they can be effectively applied to dialogue disentanglement. However, the first attempt to apply LLMs to this task achieved very low accuracy and fell far short of existing non LLM methods (Li et al., 2025). Later work reported that prompt design can improve the accuracy of LLM based dialogue disentanglement. In particular, introducing dialogue-level assignment and subsequent context achieved accuracy that surpassed existing methods, demonstrating the potential of LLMs for dialogue disentanglement (Takada and Mori, 2026). However, the effectiveness of dialogue-level assignment and subsequent context varies across LLMs, and these components can even reduce accuracy. Thus, there is still no generally effective
Multi-party chat often contains interleaved dialogues because multiple participants can discuss different topics at the same time. Dialogue disentanglement addresses this problem by separating an entangled utterance sequence into coherent dialogues. While large language models (LLMs) are promising for this task, they still struggle with dialogue disentanglement and achieve low accuracy. This paper proposes an automatic prompt optimization for LLM based dialogue disentanglement. We decompose the prompt into three components: task instruction, utterance representation, and output instruction, and optimize them using GEPA, an optimization method for compound AI systems. Experiments on benchmark datasets show that the optimized prompts improve dialogue disentanglement accuracy over the original prompts and can surpass hand crafted prompts.
1
Introduction alice
do you know how to install the new tensorflow?
bob
what’s the best way to convert a pdf to text?
carol
you can use pip install tensorflow==2.9.0
dave
I recommend pdftotext for pdf
bob
thanks! pdftotext work on Windows?
alice
carol : thx! do I need uninstall the old version?
emil
is anyone attending the keynote tomorrow?
carol
No, pip will handle the upgrade automatically
dave
Yes, there’s a Windows version available
emil
ill be there! looking forward to it.
Figure 1: An example of dialogue disentanglement, where the resulting dialogues are shown by color.
1
method for improving LLM based dialogue disentanglement. Because chat data may contain personal information, accurate disentanglement with open-weight LLMs is desirable. However, openweight LLMs with around 30B parameters still fall far short of conventional non LLM methods, leaving substantial room for improvement. Dialogue disentanglement is a challenging task even for humans; prior annotation studies have shown substantial variation in judgments among annotators (Kummerfeld et al., 2019). This makes it difficult to manually write a clear task instruction for dialogue disentanglement. Moreover, LLM performance is highly sensitive to how information and output formats are specified in the prompt (Sclar et al., 2024; Tam et al., 2024). The same issue is pronounced in dialogue disentanglement: as shown later in Section 5, especially Table 1, accuracy changes substantially depending on the utterance representation and output instruction. These observations indicate that prompt design must account not only for the task instruction but also for the output instruction. Because jointly designing and validating these components by hand is difficult, this study proposes an automatic prompt optimization method for dialogue disentanglement. We decompose each prompt into the following three components and optimize them separately. Task instruction: This component defines dialogue disentanglement, explains the task, and specifies what evidence should be used for the assignment decision. Utterance representation: This component presents each utterance as a combination of utterance number, timestamp, speaker ID, and message content. It specifies how this information is formatted for the LLM, for example by using JSON or adding explicit labels to each field. Output instruction: This component specifies how to output the result of dialogue disentanglement. Our optimization target is a prompt composed of multiple components. We therefore propose a method based on GEPA (Agrawal et al., 2026), which has achieved state-of-the-art results in automatic optimization for compound AI systems. The main contribution of this work is an automatic method for optimizing dialogue disentanglement prompts, whose design is difficult to specify manually. Experiments show that the optimized prompt improves accuracy over the initial prompts and the
manually designed prompt of Takada and Mori (2026).
2 Related Work 2.1 Dialogue Disentanglement Dialogue disentanglement has been formulated as a two stage problem (Elsner and Charniak, 2010; Li et al., 2020; Ma et al., 2021). First, a classifier assigns scores to utterance pairs within a specified context window to estimate the strength of their reply-to relations. Second, a clustering algorithm aggregates the predicted local links to construct the global dialogue structure. Early methods estimated reply-to relations from manually designed features, including lexical overlap, time gaps, and explicit user mentions (Elsner and Charniak, 2008, 2010). The release of a large annotated corpus (Kummerfeld et al., 2019) encouraged the development of end to end neural models, and the use of fine tuned PLMs such as BERT further improved accuracy by utilizing richer contextual information (Li et al., 2020). However, these methods mainly model the utterance sequence itself and make limited use of dialogue specific information. Subsequent work incorporated speaker information and user mentions (Ma et al., 2021). DiHRL (Li et al., 2025) further improved performance by integrating hierarchical learning losses, an easy-first decoding algorithm, and global conversational features. Although LLMs have achieved strong results across natural language processing tasks, the ability of dialogue disentanglement remains underexplored. The first attempt (Li et al., 2025) substantially underperformed conventional non LLM methods. Its task instruction was minimal, asking the LLMs only to identify an utterance in a reply-to relation and output its index, with a short hint that nearby utterances are likely to be related. Its utterance representation and output instruction were also examined only through simple examples. To address this issue, Takada and Mori (2026) proposed an LLM based method that substantially outperformed prior methods by improving the utterance representation and output instruction. Their approach represents the utterance sequence in JSON format and introduces dialogue-level assignment (DLA), which presents dialogue structures inferred from previous assignments, and subsequent context (SC), which adds utterances following the target utterance as auxiliary evidence. 2
However, while these techniques achieve high accuracy with some proprietary LLMs, performance drops sharply for around 30B open-weight LLMs. High accuracy disentangling with smaller openweight LLMs is especially important when handling chat data that may contain personal information. This work addresses that gap by improving the accuracy of LLM based dialogue disentanglement. One possible path to higher accuracy is to provide a more informative task instruction. Such an instruction should clearly define the criteria for assigning each target utterance. Human annotation guidelines could serve as a natural starting point. However, although many dialogue disentanglement annotations have been conducted (Kummerfeld et al., 2019; Chatterjee et al., 2020), detailed guidelines have not been established. The only available annotation guideline is that of Kummerfeld et al. (2019), which is brief and requires reconciliation among multiple annotators. Even with this guideline, inter annotator agreement was below a kappa coefficient of 0.75, indicating substantial variation in judgment. This variation stems from the difficulty of dialogue disentanglement annotation. For each target utterance, annotators must choose parent utterances from many preceding candidates. Multi-party chat also contains diverse topics, participant configurations, and dialogue situations. These factors make it difficult to write a task instruction that enables accurate LLM based dialogue disentanglement. Prompt design is harder still because accuracy also depends on the utterance representation and output instruction. We therefore address prompt design through automatic prompt optimization. 2.2
makes them difficult to transfer across LLMs. In contrast, APE (Zhou et al., 2023) and OPRO (Yang et al., 2024) optimize natural language prompts. They use an LLM as the optimizer to generate and refine candidate prompts. Because the prompts are written in natural language, humans can inspect and reuse them more easily across LLMs. EvoPrompt (Guo et al., 2024) incorporates evolutionary search into prompt optimization, allowing it to explore a broader space of candidate prompts. However, these methods are mainly designed for single prompt, single task settings. They are less suited to compound AI systems in which multiple agents or reasoning steps interact. To address this limitation, MIPROv2 (Opsahl-Ong et al., 2024) extends prompt optimization to compound systems using Bayesian optimization and bootstrap search. GEPA (Agrawal et al., 2026) further improves compound system optimization by using natural language reflection on execution trajectories and evolutionary Pareto based selection. We choose GEPA as our optimization method for the following three reasons. First, dialogue disentanglement prompts involve multiple factors, and GEPA is suitable for optimizing such multi component systems. Second, GEPA optimizes natural language prompts, which makes the resulting prompts interpretable and more portable when the underlying LLM changes. Third, GEPA has achieved state-of-theart performance. However, GEPA cannot be applied directly to dialogue disentanglement. In its original form, GEPA optimizes only the task instruction and does not handle the utterance representation or output instruction. We therefore adapt GEPA and propose a new method that optimizes these components together for dialogue disentanglement.
Automatic Prompt Optimization
Effective use of LLMs requires appropriate prompt design, but manual design involves extensive trial and error and does not guarantee an optimal prompt. Automatic prompt optimization has therefore become an active research area. Early methods include Prompt Tuning (Lester et al., 2021) and Prefix Tuning (Li and Liang, 2021). Instead of searching for natural language instructions, these methods optimize learnable continuous vectors attached to the input. The LLM parameters remain fixed, and only the added vectors are trained. Although this is more efficient than full fine tuning, the resulting prompts are not human readable. They are also model specific, which
3 LLM Based Dialogue Disentanglement 3.1 Task Formulation We define the input conversation C = (u1 , u2 , . . . , un ) as the full utterance sequence observed in the chat. Each utterance ui is represented as ui = (ti , si , mi ), where ti is the timestamp, si is the speaker ID, and mi is the message content. The desired output is a set of dialogues D = {d1 , d2 , . . . , dp }, where each dialogue dj is a cluster of utterances that are linked by reply-to relations. The task is to partition C 3
into the dialogue set D. The partition must satisfy two conditions. First, it must cover all utterances: ∪ C = dj ∈D dj . Second, the dialogue clusters must be mutually exclusive: ∀j ̸= k, dj ∩ dk = ∅.
rect when the predicted parent utterance appears before utarget and belongs to dgold . A correct decision receives a score of 1, and any other decision receives a score of 0.
3.2
4 Automatic Prompt Optimization
LLM Based Disentanglement Method
For each utterance, we ask the LLM to predict its reply-to relation. We select one utterance as the target utterance utarget and provide it to the LLM together with the utterances that precede it. The LLM determines whether utarget starts a new dialogue or responds to a previous utterance. If it responds to a previous utterance, the LLM selects one preceding utterance as the most appropriate parent utterance. After predicting reply-to relations for all utterances in C, we construct dialogue clusters in chronological order. If utarget is predicted to start a new dialogue, we create a new cluster containing only utarget . If utarget is predicted to reply to a previous utterance, we add it to the cluster that contains the predicted parent utterance. Repeating this process for all utterances yields the set of dialogues D. This algorithm follows conventional non LLM methods (Elsner and Charniak, 2010); in this study, we replace the classifier with an LLM. In addition to this basic framework, Takada and Mori (2026) proposed two extensions. DialogueLevel Assignment (DLA) changes the assignment target from individual previous utterances to previously established dialogues. In DLA, the previous context is represented by dialogue structures inferred from earlier assignments. Subsequent Context (SC) adds utterances after utarget as auxiliary evidence. However, the contribution of DLA and SC differs across LLMs, and these methods can reduce accuracy in some cases. Since this study focuses on prompt optimization itself, we use the basic framework excluding DLA and SC. 3.3
4.1 DD-GEPA We propose DD-GEPA, which adapts GEPA to dialogue disentanglement prompt optimization. As described in Section 1, we decompose a dialogue disentanglement prompt into three components: task instruction, utterance representation, and output instruction. We refer to each component as a “module” and to a dialogue disentanglement system that consists of the three modules as a “program”. DD-GEPA maintains a pool of candidate programs and repeatedly updates one module in one selected program. When an update improves the program, the new program is added to the candidate pool. Figure 2 illustrates this optimization process. The optimization starts with predefined initial programs. Each program is evaluated on 300 validation instances using the binary decision score. DD-GEPA then selects a Pareto based candidate for improvement in two steps. First, DD-GEPA removes programs dominated by another candidate that solves the same validation instances and achieves a higher total score. Second, one of the remaining programs is sampled with probability proportional to its total score. After the program is selected, the module to update is chosen in round robin order. This selection procedure is unchanged from the original GEPA. New prompts are generated through reflection on execution traces. In the original GEPA framework, how to construct these traces is left to the user. We define them as follows. For each update, we sample minibatch that has three instances from the train set and run the selected program on them. For each instance, we extract the LLM input, output, reasoning text, and decision correctness as the execution trace. For incorrect decisions, we also ask an LLM to generate a failure explanation and append it to the trace. After collecting the traces, DD-GEPA updates the selected module. The LLM receives traces and returns an updated prompt for the selected module only; the other two modules are kept unchanged. The updated module is then combined with the unchanged modules to form a new program. If
Scoring Assignment Decisions
GEPA optimizes prompts by evaluating each LLM output. We therefore define a binary score for the LLM’s decision in our dialogue disentanglement task. Let dgold denote the gold dialogue cluster to which the target utterance utarget should be assigned. The LLM decision is evaluated in two cases. If the LLM predicts that utarget starts a new dialogue, the decision is correct when utarget is the first utterance in dgold . If the LLM predicts that utarget replies to a previous utterance, the decision is cor4
Start with 2 programs
Pareto based selection V1
𝑃1 𝑃2
V2
V3
V300
〇 〇
𝑃𝑛
〇
〇
Task instruction
〇
Utterance Representation
Output instruction
𝑃𝑛+1
Update New utterance representation Old utterance representation Input/Output/Reasoning
feedback
Random selection
Round robin selection Module
fail
𝑀1 𝑀2 𝑀3
〇
Try new program
𝑀1 𝑀2 𝑀3
〇 〇
Choose the update target Score
Candidate pool
success
Evaluate the program and add to candidate
Validation:300
train: 150
Minibatch: 3
Collect traces feedback 𝑀1 〇 𝑀2
𝑀3
Try old program
𝑃2
Figure 2: Overview of DD-GEPA for automatic optimization of dialogue disentanglement prompts. A program is selected from the candidate pool using Pareto based selection, and one module in the selected program is chosen for update in round robin order. DD-GEPA samples a minibatch of three training instances, collects execution traces from the selected program, and updates the target module based on the traces. The updated module is incorporated into a new program, which is added to the candidate pool if it improves the task success rate on the minibatch.
the new program performs better than the previous program on the minibatch, the update is accepted. The new program is added to the candidate pool. We then evaluate it on the 300 validation instances so that it can be considered in later program selection. If the update does not improve performance, the new program is discarded. We repeat this cycle for a fixed number of iterations and select the program with the highest validation score as the optimized program. The prompts used in this study are provided in Appendix A. For dialogue disentanglement, the original GEPA can optimize the task instruction only. DDGEPA extends the optimization target to include the utterance representation and output instruction. The following subsections describe how each of the three modules is optimized. 4.2
tion, the proposed representation must be applicable to any utterance sequence and inserted into the prompt without manual formatting. We therefore add an external function that generates conversion code. Given the proposed representation, an LLM writes code that converts an utterance sequence into the proposed format and inserts the converted sequence into the prompt during evaluation. 4.4 Output Instruction For the output instruction, the LLM proposes a more effective prediction format. Since the evaluator expects a fixed format, predictions in a proposed format must be converted before scoring. We therefore add an external function that generates output interpretation code. Given the proposed output instruction, an LLM writes code that converts predictions into the predefined evaluation format. During evaluation, this code converts each prediction to the evaluation format before scoring.
Task Instruction
For the task instruction module, we add one constraint to the original improvement prompt: the generated prompt must not include the output instruction. Without this constraint, the optimizer may mix output requirements into the task instruction, which would prevent us from improving the modules independently. 4.3
5 Evaluation Experiments 5.1 Experimental Objectives We evaluate the proposed method from two perspectives. First, we examine whether prompt optimization improves the dialogue disentanglement accuracy of LLMs by comparing a manually designed prompt with the optimized prompt. Second, we compare an optimized prompt with a smaller open-weight LLM against a manually designed prompt with a proprietary LLM to assess
Utterance Representation
When updating the utterance representation, we ask the LLM to propose a new representation that improves the accuracy of dialogue disentanglement decisions. To automate prompt optimiza5
how much optimization can close the performance gap. 5.2
Because Baseline achieves higher assignment accuracy than Seed 1 and Seed 2 (see Table 1), the output instruction using two keys and the JSON utterance representation are likely to contribute to performance improvements. However, when optimization starts only from Seed 1, the JSON representation is often proposed early, whereas the output instruction using two keys is rarely proposed. We therefore include Seed 2 as an additional initial program to make the early stage of optimization more effective.
Dataset
We use the Ubuntu IRC dataset, a standard benchmark for dialogue disentanglement (Kummerfeld et al., 2019). The dataset consists of real chat logs in which multiple participants discuss technical issues related to Ubuntu OS, producing interleaved dialogues. It is divided into train, development, and test splits. The development and test splits are high quality gold data validated by multiple annotators; they contain 2,500 and 5,000 utterances, respectively. We use the development split for prompt optimization and the test split for evaluating performance changes and comparing with prior work. 5.3
5.4 Evaluation Metrics We adopt evaluation metrics that are widely used in dialogue disentanglement and evaluate performance from three perspectives. First, we measure the overall consistency of the predicted clustering using Variation of Information (VI) (Meilă, 2003), Adjusted Rand Index (ARI) (Hubert and Arabie, 1985), Normalized Mutual Information (NMI) (McDaid et al., 2011), One-to-One accuracy (1-1) (Elsner and Charniak, 2010), and ShenF1 (S-F) (Shen et al., 2006). Second, we use Local3 to measure local clustering accuracy over windows of three utterances (Elsner and Charniak, 2010). Third, we evaluate exact matches of dialogue clusters using precision (P), recall (R), and F1 score (Kummerfeld et al., 2019).
Prompt Settings
We evaluate four prompt settings used in this study. Seed 1: Seed 1 is one of the initial programs used for optimization. Its task instruction is a simple instruction originally written for preliminary experiments in DiHRL (Li et al., 2025). Its utterance representation separates utterance fields only with whitespace. Its output instruction requires the LLM to output a single utterance number: the target utterance number if it starts a new dialogue, or the parent utterance number if it replies to a previous utterance. Seed 2: Seed 2 is another initial program. It differs from Seed 1 only in the output instruction. Instead of a single utterance number, Seed 2 requires two keys: a Boolean key indicating whether the target utterance starts a new dialogue and a key indicating the parent utterance number. Baseline: Baseline uses a reproduction of the prompt called Baseline in Takada and Mori (2026). It uses the same task instruction as Seed 1, represents each utterance in labeled JSON format, and uses the same output instruction as Seed 2. We treat Baseline as the strongest manually designed prompt for LLM based dialogue disentanglement in this setting and test whether DD-GEPA can surpass it. Optimum: Optimum is the optimized program obtained by DD-GEPA. Starting from Seed 1, Optimum is obtained by updating the task instruction, utterance representation, and output instruction once each in this order.
5.5 Hyperparameters Except for dataset construction (Section 5.6), all experiments use Qwen3-30B-A3B-Thinking2507 (Yang et al., 2025) as the LLM. The request parameters differ between (i) reply-to relation prediction and (ii) prompt update. For reply-to relation prediction, we set the temperature to 0 to ensure reproducibility in dialogue disentanglement. For prompt update, we follow GEPA and use temperature 0.6, top-p 0.95, and top-k 20 to encourage diverse improvement proposals. For reply-to relation prediction, we restrict the candidate parent utterances to the 50 preceding utterances. We use GEPA v0.023. Following Agrawal et al. (2026), we use 150 training instances, 300 validation instances, and a minibatch size of 3 for optimization. We omit the GEPA merge operation because its effectiveness was not clearly supported in the original study. 5.6 Construction of the DD-GEPA Dataset We construct a dataset of 450 instances for prompt optimization, where each instance is a reply-to re6
Table 1: Success rates under different LLM and prompt settings Method
Success rate (%)
Qwen3-30B Qwen3-30B Qwen3-30B GPT-5.2 (OpenAI, 2025)
Seed1 Seed2 Baseline Baseline
80.28 81.60 91.92 96.12