Summarize long-term memories with Summary Views

Create owned summaries of long-term memories, refresh them, and read text or structured results.

A Summary View turns selected long-term memories into a reusable text or structured summary. For example, a travel assistant can maintain a compact profile instead of adding every matching memory to each model request.

A definition specifies the sources, filters, grouping, output, and refresh policy. A partition is one materialized result for an exact combination of grouping values. An ungrouped definition has one result. Results are derived data; they do not enter long-term-memory search or replace the source records.

Summary Views use long-term memories. Automatic summarization summarizes conversation events within a session. The supported Summary View source is LONG_TERM. Document-managed MemoryETL records are excluded from Summary View sources.

Prepare the service and identity

Summary Views are available in Redis Cloud and enabled in self-managed deployments. For self-managed model and capacity settings, see Configure Summary Views.

These examples continue from the quickstart. Load the same .env connection values and reuse its user ID. Expand an example to copy a complete program that connects for you.

Each run repeats every write in the program. Session-event writes and memory creates with a new idempotency key add new records, so run cleanup or change the identifiers before rerunning.

The server assigns the definition's immutable ownerId from the caller's authenticated user ID. A create request cannot supply an owner field.

On a self-managed store with ownership enforcement enabled, creating a view requires an authenticated user ID, including when an agent key is used. Use delegated user identity and send the user token on every Summary View request. Pass http_headers={"X-Iris-User-Token": user_token} to each Python call, or add -H "X-Iris-User-Token: $USER_TOKEN" to each cURL request. The verified user becomes the owner, so filter sources by that user's ID.

On a self-managed store with ownership enforcement disabled, agent keys without a user can create, refresh, and read views of either visibility. ownerId is empty when the caller has no authenticated user ID. Check the store's effective ownership policy before choosing a visibility.

Choose private or shared visibility

On self-managed stores with ownership enforcement enabled:

Visibility Who can read Sources
PRIVATE (default) The definition owner. The owner's personal and store-authorized shared memories, narrowed by the definition's filters.
SHARED Callers with store read access. The owner retains lifecycle control. Shared memories only. Personal records cannot be published through a shared view.

Shared does not mean a particular team. Enforce team membership in your backend or use separate stores and grants.

With ownership enforcement disabled, every caller with store read access can read a PRIVATE view. Both PRIVATE and SHARED views can include personal memories. Your backend must authorize access to personal data. A view records its source-access policy at creation. Replace views whose policy differs from the store's effective policy after a change. Keep the server and worker configuration aligned.

Create, refresh, and read a view

These examples create one private profile for the quickstart user, request a full refresh, and poll its result. First create ordinary long-term memories for that user. For more ways to write them, see Create a custom memory directly:

memory.remember("The user is vegetarian and prefers spicy food.", owner=OWNER_ID)
memory.remember("The user wants to visit Tokyo and Kyoto next month.", owner=OWNER_ID)
const seeded = await memory.bulkCreateLongTermMemories({
  idempotencyKey: crypto.randomUUID(),
  memories: [
    { memoryId: crypto.randomUUID(), text: "The user is vegetarian and prefers spicy food.", ownerId: OWNER_ID },
    { memoryId: crypto.randomUUID(), text: "The user wants to visit Tokyo and Kyoto next month.", ownerId: OWNER_ID },
  ],
});
for (const error of seeded.errors ?? []) console.log("Not created:", error);
jq -n --arg owner "$OWNER_ID" --arg key "$(uuidgen)" '{
  memories: [
    {memoryId: "example-diet", ownerId: $owner, text: "The user is vegetarian and prefers spicy food."},
    {memoryId: "example-trip", ownerId: $owner, text: "The user wants to visit Tokyo and Kyoto next month."}
  ],
  idempotencyKey: $key
}' > memories.json
curl --fail-with-body --silent --show-error \
  -X POST "$MEMORY_API/memories" \
  -H "Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY" \
  -H 'Content-Type: application/json' --data-binary @memories.json | jq .

Create the view and save its ID for later requests:

