PostgreSQL Memory
HTTP memory service backed by PostgreSQL for persistent conversation storage.
Installation
make postgres-memory-install # Installs PGO and deploys the service
Database Access
# Port forward to PostgreSQL
kubectl port-forward \
$(kubectl get pod -l postgres-operator.crunchydata.com/cluster=postgres-memory-postgres,postgres-operator.crunchydata.com/role=master -o name) \
5432:5432
# Get password and connect
export PGPASSWORD=$(kubectl get secret postgres-memory-postgres-pguser-postgres \
-o jsonpath='{.data.password}' | base64 -d)
psql -h localhost -U postgres -d memory
# Or just
make postgres-connect
Local Development
make postgres-memory-dev
Configuration
The PostgreSQL Memory service stores conversation history and agent memory across sessions. It integrates with ARK agents to provide persistent memory capabilities.
Environment Variables
DATABASE_URL
- PostgreSQL connection string (auto-configured in cluster)
Usage
Once installed, agents can reference the memory service in their configuration to enable persistent conversation storage.
This example shows how to use a memory object to track occurrences of a keyword (bazinga) and terminate the conversation if it is repeated more than three times.
apiVersion: ark.mckinsey.com/v1alpha1
kind: Agent
metadata:
name: agent-rr
spec:
prompt: Append "Bazinga!" to the user input and say it. If you see Bazinga 3 times, end the conversation.
tools:
- type: built-in
name: terminate
---
apiVersion: ark.mckinsey.com/v1alpha1
kind: Team
metadata:
name: team-rr
spec:
members:
- name: agent-rr
type: agent
strategy: "round-robin"
---
apiVersion: ark.mckinsey.com/v1alpha1
kind: Query
metadata:
name: query-rr
spec:
input: "Sheldon says:"
memory:
name: postgres-memory
targets:
- type: team
name: team-rr
You try this out by :
kubectl apply -f samples/teams/round-robin-with-terminate.yaml
fark team team-rr query-rr
Try this query more than three times to test it.
Last updated on