MemRole: From Memories to Decisions for Long-Horizon Reasoning in Role-Playing Agents
Organizations: Beihang University · Communication University of China · Zhejiang University · Guangxi University ·
Abstract
LLM-based role-playing agents are fluent at imitating a character's style, yet struggle to make role-consistent decisions over long narrative horizons. Such decisions are shaped by experiences spanning many prior scenes, which are often partial and may point in different directions. Existing methods inject cross-scene memories as context, but do not reason about how past events shape a character's current motivations and behavior. We propose MemRole, a framework that makes this memory-to-decision process explicit. It introduces Long-Horizon Memory Thinking (LHMT), a reasoning schema that decomposes hidden reasoning into context understanding, memory activation, and response strategy planning, trained on a novel-derived dataset whose character-grounded, timeline-constrained memory pools limit each character to what it could plausibly know at the current narrative point. Beyond supervised fine-tuning, we propose Self-Refining On-Policy Self-Distillation (SR-OPSD): the model critiques its own rollouts against the reference under a data-driven rubric, and a critique-conditioned teacher view of the same model distills token-level guidance back into the policy. MemRole-32B improves over its backbone by 15.2 points on memory-grounded role-playing, performs on par with frontier LLMs such as GPT-5.4, and achieves the best character-motivation recognition accuracy on CroSS-MR.
Figures & tables
| Model | MemRole Test | Life Choice | Cross-MR | |||||||
| SC | AN | CF | SQ | MAQ | RC | Avg. | ACC | +motivation | ACC | |
| Claude-4.6-Opus | 75.26 | 63.11 | 69.84 | 73.77 | 72.95 | 80.02 | 72.49 | 85.14 | 98.43 | 65.18 |
| Gemini-3-Pro | 74.33 | 45.98 | 63.57 | 77.22 | 64.53 | 73.86 | 66.58 | 78.77 | 97.41 | 63.54 |
| DeepSeek-v4-Pro | 66.37 | 59.76 | 61.14 | 70.96 | 69.78 | 70.33 | 66.39 | 74.58 | 97.32 | 63.77 |
| GPT-5.4 | 64.76 | 55.28 | 57.95 | 70.78 | 65.89 | 72.01 | 64.45 | 73.69 | 97.35 | 67.12 |
| MemRole-32B | 61.12 | 51.97 | 56.73 | 70.82 | 72.98 | 71.87 | 64.25 | 79.11 | 97.72 | 69.83 |
| (a) Prompting-level comparison | ||||
| Model | Reasoning Mode | Dialogue Avg. | MAQ | RC |
| Qwen3-8B | Direct Response | 42.44 | 42.03 | 42.38 |
| Generic CoT | 43.93 | 44.26 | 43.11 | |
| LHMT Prompting | 43.87 | 44.78 | 44.34 | |
| Qwen3-32B | Direct Response | 48.50 | 45.93 | 54.38 |
| Generic CoT | 49.85 | 48.46 | 58.81 | |
Appendix figures & tables19 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Source | Memory Representation | Knowledge-boundary Constraint | Decision Focus | Reasoning Supervision |
| RoleLLM ( Wang et al., 2024 ) | Scripts / GPT-gen. | Profile + synthetic QA | – | ✗ | None |
| DITTO ( Lu et al., 2024 ) | Wikidata (self-aligned) | Model-internal knowledge | – | ✗ | None |
| CoSER ( Wang et al., 2025a ) | Novels | Conversations / plots / exp. | ✗ | ✗ | None |
| HER ( Du et al., 2026 ) | Novels (CoSER-derived) | Dialogue history + scenario | ✗ | ✗ | Dual-layer thinking |
| PsyMem ( Cheng et al., 2026 ) | Novels | Character / event graph | ✗ | ✗ | None |
| LifeChoice ( Xu et al., 2025 ) | Novels | Preceding context | Partial | Choice-level | None |
| Split | Novels | Characters | Scenes | Turns | Turns/Scene | Memories/Turn |
| Train | 64 | 1,755 | 13,172 | 161,027 | 12.22 | 0.722 |
| Test | 11 | 245 | 1,672 | 20,110 | 12.03 | 0.710 |
| Total | 75 | 2,000 | 14,844 | 181,137 | 12.20 | 0.721 |
| Activated Memories | Count | Percentage |
| 0 | 113,687 | 62.8% |
| 1 | 23,590 | 13.0% |
| 2 | 28,432 | 15.7% |
| 3+ | 15,428 | 8.5% |
| Total | 181,137 | 100.0% |
| Memory Effect Pattern | Count | Percentage |
| single | 23,590 | 34.97% |
| aligned | 35,424 | 52.52% |
| opposed | 3,683 | 5.46% |
| mixed | 4,753 | 7.05% |
| Total | 67,450 | 100.00% |
| Stones from the River (From Test Set) | |
| Character | Trudi Montag |
| Topic | Comforting Konrad before his wartime relocation. |
| Plot Summary | Leo Montag prepares a rare formal dinner for Trudi, Eva, Frau Neimann, and Konrad during wartime scarcity. During the meal, he reveals that Konrad and his mother must leave that night for a safer hiding place. Trudi has known this news in advance but has hidden it from Konrad to avoid frightening him. As the departure approaches, she uses the invented story of the Island of the Little People to comfort him while privately struggling with grief, anger, and attachment. |
| Scenario | The scene takes place in Leo Montag’s home, including the kitchen and attached pay-library. The atmosphere is bittersweet and tense: the dinner is warm and carefully prepared, but it is also a farewell. Konrad asks why the imagined island in Trudi’s story has changed and why its beautiful world has collapsed. The question forces Trudi to respond without exposing the real danger behind his relocation or the violence that makes it necessary. |
| Character Profile | Trudi Montag Trudi is a Burgdorf pay-library keeper whose role combines storytelling, radical kindness, and protective care for vulnerable people. Her months of caring for Konrad have formed a strong maternal attachment, but she must suppress her grief to protect him emotionally. Konrad Neimann Konrad is a young Jewish boy hidden in the Montag home with his mother. He relies on Trudi’s stories for comfort and asks direct questions when he senses that adults are concealing painful truths. |
| Activated Memories | Memory 1: Story framework Trudi recalls the origin of the magical-island story, which gives her a familiar imaginative frame for comforting Konrad without naming the danger directly. Memories 2–4: Protective care These memories cover Trudi’s first discovery of Konrad and his mother hiding from Nazi persecution, her decision to shelter them, and her repeated use of stories and games to calm Konrad during their stay. Memories 5–9: Wartime danger These memories remind Trudi that hidden fugitives face mortal danger if discovered. Their aligned effect pushes her to withhold the full factual truth, suppress her own grief, and respond in a way that protects Konrad’s emotional safety. |
| Hyperparameter | Value |
| Backbone model | Qwen3-8B |
| Maximum sequence length | 8192 |
| Learning rate | 1.0e-4 |
| Batch size (Global) | 128 |
| Number of epochs | 8 |
| Optimizer | AdamW (DeepSpeed ZeRO-3) |
| Hyperparameter | Value |
| Initial policy | |
| Critique / teacher model | Frozen |
| Rollout sampling temperature | 1.0 |
| Maximum rollout length | 2048 |
| Learning rate | 1.0e-5 |
| Batch size (Global) | 128 |
| Critique Model | Dialogue | Memory |
| Qwen3-8B | 51.3 | 54.1 |
| w/o general-data mixture | 49.4 | 51.9 |
| Frozen | 51.7 | 54.8 |
| Qwen3-32B | 52.2 | 55.4 |
| Category | Rubric dimension | Definition | Typical failure |
| Memory | Memory-need misjudgment | Fails to correctly decide whether the current turn requires consulting the memory pool. | Uses memory when the current context is sufficient, or ignores memory when past events are needed. |
| Memory | Missing relevant memory | Fails to activate a memory that is necessary for explaining the character’s current decision. | Omits a prior confrontation or promise that should constrain the response. |
| Memory | Irrelevant memory injection | Activates memory entries that are unrelated to the current decision or unsupported by the input. | Grounds the response in an unrelated past scene. |
| Memory | Multi-memory effect integration error | Fails to integrate aligned, conflicting, or complementary effects across multiple activated memories. | Treats conflicting memories as independently supportive, or ignores their combined effect. |
| Character | Motivation misalignment | Misidentifies the character’s current motivation, constraint, or behavioral tendency. | Makes a cautious character act boldly without contextual support. |
| Character | Character voice inconsistency | Produces a response whose style, register, emotional tone, or manner of expression is inconsistent with the character. | Uses overly modern, generic, or emotionally mismatched phrasing. |
| Model | Avg. Human Score | Win Rate (%) |
| Qwen3-8B | 4.57 | 31.4 |
| Qwen3-32B | 5.21 | 38.5 |
| CoSER-70B | 6.05 | 42.1 |
| MemRole-8B | 6.34 | 50.1 |
| HER-RL | 6.78 | 65.6 |
| MemRole-32B | 7.02 | 72.3 |
| Target | Samples | Agreement | ||
| Responses | 300 | 89.4% | 0.77 | 0.81 |
| LHMT Traces | 300 | 90.2% | 0.80 | 0.83 |
| Model | CoSER Benchmark | ||||
| Avg | SC | AN | CF | SQ | |
| Claude-4.6-Opus | 62.10 | 62.71 | 64.21 | 58.33 | 63.14 |
| Gemini-3-Pro | 61.92 | 65.85 | 61.42 | 58.14 | 62.27 |
| GPT-5.4 | 60.41 | 62.95 | 53.21 | 60.13 | 65.35 |
| Gemini-2.5-Pro | 61.19 | 61.05 | 62.83 | 57.41 | 63.45 |
| MemRole-32B | 60.02 | 60.50 | 53.20 | 56.57 | 69.79 |
| Model | Context | Memory | Plan |
| Base + LHMT prompt | 2.68 | 2.12 | 2.49 |
| SFT warm-up | 3.49 | 2.88 | 3.10 |
| SR-OPSD | 4.12 | 4.04 | 4.18 |
| A reference prompt for LHMT trace generation. |
| ⬇ You are a CoT generator for a ShareGPT role - playing dataset . Given the reference context and the original assistant target , generate a hidden < think > analysis and then append the original assistant target exactly unchanged . === REFERENCE CONTEXT === { reference_content } === ORIGINAL ASSISTANT TARGET === { target_assistant_content } === PREVIOUS ATTEMPT AND VALIDATOR FEEDBACK ( ignore if absent ) === { previous_attempt_feedback } Use previous feedback only to avoid recurring errors . Do not copy failed wording . The < think > block must contain exactly three natural paragraphs : Paragraph 1: Analyze the focal character ’ s current situation , immediate interaction pressure , and only the profile traits relevant to this turn . Paragraph 2: Decide whether the scene memory pool is needed . The scene memory pool refers only to memories listed under Relevant Past Memories , not the character profile . If memory is needed , identify the necessary memory ids , explain why the current context is insufficient , and describe the behavioral pressure of each activated memory . When multiple memories are used , determine whether their effects are aligned , opposed , or mixed , and explain their combined effect . If memory is not needed , explain why the current context and profile are sufficient . Paragraph 3: Describe the response policy , including the appropriate use of speech , action , or inner thought , the tone , what should be revealed or withheld , and what should be avoided . Rules : 1. Use third - person analysis rather than first - person narration . 2. Use exactly three natural paragraphs without headings , bullets , numbered steps , or explicit reasoning tags . 3. Ground every claim in the reference context , listed memories , character relationships , or the original target . 4. Do not invent facts or use future information unavailable to the character . 5. Use the original target only to infer the intended stance and response policy . Do not quote , closely paraphrase , or pre - announce its distinctive wording , actions , or thoughts inside < think >. 6. Distinguish stable profile knowledge from episodic scene memories . 7. After </ think >, append the original assistant target exactly unchanged . Return only : < think > Natural paragraph 1. Natural paragraph 2. Natural paragraph 3. </ think > { target_assistant_content } |
| A Reference Prompt for LHMT trace Validation (Part 1). |
| ⬇ You are a validator for hidden CoT generated for a ShareGPT role - playing memory - activation dataset . You will receive : (1) the reference context , (2) the original assistant target , and (3) a generated assistant value containing a < think > block followed by the target . === REFERENCE CONTEXT === { reference_content_with_memories } === ORIGINAL ASSISTANT TARGET === { target_assistant_content } === GENERATED ASSISTANT VALUE === { generated_reasoning } Determine whether the generated < think > is valid supervision for current - turn memory - aware role - playing . Check the following : 1. Structure - There is exactly one < think > block containing three natural paragraphs . - The assistant target after </ think > exactly matches the original target . - The reasoning contains no headings , bullets , numbered steps , or explicit reasoning tags . 2. Grounding and temporal validity - Every claim is grounded in the profile , current scenario , dialogue prefix , listed memories , character relationships , or original target . - The reasoning contains no fabricated facts or future information unavailable to the character at the current turn . 3. Memory decision - Independently determine whether the listed scene memory pool is needed . - Do not treat character - profile information as scene memory . - When memory is needed , verify the selected memory ids and explain the behavioral pressure of each memory . - For multiple activated memories , classify their combined effect as aligned , opposed , or mixed . - When memory is not needed , verify that the current context and profile are sufficient . 4. Target leakage - The reasoning may use the target to infer the intended stance and response policy , but must not quote , closely paraphrase , or pre - announce its distinctive wording , actions , thoughts , or withheld information . 5. Training usefulness - The reasoning clearly explains the current information need , memory relevance , and response policy . - It is not generic or merely a restatement of the target . |
| A Reference Prompt for LHMT trace Validation (Part 2). |
| ⬇ Return ONLY a JSON object , with no preamble or explanation outside JSON : { " pass ": true | false , " memory_analysis ": { " need_scene_memory_pool ": true | false , " memory_ids ": [" Memory N ", "…"], " profile_needed ": true | false , " current_context_sufficient ": true | false , " effect_pattern ": " none " | " single " | " aligned " | " opposed " | " mixed ", " memory_effects ": [ { " memory_id ": " Memory N ", " direction ": " supports_response " | " opposes_response " | " constrains_response " | " complicates_response " | " contextualizes_response ", " behavioral_pressure ": " What this memory pushes the character toward or away from in the current turn ." } ], " net_effect ": " The combined behavioral effect of the activated memories ; empty if no memory is activated ." }, " issues ": [ { " severity ": " critical " | " major " | " minor ", " type ": " structure " | " target_mismatch " | " source_grounding " | " current_turn_boundary " | " future_knowledge_leakage " | " withheld_information_leakage " | " target_wording_leakage " | " memory_decision " | " memory_effect_analysis " | " profile_memory_confusion " | " answer_leakage " | " training_usefulness ", " message ": " A concrete description of the problem ." } ], " revision_feedback ": " Concise and actionable revision guidance ; empty if pass is true ." } Always provide your best independent memory analysis , even when pass is false . Severity : - critical : invalid structure , target mismatch , unsupported or future information , hidden - information leakage , or an incorrect memory - needed decision ; - major : incorrect or incomplete memory use , profile - memory confusion , target leakage , or an unclear response policy ; - minor : limited style or specificity issues that do not change correctness . If all checks pass , return pass = true , issues =[], and revision_feedback ="". |
| A Reference Prompt for Critique Generation in OPSD. |
| You are a critique expert for long-horizon memory reasoning in role-playing agents. Your task is to identify weaknesses in a model-generated reasoning trajectory by comparing it with a privileged reference, using a structured multi-dimensional rubric. === INPUTS === Current input : – Dialogue context : {dialogue_context} – Character profile : {character_profile} – Memory pool : {memory_pool} Model-generated trajectory : – LHMT trace : {generated_trace} – Role-playing response : {generated_response} Reference trajectory (PRIVILEGED – used for grounding only): – LHMT trace : {reference_trace} – Role-playing response : {reference_response} Rubric : {rubric_dimensions_with_weights} === TASK === Compare against , guided by rubric , and identify the rubric dimensions where meaningfully deviates from . For each deviation, produce a structured diagnosis with: 1. rubric_dimension – which dimension from this deviation belongs to. 2. severity – “high” | “medium” | “low”, jointly determined by the rubric weight and the magnitude of deviation. 3. specific_failure – concrete description of what did wrong (citing ’s content is safe; is the student’s own rollout). 4. improvement_direction – abstract guidance on what the model should do differently, at the level of reasoning pattern, memory usage, or response policy. 5. anchor_constraints – character-level invariants extracted from that must be preserved (traits, relational facts, decision stance, tone), expressed abstractly. Cover (LHMT trace), (visible response), and their correspondence – whether faithfully executes what plans (memories activates should be reflected in ; response policy states should be followed by ). Deviations may occur in context understanding, memory activation, response strategy planning, surface response, or trace-response correspondence. === CRITICAL CONSTRAINTS (surface-leakage prevention) === The critique will be used as privileged supervision for the student model. The student must not be able to reconstruct ’s exact wording. Therefore: – DO NOT quote, paraphrase, or reproduce ’s specific surface wording ( ’s exact sentences, ’s exact phrases, distinctive word choices). – Refer to ONLY at the level of: (a) reasoning patterns (“the reference activates Memory 2 and reasons about its denial implication”), (b) decision logic (“the reference adopts a reluctant-denial stance”), (c) character-level invariants (“preserve honest-denial pattern, short reply length”), or (d) rubric-dimension properties. – Quoting is fine – it is the student’s own rollout. – improvement_direction must NEVER contain the specific surface form uses. E.g., “should explicitly activate Memory 2 to ground a short denial” – NOT “should say ‘I didn’t put my name in the Goblet”’. === OUTPUT FORMAT === Return ONLY a JSON array. No preamble, no markdown fence, no commentary outside the array. If has no significant deviations, return [] . [ { "rubric_dimension": "<dimension name from R>", "severity": "high | medium | low", "specific_failure": "<what did wrong; may cite ’s content>", "improvement_direction": "<abstract direction; NO surface wording>", "anchor_constraints": "<abstract character/relational invariants from >" } ] Order entries by severity (high low). At most 6 entries; focus on the most consequential deviations. |
Large Language Model-Based Role-Play Simulation
Large language model-based role-play simulation creates interactive agents that portray people, characters, or users for training, testing, and research.
See all 118 papers