view = memory.client.create_summary_view(
    name="example-travel-profile",
    source=models.SummaryViewSource.LONG_TERM,
    visibility=models.SummaryViewVisibility.PRIVATE,
    group_by=[],
    filter_={"owner_id": {"eq": OWNER_ID}},
    output={
        "format_": "TEXT",
        "instructions": "Summarize the travel preferences in these memories.",
    },
    refresh_policy={"mode": "MANUAL"},
)
view_id = view.view_id
print("View ID:", view_id, "owner:", repr(view.owner_id))
const view = await memory.createSummaryView({
  name: "example-travel-profile",
  source: "LONG_TERM",
  visibility: "PRIVATE",
  groupBy: [],
  filter: { ownerId: { eq: OWNER_ID } },
  output: {
    format: "TEXT",
    instructions: "Summarize the travel preferences in these memories.",
  },
  refreshPolicy: { mode: "MANUAL" },
});
const viewId = view.viewId;
console.log("View ID:", viewId, "owner:", view.ownerId);
jq -n --arg owner "$OWNER_ID" '{
  name: "example-travel-profile",
  source: "LONG_TERM",
  visibility: "PRIVATE",
  groupBy: [],
  filter: {ownerId: {eq: $owner}},
  output: {format: "TEXT", instructions: "Summarize the travel preferences in these memories."},
  refreshPolicy: {mode: "MANUAL"}
}' > view.json
VIEW_ID=$(curl --fail-with-body --silent --show-error \
  -X POST "$MEMORY_API/summary-views" \
  -H "Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY" \
  -H 'Content-Type: application/json' --data-binary @view.json | jq -er .viewId)
echo "View ID: $VIEW_ID"

Request a full refresh. Creation and refresh are asynchronous; their responses do not contain generated output:

accepted = memory.client.refresh_summary_view(
    view_id=view_id, target=models.SummaryViewRefreshTarget.FULL,
)
print("Refresh accepted:", accepted.accepted)
const refresh = await memory.refreshSummaryView(viewId, { target: "FULL" });
console.log("Refresh accepted:", refresh.accepted);
curl --fail-with-body --silent --show-error \
  -X POST "$MEMORY_API/summary-views/$VIEW_ID/refresh" \
  -H "Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY" \
  -H 'Content-Type: application/json' --data '{"target": "FULL"}' | jq .

Poll the result until it is ready. A successful refresh with no matching sources returns EMPTY:

Status = models.SummaryViewResultStatus
for _ in range(60):  # generation runs in the background
    result = memory.client.get_summary_view_result(
        view_id=view_id, include_source_memory_ids=True,
    )
    if result.status == Status.FAILED:
        raise RuntimeError(f"Refresh failed: {result.error_code}")
    if result.status == Status.EMPTY:
        print("No matching source memories.")
        break
    if result.status == Status.READY and not result.stale and result.value is not None:
        print(result.value.text)
        print(f"{result.summarized_memory_count} of {result.source_memory_count} memories,",
              "truncated:", result.truncated)
        break
    time.sleep(5)
else:
    raise TimeoutError(f"Continue polling view {view_id}")
for (let attempt = 0; ; attempt += 1) {
  const result = await memory.getSummaryViewResult(
    viewId, undefined, undefined, undefined, undefined, true,
  );
  if (result.status === "FAILED") throw new Error(`Refresh failed: ${result.errorCode}`);
  if (result.status === "EMPTY") {
    console.log("No matching source memories.");
    break;
  }
  if (result.status === "READY" && !result.stale && result.value && "text" in result.value) {
    console.log(result.value.text);
    console.log(`${result.summarizedMemoryCount} of ${result.sourceMemoryCount} memories, truncated: ${result.truncated}`);
    break;
  }
  if (attempt === 59) throw new Error(`Continue polling view ${viewId}`);
  await new Promise((resolve) => setTimeout(resolve, 5_000));
}
for _ in $(seq 60); do  # generation runs in the background
  RESULT=$(curl --fail-with-body --silent --show-error --get \
    "$MEMORY_API/summary-views/$VIEW_ID/result" \
    -H "Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY" \
    --data-urlencode 'includeSourceMemoryIds=true')
  case "$(jq -r .status <<< "$RESULT")" in
    FAILED) jq . <<< "$RESULT"; exit 1 ;;
    EMPTY) echo "No matching source memories."; break ;;
    READY) if jq -e '.stale == false and .value != null' <<< "$RESULT" > /dev/null; then
        jq '{text: .value.text, sourceMemoryCount, summarizedMemoryCount, truncated}' <<< "$RESULT"
        break
      fi ;;
  esac
  sleep 5
