Inspiration

Small businesses often run on conversations. A customer promise, a supplier price change, a margin rule, or a delivery date may live in a message thread or in one person’s memory. A normal chat assistant can answer the current prompt, but it starts losing value when it forgets the operating context that should shape the next decision.

Afelu Memory was built around a different idea: memory should not be a transcript. It should be durable business context that an agent can retrieve, reason over, and turn into action.

What it does

Afelu Memory helps a business capture commitments, customer needs, supplier changes, and operating rules. When the user asks what to do next, Afelu:

  1. creates a semantic embedding for the current message;
  2. retrieves the most relevant tenant-scoped memories from CockroachDB;
  3. gives only that grounded context to Amazon Bedrock;
  4. returns a clear response and, when appropriate, creates a durable memory or task; and
  5. records the agent run and outcome for auditability.

The live story follows "Selam Craft." Afelu remembers a Friday basket order, a supplier price change, and a wholesale margin rule. When asked to plan the order, it connects those facts to the current request instead of treating the conversation as a blank slate.

How we built it

The application is a Next.js 15 project deployed as a server-rendered application on AWS Amplify Hosting.

Amazon Titan Text Embeddings V2 produces 1,024-dimensional vectors. CockroachDB Cloud stores those vectors beside the operational records for memories, tasks, tenants, agent runs, and audit events. A tenant-prefixed distributed vector index performs cosine similarity search, so semantic retrieval and transactional state stay in one database.

Amazon Nova Lite receives the retrieved memory context and returns a structured response containing the user-facing answer, an optional durable memory, and an optional next task. The application validates this structured boundary before writing results.

The production runtime uses a dedicated least-privilege CockroachDB SQL user. The database credential is stored in AWS Secrets Manager, and the Amplify SSR compute role can access only that secret and the required Bedrock models. CloudWatch runtime logging is enabled through a separate app-scoped role.

The official CockroachDB hardening-user-privileges Agent Skill was applied to audit the production grants. The review confirmed that the PUBLIC role has no data access to application tables and that the runtime identity has only the table-specific privileges required by the workflow.

Challenges we ran into

The hardest part was making the demo production-real rather than stopping at a local prototype. Cross-region Bedrock inference profiles needed precise IAM resource permissions. The database secret needed to remain out of build artifacts while still being available to server-side requests. Model-generated task dates also needed validation so an optional malformed date could not break an otherwise successful agent run.

Production testing caught those boundaries. The final end-to-end workflow was verified from the public application through Bedrock and CockroachDB: semantic retrieval completed, a grounded response returned, and the memory, task, and agent-run records were persisted by the least-privilege runtime user.

Accomplishments that we're proud of

  • A production-ready memory loop using Titan embeddings and CockroachDB vector search.
  • Seamless tenant isolation and least-privilege security (Secrets Manager + IAM).
  • A structured agent that retrieves, reasons, and writes tasks in a single transaction.

What we learned

The main lesson is that agentic memory is a system design problem, not just a prompt feature. Useful memory needs tenant isolation, retrieval quality, transactional writes, clear provenance, controlled model context, and failure handling. CockroachDB’s ability to keep vector search and operational state together made the memory loop much simpler and easier to reason about.

What's next for Afelu Memory

  • Add calendar integration to auto-schedule tasks.
  • Build a Slack/WhatsApp interface for business owners.
  • Run paid pilots with local craft businesses to measure time saved.

Built With

Share this project:

Updates