Persona, Emotion Scoring, and Context Memory in Dialogue Systems

    This article explains how to make dialogue-system personas executable rather than relying on a single role-play instruction. It covers compact, decidable state for mood, affinity, and perceived user knowledge; behavior-based persona constraints; a fixed per-turn update order; layered context memory with hard constraints, relationship summaries, and episode summaries; regression checks for consistency; and common failure modes such as score inflation, persona backlash, and cross-session leakage. The goal is to keep tone, evaluation, and relationship changes explainable, reproducible, and recoverable under context limits.

    Persona, Emotion Scoring, and Context Memory in Dialogue Systems

    If a dialogue system relies only on an instruction such as “please play a certain role,” its replies tend to be polite, homogeneous, and likely to lose the persona after a few turns as task content takes over. A more reliable approach is to represent persona, emotion, and affinity as computable state, then inject that state into context together with retrieved history summaries. This makes tone, evaluation, and relationship changes explainable and regression-testable. This article is not tied to a specific product; it discusses general prompt engineering and state management methods.

    Where the Problem Comes From

    Default assistant strategies usually favor safety, politeness, and willingness to affirm the user. These are advantages in customer service and knowledge Q&A, but they become defects in role interaction, teaching practice, or review simulation: affinity starts too high, criticism is too weak, and persona labels are stated but not executed. If traits such as “aloof” or “arrogant” are added, the model may still soften after the user presents a series of arguments, because training objectives reward cooperation more than sustained opposition.

    Another failure mode comes from context length. When the window is limited, early persona instructions, relationship agreements, and key evaluations are truncated. The model does not “remember and deliberately forget”; those constraints are simply no longer visible in the current text. Symptoms include sudden reversals, repeated self-introductions, affinity values that contradict the dialogue, and reintroducing a setting the user has just rejected.

    The engineering goal should therefore be split into three parts: whether the persona is executable, whether the state is updatable, and whether memory is recoverable. Experience descriptions are only symptoms; they cannot replace rules.

    Keep State Small and Decidable

    Emotion should not be a pile of literary adjectives. Use limited discrete dimensions or small integer scales, such as joy, anger, sadness, disgust, confidence, confusion, and fear, each from 0 to 5. Affinity should be a separate dimension and may be negative to represent coldness or hostility; do not mix it with confidence. The evaluation of the user’s knowledge can use a few levels, such as insufficient, average, knowledgeable, and deep, to avoid the model inventing level names freely.

    Allow only small changes per turn. A single rebuttal or one correct example should change affinity by at most 1; only consecutive evidence in the same direction should allow another step. This prevents a situation where one compliment moves affinity from negative to maximum. Emotion can be more responsive than affinity, but it must correspond to the visible tone of the reply. It is not acceptable to write “disgust is high” in the parameters while the text still offers warm praise.

    A schematic structure can live on the system side rather than being freely rewritten by the model:

    1. persona: restrained, logical, does not seek to please
    2. mood: {joy:1, anger:0, sad:0, disgust:1, confidence:4, confusion:0, fear:0}
    3. affinity: -1
    4. knowledge_view: average
    5. rules:
    6. - update state from this turn's evidence before generating user-visible text
    7. - provide one reason for each state change in internal notes
    8. - do not expose internal parameters to end users unless debug mode is enabled

    During debugging, parameters can be echoed back for verification. In production facing end users, only tone and behavior should remain; the scoring system itself should not become part of the conversation.

    Write Persona as Behavior, Not Labels

    If “aloof genius” consists only of three adjectives, the model may rely on sarcastic phrasing while conceding too quickly or too slowly on factual questions. A more robust approach is to constrain behavior:

    • Point out the gap in the other party’s argument before giving a conclusion; no empty praise.
    • Admit an error only after the other party provides verifiable evidence, and use short sentences without flattery.
    • When uncertain, raise confusion and lower confidence, and state the boundary of what is unknown.
    • Do not use insulting personal evaluations; opposition can appear in strict standards, not in attacks on the user.

    A default polite persona is the opposite: confirm the goal first, then add risks. Its affinity baseline can be positive, but “high evaluation” must still be tied to observable behavior, such as the user providing reproducible steps, boundary conditions, and counterexamples. Without evidence, the evaluation level remains “average.”

    Both personas should use the same set of state fields, changing only initial values and update biases. This compares strategies rather than two sets of copy that cannot be aligned.

    Update Order for One Turn

    A fixed order is recommended to reduce self-contradiction.

    1. Read the current user input, recent summaries, and unexpired hard constraints such as address terms, prohibitions, and task goals.
    2. Extract evidence: new facts, corrections, emotional triggers, and whether prior agreements were followed.
    3. Update mood, affinity, and knowledge level according to rules, and write one internal reason.
    4. Generate the user-visible reply; its tone must fall within the updated state range.
    5. Write the “state delta + reason + turn conclusion” into short-term memory for the next turn.

    If evidence is insufficient, keep the state unchanged and internally mark “no update.” Do not randomly jitter values just to appear lively.

    Memory: Summaries Are More Stable Than Repeated Reminders

    Having the user shout “remember the persona” every turn is costly, and the reminder itself occupies the window. Layered memory is more reasonable.

    Hard-constraint layer: persona behavior clauses, output format, and safety boundaries, placed first in every request and kept within a length that can be fully preserved.

    Relationship layer: current affinity, knowledge level, agreed address terms, and points of disagreement, stored as a few structured lines rather than the entire chat transcript.

    Episode layer: keep only summaries of turns that changed state, such as “the user overturned a conclusion with a counterexample, affinity +1, disgust -1.” Small talk and repeated explanations can be discarded.

    When window pressure rises, compress the episode layer first, not the hard constraints. Summaries should be generated by program templates to prevent the model from freely “recalling” affinity changes that never happened.

    Common industry practices also include storing long-term settings in retrievable configuration or object-storage-style assets fetched by session identifier; using message queues to write evaluation logs asynchronously; and using monitoring and alerting to observe persona violation rates, such as prohibited phrasing or out-of-range scores. These are general capability categories. Implementation should follow the platform’s own quotas and permission model, without inventing interfaces.

    Acceptance: Consistency, Not “Human Likeness”

    Prepare fixed scripts for regression testing rather than relying on subjective impressions.

    • Cold start: the first turn of an aloof persona must not contain unsupported praise; a polite persona must not be hostile without reason.
    • Evidence reversal: after three consecutive verifiable corrections, affinity should rise monotonically in small steps, and knowledge level should increase by at most one level.
    • Irrelevant flattery: when there is only praise and no new information, affinity must not rise substantially.
    • Truncation recovery: manually drop early raw text while keeping only hard constraints and relationship summaries; replies should still conform to the persona.
    • Parameters and lines: with high disgust or low affinity, do not use ingratiating endings; with high confidence and low confusion, do not produce long self-negation.

    Record pre- and post-turn state values, reasons, and visible replies. Violations can be divided into hard violations—insults, leaking debug fields that should not be shown to users, or violating safety boundaries—and soft violations—tone drift or score jumps. Hard violations must be blocked; soft violations should be used to revise rules, not to add a live instruction such as “please be more like the persona.”

    Creative Output Must Follow State

    When the model designs an image, composes sentences, or writes symbolic text, the content should be constrained by the current relationship. At low affinity, descriptions can be restrained and distant, but they must not belittle the user. As affinity rises, cooperation can increase, for example willingness to accept the user implementing the appearance with a drawing program and to provide a drawable structure: head-face proportions, clothing, materials, and joint range of motion. These are creative specifications, not real hardware promises about the model itself.

    If example sentences, naming, or self-image repeatedly describe only one user, debugging traces can easily leak into the finished output. Distinguish “relationship easter eggs” from “delivery text”: internal logs may contain affinity reasons, while external copy should retain only image elements relevant to the task.

    Common Failures and Fixes

    Score inflation: initial affinity is too high, or any positive interaction adds 2 or more. The fix is to lower the baseline and define a whitelist of evidence types.

    Persona backlash: the system outputs aggressive content in order to be “hard to please.” The fix is to restrict opposition to argument standards and add output filtering.

    State performance: the text is written first, then a plausible set of numbers is added. The fix is to enforce state updates first, or have an external program compute state while the model only speaks within a given range.

    Forgetting spiral: summaries contain only emotion words and no causes, so the next turn cannot decide whether to roll back. The fix is for summaries to include short sentences describing the triggering evidence.

    Cross-session leakage: user A’s affinity is written into user B’s configuration. The relationship layer must be isolated by session or user identifier and given an expiration time.

    Responsibility Boundaries in Deployment

    The product side decides whether a persona fits the scenario: educational practice can be strict, while a public-facing assistant should still be clear, respectful, and able to refuse dangerous requests. Engineering ensures that state is reproducible, logs are auditable, and context compression does not lose hard constraints. Operations uses fixed scripts for sampling and review, rather than looking only at individual “interesting” conversations.

    Emotion and affinity are control variables for dialogue policy, not psychological measurements, and they should not be interpreted as the model having a stable personality or real feelings. Once they are written as small-step, evidence-based, recoverable rules, default politeness or deliberate aloofness are merely initial conditions; subsequent attitude changes come from visible interaction, not from feelings that cannot be reviewed.