done

Text output uses value.text; structured output uses value.data. Python output configuration uses format_ and schema_, serialized as format and schema. Do not assume every result has a value.

Handle asynchronous result states

Status Application behavior
COLD No result is stored for this group. It may not have been generated yet, or it may have been evicted.
PENDING Work is queued. Previous output may be withheld because its sources changed or became inaccessible.
READY A value is available. Check stale and coverage fields.
EMPTY No sources match. There is no generated value.
REFRESHING New work is running. A last good value can remain.
FAILED Inspect errorCode. A last good value may remain, or value may be absent.

stale is independent of status. It compares the result with the current definition and source changes. Decide whether to use a last good stale value, wait, or fall back to direct recall. Do not turn an absent value into an empty summary.

Result reads validate contributing source records. Deleted, changed, or newly inaccessible sources can cause old output to be withheld and repair to be requested. Repair is asynchronous; an old value need not remain available.

Track refresh progress

A result can include refresh while a newer attempt is outstanding. Use value and stale to decide whether to serve the cached result. Use refresh.status to inspect the attempt:

Status Meaning
QUEUED Work is waiting for a worker.
RUNNING A worker holds the refresh lease.
INTERRUPTED The worker's lease expired and another attempt can recover the work.
FAILED The last attempt failed. Inspect the result's error and retry as appropriate.

lastHeartbeatAt shows worker activity. lastProgressAt updates as the worker processes sources and generates output. If a terminal failure leaves newer changes pending, a continuous view picks them up during reconciliation. For a manual view, request another refresh after addressing the failure.

Repeated refresh requests for the same partition share a queued job. Changes during a build can queue one follow-up after it succeeds. An immediate manual refresh can bring a delayed job forward. A job that is already retrying keeps its backoff.

Filter and group sources

Use filter for owners, sessions, stable namespace IDs, topics, memory types, creation times, and typed attributes. filter.op defaults to ALL; ANY combines optional filters with OR. Exact partition scope, time windows, and self-managed ownership checks apply independently. Use namespaceId to filter by namespace.

groupBy accepts up to four distinct fields: ownerId, sessionId, namespaceId, and memoryType. A result read or target: PARTITION refresh must supply exactly those fields. Missing or extra scope fields are invalid. groupBy: [] creates a singleton; omit all scope fields when reading it.

For groupBy: ["ownerId", "namespaceId"], use this partition refresh body:

{
  "target": "PARTITION",
  "scope": {"ownerId":"<user-id>","namespaceId":"<namespace-id>"}
}

Send the same scope as query parameters on result reads. target: FULL reconciles current and previous partitions.

evictionPolicy.maxPartitions bounds grouped results within the deployment limit. Grouped views use the operator's partition limit when the policy is omitted; singleton views omit it. Matching source mutations make a scope recent; reads do not. Evicted scopes can return COLD.

timeWindowSeconds sets a rolling window for source selection. The default time basis, createdAt, uses the time when Agent Memory stored each memory. The window only affects which memories the view uses.

Set "timeBasis": "eventTime" when you create the view and include a timeWindowSeconds value. For example, use 1209600 for a 14-day window. This keeps historical session imports out of a recent view. Agent Memory ranks eligible memories by event time before applying source limits.

Create and refresh a 14-day event-time view. The example reads the result once to inspect refresh progress.

from redis_iris.agent_memory import AgentMemory

memory = AgentMemory.from_env()

