Skip to content

Configure context store

Configure the context store so an agent keeps conversation state across connections, pod restarts and replicas.

  • An AgentRuntime in the namespace you are working in.
  • For Redis, a reachable Redis instance.

The in-memory store is the default. spec.context can be omitted, or set explicitly:

apiVersion: omnia.altairalabs.ai/v1alpha1
kind: AgentRuntime
metadata:
name: my-agent
spec:
# ... other config
context:
type: memory
ttl: 1h

Conversations are lost when the pod restarts, and a second replica cannot see a conversation held by the first. Use it for development and single-replica agents.

  1. Deploy Redis, or use an existing instance. The password and release name below are illustrative:

    Terminal window
    kubectl create namespace redis
    helm install redis bitnami/redis -n redis \
    --set auth.password=your-redis-password
  2. Create a Secret in the AgentRuntime’s namespace. The Redis URL must be under the key url:

    apiVersion: v1
    kind: Secret
    metadata:
    name: redis-credentials
    type: Opaque
    stringData:
    url: "redis://:your-redis-password@redis-master.redis.svc:6379"
  3. Point the AgentRuntime at the Secret. storeRef is required when type is redis:

    apiVersion: omnia.altairalabs.ai/v1alpha1
    kind: AgentRuntime
    metadata:
    name: my-agent
    spec:
    # ... other config
    context:
    type: redis
    ttl: 24h
    storeRef:
    name: redis-credentials

See the AgentRuntime reference for every context field.

spec.context.ttl is a Go duration such as 30m, 1h, 24h or 168h. It defaults to 24h. Set it to the longest gap you expect between messages in one conversation. Session management explains how the window slides and what a longer value costs.

Send the session_id from the connected message to resume that conversation:

{
"type": "message",
"session_id": "existing-session-id",
"content": "Continue our conversation..."
}

If the context store still holds the conversation, the history is preserved. If it has expired, the facade answers SESSION_EXPIRED and drops the message. Make your client resend the message without session_id to start a new conversation.

A conversation lives as long as the Redis that holds it. It survives an agent restart, a rollout and an Omnia upgrade or rollback, but not a restart of a Redis that keeps no data on disk. The chart’s development Redis (dev.redis.enabled) is one: it runs with persistence off, and Helm recreates its pod whenever its settings change, which a chart upgrade or rollback can do. Every open conversation then answers SESSION_EXPIRED. For conversations that must outlive upgrades, point storeRef at a Redis with persistence or replication.

The connected message carries the ID. The value below is illustrative; the facade generates a UUID:

{"type": "connected", "session_id": "0b6f6d2e-6a53-4f7e-9a0c-2f6d1f3f9c11"}
  1. Open a connection, send a message, and note the session_id.

  2. Restart the agent pods:

    Terminal window
    kubectl rollout restart deployment/my-agent
  3. Open a new connection and send a message with the same session_id.

With Redis, the conversation continues with its history. With the in-memory store, the facade answers SESSION_EXPIRED.