Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Dialogue state: apply slot updates, corrections and deletions

Last updated: 7 Oct 20265 min read
tutorial
AdvancedBy AITrove Editorial

A support conversation changes state over several turns. A later correction must replace an earlier slot without erasing the evidence trail.

Represent state explicitly

A refund conversation may track intent, order reference, requested action and confirmation status. Store each slot with value, source turn, confidence and validation state. Separate the user’s assertion from a verified account lookup. An order ID spoken earlier is not necessarily current after “Sorry, I meant ZX-82.” The state reducer needs set, clear and unchanged operations; treating every absent slot as clear would erase context on ordinary turns.

Interpret corrections in context

A turn can negate an earlier choice, revise a value or refer back with “that one.” Annotate the operation and its target slot before updating state. If the referent is ambiguous, ask a clarifying question and leave the previous value unconfirmed. Mention identity helps with references, while entity extraction supplies candidate IDs. Neither should silently authorize a refund.

Evaluate the whole conversation

Measure exact joint state at each turn, per-slot accuracy, correction success and harmful state persistence. A single early mistake can carry forward, so also score the immediate update independent of accumulated state. Split by full conversation and customer, not individual turns. Include interruptions, repeated values, mixed languages and agent handoffs. A state that looks correct at the final turn may have triggered a wrong action earlier.

Version the handoff

Package ontology, slot schema, reducer policy, model and validation rules. A schema change needs a migration or a reset with clear user communication. Keep an event log of state updates and reviewer corrections under restricted access. The handoff lesson turns state into a gated action, and the project tests a complete support exchange.

Implementation

python
def apply_slot_update(state, slot_name, operation, value=None):
    next_state = dict(state)
    if operation == "unchanged":
        return next_state
    if operation == "clear":
        next_state.pop(slot_name, None)
    elif operation == "set" and value is not None:
        next_state[slot_name] = value
    else:
        raise ValueError("invalid slot update")
    return next_state

first = apply_slot_update({}, "order_id", "set", "ZX-47")
corrected = apply_slot_update(first, "order_id", "set", "ZX-82")
assert corrected["order_id"] == "ZX-82" and first["order_id"] == "ZX-47"

Performance and operating cost

Copying a state dictionary is O(s) time and space for s slots; this is acceptable for a small support ontology and preserves previous snapshots for audit. A long-running conversation may accumulate more event records than active slots, so cap or archive history under retention rules without losing correction provenance. Model inference and clarification turns dominate user-facing latency.

Common Mistakes

  • Clearing a slot because the next turn did not mention it.
  • Keeping an old order reference after an explicit correction.
  • Treating a model-extracted value as account-verified.
  • Scoring only the final state while ignoring harmful interim decisions.

Read next

Continue the workflow: Dialogue handoff: gate actions on verified state and uncertainty.

Continue the workflow: Speech acts: requests, reports and commitments in support dialogue.

ai-data
natural-language-processing
Storage details