view = memory.client.create_summary_view(
    name="example-recent-travel",
    source="LONG_TERM",
    visibility="PRIVATE",
    group_by=[],
    filter_={"owner_id": {"eq": "quickstart-user"}},
    output={"format_": "TEXT", "instructions": "Summarize recent travel preferences."},
    refresh_policy={"mode": "MANUAL"},
    time_basis="eventTime",
    time_window_seconds=1209600,
)
memory.client.refresh_summary_view(view_id=view.view_id, target="FULL")
result = memory.client.get_summary_view_result(view_id=view.view_id)
if result.refresh:
    print(result.refresh.status, result.refresh.last_progress_at)
print("Result status:", result.status, "Stale:", result.stale)
import { AgentMemory } from "@redis-iris/agent-memory";

const memory = new AgentMemory({
  serverURL: process.env.IRIS_AGENT_MEMORY_URL!,
  storeId: process.env.IRIS_AGENT_MEMORY_STORE_ID!,
  apiKey: process.env.IRIS_AGENT_MEMORY_API_KEY!,
});

const view = await memory.createSummaryView({
  name: "example-recent-travel",
  source: "LONG_TERM",
  visibility: "PRIVATE",
  groupBy: [],
  filter: { ownerId: { eq: "quickstart-user" } },
  output: { format: "TEXT", instructions: "Summarize recent travel preferences." },
  refreshPolicy: { mode: "MANUAL" },
  timeBasis: "eventTime",
  timeWindowSeconds: 1209600,
});
await memory.refreshSummaryView(view.viewId, { target: "FULL" });
const result = await memory.getSummaryViewResult(view.viewId);
if (result.refresh) console.log(result.refresh.status, result.refresh.lastProgressAt);
console.log("Result status:", result.status, "Stale:", result.stale);
set -euo pipefail
MEMORY_API="${IRIS_AGENT_MEMORY_URL%/}/iris/data/v1/agent-memory/stores/$IRIS_AGENT_MEMORY_STORE_ID"
AUTH="Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY"

VIEW_ID=$(curl --fail-with-body --silent --show-error -X POST "$MEMORY_API/summary-views" \
  -H "$AUTH" -H 'Content-Type: application/json' --data '{
    "name":"example-recent-travel","source":"LONG_TERM","visibility":"PRIVATE","groupBy":[],
    "filter":{"ownerId":{"eq":"quickstart-user"}},
    "output":{"format":"TEXT","instructions":"Summarize recent travel preferences."},
    "refreshPolicy":{"mode":"MANUAL"},"timeBasis":"eventTime","timeWindowSeconds":1209600
  }' | jq -er '.viewId')
curl --fail-with-body --silent --show-error -X POST "$MEMORY_API/summary-views/$VIEW_ID/refresh" \
  -H "$AUTH" -H 'Content-Type: application/json' --data '{"target":"FULL"}' >/dev/null
curl --fail-with-body --silent --show-error "$MEMORY_API/summary-views/$VIEW_ID/result" \
  -H "$AUTH" | jq '{status, stale, refresh: (.refresh | if . then {status, lastProgressAt} else null end)}'
  • For a session-derived memory, event time is the newest rendered message time from its recorded extraction sources. Send original message timestamps when importing sessions.
  • For a new direct memory, event time is the memory's creation time.
  • The view skips memories without a stored event time, including records written before the feature was available. Agent Memory does not backfill timestamps.

Create a new view to choose a different time basis. On self-managed deployments, upgrade the Agent Memory control plane, data-plane servers, and workers before creating an event-time view. Disable event-time views before rolling back to older binaries. Older workers select sources by storage time.

When a source used in a cached result ages out of the window, the result reports stale: true. Continuous views refresh at the next reconciliation. For a manual view, request a refresh.

Choose structured output and continuous refresh

For structured output, replace output with:

{
  "format": "STRUCTURED",
  "instructions": "Summarize only preferences supported by the selected memories.",
  "schema": {
    "fields": [
      {"name":"cities","type":"STRING_LIST","description":"Cities the user wants to visit"},
      {"name":"vegetarian","type":"BOOLEAN","description":"Whether the user has stated a vegetarian diet"}
    ]
  }
}

