# Memory and context

> Model the data available before, during, and after a run so implementation agents preserve variable names and never confuse context with durable storage.

{/* Generated by scripts/sync_docs_handbook.mjs from the preserved in-app docs. */}

Menace Voice context is run-scoped. It personalizes a conversation and captures its result, but it is not a general-purpose customer database or durable memory layer. Keep the authoritative customer record in your system and move only the fields needed for the current conversation across the boundary.

## Use the context model precisely

- initial_context contains values known before the call. It can come from an API trigger, campaign CSV, telephony data, test settings, or a pre-call fetch.
- Template variables render initial-context values into prompts. Agent prompts use &#123;&#123;field&#125;&#125;; webhook payloads use &#123;&#123;initial_context.field&#125;&#125;.
- gathered_context contains typed values extracted from the transcript by Agent or End Call nodes. It is available in the completed run and webhook templates, not later Agent prompts.
- Tool results are live turn data. Use them to answer the current question; persist any durable change in the external system that owns it.
- Knowledge documents are workspace resources attached by document UUID. They provide reference text, not caller-specific mutable state.

## Preserve variable contracts during edits

```text
Input
  initial_context.customer_name: string
  initial_context.account_id: string

Prompt references
  {{customer_name}}
  {{account_id}}

Output
  gathered_context.resolution: string
  gathered_context.callback_requested: boolean
```

When an implementation assistant renames a variable, it must update every producer and consumer: API or campaign input, pre-call response, prompt template, extraction definition, webhook payload, and downstream handler. If the request does not require a rename, preserve the existing key exactly.

## Minimize what enters the run

- Pass the account ID and relevant status, not an entire CRM record.
- Exclude passwords, access tokens, payment credentials, private notes, and fields the conversation cannot use.
- Use a pre-call fetch when caller identity must be resolved from the inbound caller and called numbers before the greeting.
- Use a tool when freshness matters at the moment of the question, especially for availability, balances, or mutable order state.
- Define how the agent handles missing, stale, or conflicting values instead of silently choosing one.

> **Protect the boundary**
>
> Credentials belong in Menace Voice credential storage or server-side configuration. They must never be written into workflow prompts, initial context, tool arguments generated by the model, webhook bodies, or implementation-agent handoff notes.

For the two supported MCP directions and their different trust boundaries, continue to [Use the MCP bridge safely](/handbook/agents/mcp-bridge).
