MemoryForge AI gives agents an operating memory: structured experience that can change the next action. The interactive demo shows an agent fail a deployment, persist the reason, retrieve it on the next run, switch strategies, and succeed.
- Select Run task.
- Watch the default deployment strategy time out.
- Confirm that the failure and recommended correction appear in long-term memory.
- Select Run again with memory.
- Watch the agent retrieve the past failure, choose an asynchronous deployment, verify service health, and store the successful outcome.
AI Agent → AWS Runtime → CockroachDB Memory → Relevant Experience → Better Action
The production architecture is designed around:
- Amazon Bedrock for agent reasoning
- AWS Lambda for serverless execution
- CockroachDB for durable, distributed memory storage
- vector retrieval for relevant past experience
- structured decision and outcome records for auditability
Built for the CockroachDB × AWS Hackathon.
- Python 3.12
- A CockroachDB Cloud cluster with vector indexes enabled
- An AWS account with Amazon Bedrock model access and permission to deploy Lambda
- AWS CLI and AWS SAM CLI for deployment
git clone https://github.com/lsh2546/MemoryForge-AI.git
cd MemoryForge-AI
python -m venv .venvActivate the virtual environment, then install dependencies:
# macOS/Linux
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1
pip install -r requirements.txtCopy .env.example to .env for local work. Never commit the populated file.
| Variable | Required | Purpose |
|---|---|---|
DATABASE_URL |
Yes | CockroachDB PostgreSQL connection string with sslmode=verify-full |
AWS_REGION |
Yes | Region used by the Bedrock Runtime client and Lambda |
EMBEDDING_MODEL_ID |
Yes | Bedrock embedding model; defaults to Titan Text Embeddings v2 |
MEMORYFORGE_AGENT_ID |
Local demo only | Stable agent identity used by the two-run example |
The production embedding contract is explicitly 1024 dimensions and matches
agent_memories.embedding VECTOR(1024).
The Python driver uses the packaged certifi CA bundle while retaining full TLS
certificate verification in both local and Lambda environments.
Create a memoryforge database or choose an existing database, then apply the schema:
cockroach sql --url "$DATABASE_URL" --file schema.sqlThe schema stores structured failures, successes, decisions, workflow state, and
1024-dimensional embeddings. memories_embedding_idx is a CockroachDB vector
index used by cosine-distance recall. The Lambda database user needs only
SELECT and INSERT on agent_memories.
Export the variables from .env, ensure your AWS identity can call the configured
Bedrock model, and invoke the Lambda handler twice with the same task and agent ID:
python - <<'PY'
import json
from src.lambda_handler import handler
event = {
"agent_id": "demo-agent",
"task": "Deploy checkout-service v2.4 and verify production health",
}
print("RUN 1", json.loads(handler(event, None)["body"]))
print("RUN 2", json.loads(handler(event, None)["body"]))
PYExpected causal chain:
- Run 1 finds no relevant failure, uses
synchronous_deployment, fails, and returns a newwritten_memory_id. - Run 2 recalls that ID, places it in
plan.adapted_from_memory, changes the strategy toasync_job_with_health_check, succeeds, and writes the outcome.
The included template.yaml gives the function Bedrock invoke permission, keeps
the CockroachDB URL server-side, and limits reserved concurrency.
sam build
sam deploy --guidedDuring guided deployment:
- choose the same AWS region in which Bedrock model access is available;
- provide
DatabaseUrlfrom CockroachDB Cloud (the parameter isNoEcho); - keep the default Titan embedding model unless another 1024-dimensional model is deliberately configured in both code and schema.
Invoke the deployed function twice with the same payload:
aws lambda invoke \
--function-name memoryforge-ai-agent \
--payload '{"agent_id":"demo-agent","task":"Deploy checkout-service v2.4 and verify production health"}' \
--cli-binary-format raw-in-base64-out run-1.json
aws lambda invoke \
--function-name memoryforge-ai-agent \
--payload '{"agent_id":"demo-agent","task":"Deploy checkout-service v2.4 and verify production health"}' \
--cli-binary-format raw-in-base64-out run-2.jsonCompare run-1.json and run-2.json. The second response must contain the first
run's memory ID in both recalled_memory_ids and plan.adapted_from_memory, plus
result.status: success. This is the proof that CockroachDB recall changed the
next action rather than merely displaying history.
- Keep
DATABASE_URLonly in Lambda environment configuration or a secret store. - Do not expose database credentials, Bedrock responses, or stack traces to a browser.
- Use a least-privilege CockroachDB user and a reserved concurrency limit.
- Parameterized SQL is used for every memory value; arbitrary SQL is not accepted.
The submitted demo was re-run against the deployed memoryforge-ai-agent
Lambda in us-east-1, Amazon Bedrock Titan Text Embeddings v2, and CockroachDB
Cloud. With the same agent and task payload:
- Run 1 returned
failedwithsynchronous_deploymentand wrote memoryc7a7eb57-dd10-4163-8618-88c9232c2678. - Run 2 recalled that exact ID, returned it as
plan.adapted_from_memory, changed the strategy toasync_job_with_health_check, and returnedsuccess. - The automated equality and outcome check returned
same_memory_changed_action: true. - CockroachDB Cloud Managed MCP
select_queryindependently returned the same UUID as afailurememory with decisionasync_job_with_health_check, outcometimeout, and confidence0.96. The read-only reproduction script isscripts/managed_mcp_query.mjs.
The 2 minute 14 second demo video shows the application states and the live AWS invocation evidence without exposing the database URL, credentials, or environment values.