The schema accepts 1–50 fields of type STRING, INTEGER, FLOAT, BOOLEAN, STRING_LIST, FLOAT_LIST, or OBJECT. Generated fields are optional. Arbitrary JSON Schema, required-field declarations, and nested object schemas are unsupported. Text output must omit schema; structured output requires it. Invalid generated data is reported as OUTPUT_VALIDATION_FAILED.

For continuous refresh, use:

{"mode":"CONTINUOUS","debounceSeconds":5,"reconcileIntervalSeconds":60}

The reconcile interval is required and must fit deployment limits. Debounce coalesces mutations; reconciliation also handles changes such as a moving time window. Manual mode omits both interval fields. Both modes run asynchronously within queue, source, generation, and concurrency limits.

Check coverage and manage definitions

Inspect sourceMemoryCount and summarizedMemoryCount. Selection can omit whole records (sourcesOmitted) or clip included content (sourceContentTruncated). truncated combines both. Check truncated even when every record was included: some text may have been cut. Concurrent writes can change the source set while counts are measured.

Request includeSourceMemoryIds=true for the selected source IDs. These identify contributing records, not every match. computedAt, sourceUpdatedAt, and definitionVersion help assess freshness.

Action Python method REST
List definitions memory.client.list_summary_views GET /summary-views
Read a definition memory.client.get_summary_view GET /summary-views/{viewId}
Update a definition memory.client.update_summary_view PATCH /summary-views/{viewId}
Delete a definition memory.client.delete_summary_view DELETE /summary-views/{viewId}

REST paths are relative to /iris/data/v1/agent-memory/stores/{storeId}. Lists return items and optional nextCursor; pass it as cursor with the same query. Definition states (ACTIVE, DISABLED, DELETING) are separate from result status. Each Python method also has an _async variant.

This example updates the description, which does not trigger generation, and lists the store's definitions:

updated = memory.client.update_summary_view(
    view_id=view_id, description="Travel preferences for trip planning.",
)
print(updated.name, "version", updated.definition_version)
for item in memory.client.list_summary_views(limit=20).items:
    print(item.view_id, item.name, item.state)
const updated = await memory.updateSummaryView(viewId, {
  description: "Travel preferences for trip planning.",
});
console.log(updated.name, "version", updated.definitionVersion);
for (const item of (await memory.listSummaryViews(20)).items) {
  console.log(item.viewId, item.name, item.state);
}
curl --fail-with-body --silent --show-error \
  -X PATCH "$MEMORY_API/summary-views/$VIEW_ID" \
  -H "Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"description": "Travel preferences for trip planning."}' | jq '{name, definitionVersion}'
curl --fail-with-body --silent --show-error --get \
  "$MEMORY_API/summary-views" \
  -H "Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY" \
  --data-urlencode 'limit=20' | jq '.items[] | {viewId, name, state}'
Change Effect
Name or description Does not trigger generation.
Filter, output, or refresh policy Increments definitionVersion.
groupBy Increments definitionVersion and replaces the partition layout.
Owner, visibility, source, or time basis Create a new definition to change these fields.
state: DISABLED Disables the view. Re-enabling requests refresh work.

clearFilter: true and clearTimeWindow: true remove those settings; do not also supply replacements.

Deletion returns 202 while cleanup runs. Repeated deletion is idempotent; the definition becomes DELETING before schedules and results are removed. Source memories remain.

memory.client.delete_summary_view(view_id=view_id)
await memory.deleteSummaryView(viewId);
curl --fail-with-body --silent --show-error \
  -X DELETE "$MEMORY_API/summary-views/$VIEW_ID" \
  -H "Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY" | jq .

For quota failures, inspect the API error and deployment limits. For generation or source-access failures, keep the view ID and address the reported error instead of creating duplicates. Ingestion webhooks can reject generated content before publication.

RATE THIS PAGE
Back to top ↑