Configure context store
Configure the context store so an agent keeps conversation state across connections, pod restarts and replicas.
Prerequisites
Section titled “Prerequisites”- An AgentRuntime in the namespace you are working in.
- For Redis, a reachable Redis instance.
Use the in-memory store
Section titled “Use the in-memory store”The in-memory store is the default. spec.context can be omitted, or set explicitly:
apiVersion: omnia.altairalabs.ai/v1alpha1kind: AgentRuntimemetadata: name: my-agentspec: # ... other config context: type: memory ttl: 1hConversations 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.
Use the Redis store
Section titled “Use the Redis store”-
Deploy Redis, or use an existing instance. The password and release name below are illustrative:
Terminal window kubectl create namespace redishelm install redis bitnami/redis -n redis \--set auth.password=your-redis-password -
Create a Secret in the AgentRuntime’s namespace. The Redis URL must be under the key
url:apiVersion: v1kind: Secretmetadata:name: redis-credentialstype: OpaquestringData:url: "redis://:your-redis-password@redis-master.redis.svc:6379" -
Point the AgentRuntime at the Secret.
storeRefis required whentypeisredis:apiVersion: omnia.altairalabs.ai/v1alpha1kind: AgentRuntimemetadata:name: my-agentspec:# ... other configcontext:type: redisttl: 24hstoreRef:name: redis-credentials
See the AgentRuntime reference for every context field.
Set the TTL
Section titled “Set the TTL”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.
Resume a session
Section titled “Resume a session”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"}Verify
Section titled “Verify”-
Open a connection, send a message, and note the
session_id. -
Restart the agent pods:
Terminal window kubectl rollout restart deployment/my-agent -
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.
Related pages
Section titled “Related pages”- Session management: how the context store, the session archive, TTL and resumption interact.
- Scale agents
- AgentRuntime reference