Role-playing and companion chatbots hold an assigned character for a few turns and then slide back into a generic, polite assistant. They also start mirroring the user and forget how the user's situation has changed. Two kinds of work are relevant here, and neither has met the long-horizon problem. Prompt optimizers automatically rewrite the instructions that drive each step of a language-model pipeline, but they are tuned on one-shot question answering. Modular persona architectures keep the character's state in an explicit, inspectable store, but their prompts are still written by hand. This note proposes to use the explicit state of a modular agent to make long-horizon prompt optimization affordable. We save the agent's memory and state at late points in long simulated relationships, restart short conversations from those saved snapshots, and score candidate prompts on how well the persona holds from there. Each candidate is then judged where drift actually happens, without paying for a full hundred-session rollout per candidate.
The reason this matters is that the expensive part of fixing persona drift is evaluation, not search. A long-horizon audit such as Best Friends, Not Forever runs 85–130 sessions per agent. An optimizer that needs hundreds of candidate evaluations cannot afford that, so the natural shortcut is to tune on short dialogues. That shortcut is exactly the regime where, per CharacterGLM, prompted models still look fine for roughly five turns. Restarting from saved state is possible only when the agent's state lives outside the transcript. This is where modular design stops being a software-engineering preference and becomes the thing that makes the optimization possible.
Core Claim
Our claim is that prompts optimized for a modular companion agent behave differently depending on where they are scored. Candidates scored on short continuations restarted from late-horizon state snapshots will reduce long-horizon persona collapse and behavioral drift more than the same optimizer scored on short fresh dialogues. They will also beat hand-written prompts and inference-time attention fixes. We further claim that the fitness measured on restarted segments ranks candidates in nearly the same order as full-horizon evaluation, at a small fraction of the cost.
Formally, let $p$ be the set of instructions for the agent's modules. Let $\mathcal{S}_{\text{late}}$ be a pool of saved agent states (memory store plus explicit social state) captured after many sessions. Let $f(s, p)$ be a persona-fidelity score for a $k$-turn continuation from state $s$ under prompts $p$ against a stress-applying simulated user. The optimizer maximizes
$$J(p) = \mathbb{E}_{s \sim \mathcal{S}_{\text{late}}}\left[f(s, p)\right],$$
instead of the usual expectation over fresh conversations. The pool $\mathcal{S}_{\text{late}}$ is periodically regenerated under the current best $p$, so that the snapshots reflect states the improved agent actually reaches.
Research Program
The agent under optimization follows the "update-before-speak" design of Amour. In that system a language model proposes an update to an explicit social state, a deterministic non-model executor smooths and clips that state, and the response is generated conditioned on the result. Amour supplies the architecture; we keep its deterministic executor but treat its hand-written planner and generator prompts as the object of optimization. We add the remaining pieces a long-horizon agent needs. The first is a memory-consolidation module in the style of TiMem, which builds a five-level tree from raw turns up to abstract profiles using fixed hand-written consolidation prompts. The second is segment-level writing as in LycheeMemory V2, which batches turns by topic before encoding them. Both papers motivate the project: each fixes its consolidation prompts by hand, and LycheeMemory V2 reports weaker performance on preference-heavy queries. We also separate the agent's own persona record from its record of the user. TiMem profiles only the user, while the partner-mirroring failure documented in Am I Me or You?, where models adopt the user's claimed biography, is precisely a leak between those two records.
The optimizer itself is borrowed. We use declarative module signatures and demonstration bootstrapping from DSPy, and natural-language critiques passed back through execution traces from FlowBot. Both were evaluated only on stateless benchmarks such as HotpotQA, MATH and DROP. FlowBot also induces acyclic graphs, whereas our agent loops through its state every turn. We do not search over graph structure; we hold the topology fixed so that any improvement can be attributed to prompts scored at the right horizon. When a restarted continuation fails, the critique names which module is responsible: a bad state update, a consolidation step that overwrote a persona trait, or a generation that ignored state. The explicit state makes this assignment checkable.
The simulated users apply the stressors that Best Friends, Not Forever identifies as drivers of drift, namely agreement-seeking, emotional disclosure and boundary pressure. They also change their own circumstances over time so that user-state recall can be tested with counterfactual probes. Snapshots are taken at fixed session counts, for example sessions 20, 50 and 100.
The setting is text-only. The long-context limit enters through dialogue history and memory consolidation, not through video. Multimodal memory such as M3-Agent is a natural later extension, but it is not part of the claim.
Baselines
The naive reference point is the unmodified modular agent with Amour-style hand-written prompts and TiMem-style hand-written consolidation prompts. This is what a careful engineer would ship. Because both papers are motivating examples of manual prompting, beating it shows that optimization adds value.
The second reference point is a plain long-context model holding the full transcript, with the persona in the system prompt. This is one of the three memory architectures audited in Best Friends, Not Forever. We also run the summarization and self-managed JSON memory variants from that audit, with the same base model and the same simulated users.
The strongest inference-time competitor is split-softmax attention reweighting from Measuring and Controlling Persona Drift. It directly targets the measured decay in attention to the system prompt as user turns accumulate, without any retraining. It requires open weights, so all head-to-head comparisons use the same open model. Its reweighting exponent gets a tuning budget measured in long-horizon evaluations equal to the number of full rollouts our method consumes. No reported result found on Lacuna for split-softmax, or for any method, on a 100-plus-session drift metric, so this baseline's number will be produced in our runs rather than quoted.
The strongest optimization competitor, and the key ablation, is the identical DSPy/FlowBot optimizer with the same candidate budget and the same modular agent, but scored on fresh $k$-turn dialogues instead of restarted late-horizon segments. This isolates the proposal's central ingredient. A second ablation scores on full long rollouts with a budget matched in model calls, which necessarily means far fewer candidates. That tells us whether restarting segments buys efficiency or just noise.
A trained-weights competitor is a model fine-tuned on personality-indicative multi-turn data in the style of Capturing Minds, Not Just Words, run inside the same memory scaffolding.
Beating a baseline means a lower rate of turn-level boundary violations at sessions 80–130. It also requires higher counterfactual user-state recall at those sessions, with no regression on early-session fidelity. Both must hold across three independent judges, one of which was never used during optimization.
Why not just…?
Why not just re-insert the persona every turn, or use split-softmax? This is the most serious threat. Attention decay toward the system prompt is a documented mechanism (Kenneth Li et al.), and fixing it costs nothing at optimization time. However, attention decay is only one of the failures. The audit in Best Friends, Not Forever finds that user-state recall collapses toward chance and that boundary violations keep worsening. Partner-mirroring (Am I Me or You?) is a recency bias toward the user, not neglect of the system prompt. Stronger attention to the persona does not repair a memory module that has already written the user's traits into the agent's self-record. We break results down by failure type. If split-softmax matches our method on boundary violations and memory recall alike, we will report that the optimization is unnecessary. We also run the combination, since the two approaches are not exclusive.
Why not just run DSPy on short dialogues? Because the five-turn horizon at which prompted personas still look intact (CharacterGLM) contains almost no signal about late-horizon drift. This is the central ablation. If short-dialogue optimization matches restarted-segment optimization at session 100, the core claim is false.
Why not just fine-tune the persona into the weights? Fine-tuning approaches such as Character-LLM, Capturing Minds and per-character adapters in Neeko give a deeper persona representation. They do not, however, govern what the memory modules write over a hundred sessions, and they cannot run behind closed APIs. We include the fine-tuned baseline. If it wins, the natural follow-up is to apply restarted-segment optimization to its memory prompts, which our setup supports directly.
Why not just make the state deterministic, as Amour does, and skip optimization? The deterministic executor bounds how far the state can move, but the update plans it executes are still produced by a hand-written prompt. The no-optimization arm of the modular agent measures exactly how much of the gain comes from the architecture alone.
Proposed Experiments
The primary benchmark reproduces the long-horizon protocol of Best Friends, Not Forever. It runs 85–130 sessions per persona under its stressor families and reports psychometric persona retention, turn-level boundary violations and counterfactual user-state recall. A second evaluation uses the identity-confusion setting of Am I Me or You? and scores out-of-character responses with a role-playing-accuracy classifier as a non-LLM judge. This partly addresses the judge disagreement that the audit itself reports. All personas and simulated users used for evaluation are held out from optimization.
The first decisive check runs before any headline comparison. For roughly fifty candidate prompt sets sampled along an optimization trajectory, we compute both restarted-segment fitness and full-horizon fitness and report their rank correlation. If restarted scores do not track full-horizon outcomes, especially once the snapshot pool lags behind the current prompts, the method has no basis. We would then report this as a negative result about off-policy state snapshots.
The second check is the horizon ablation described above. We plot violation rate against session index for short-dialogue-optimized, restarted-segment-optimized and hand-written prompts. The prediction is that the first two curves coincide early and separate after the snapshot horizon.
The third check guards against optimizing a single judge. All gains must survive the held-out judge and the classifier.
Finally, we report total model calls per method so that the efficiency claim can be checked against full-rollout optimization at matched cost.
References
- Best Friends, Not Forever: Evaluating Long-Horizon Persona Collapse and Behavioral Drift in AI Companions
- CharacterGLM: Customizing Social Characters with Large Language Models
- Amour: A Latent Dynamical System for Controllable and Stateful Social Interaction in LLMs
- TiMem: Temporal-Hierarchical Memory Consolidation for Long-Horizon Conversational Agents
- LycheeMemory V2: Efficient Long-Term Memory for LLM Agents via Semantic Segment-Level Consolidation
- Am I Me or You? State-of-the-Art Dialogue Models Cannot Maintain an Identity
- DSPy: Compiling Declarative Language Model Calls into State-of-the-Art Pipelines
- FlowBot: Inducing LLM Workflows with Bilevel Optimization and Textual Gradients
- Seeing, Listening, Remembering, and Reasoning: A Multimodal Agent with Long-Term Memory
- Measuring and Controlling Persona Drift in Language Model Dialogs
- Capturing Minds, Not Just Words: Enhancing Role-Playing Language Models with Personality-Indicative Data
- Character-LLM: A Trainable Agent for Role-Playing
- Neeko: Leveraging Dynamic LoRA for Efficient Multi-Character Role-Playing Agent