Build agent memory with NVIDIA NeMo Agent Toolkit and Amazon S3 Vectors
https://aws.amazon.com/blogs/machine-learning/build-agent-memory-with-nvidia-nemo-agent-toolkit-and-amazon-s3-vectors/📌 用 NVIDIA NeMo Agent Toolkit 打造多 Agent 記憶層
TL;DR:AWS 示範如何用 Amazon S3 Vectors 當作 NAT 的自訂記憶後端,並部署在 EKS 上實戰。
多 Agent 系統最大的痛點之一,是每次呼叫都像失憶重啟:上一輪蒐集的資料、分析出的模式,下一次對話全部歸零。AWS 這篇文章接續前一篇「為多 Agent AI 系統建立持久記憶」的架構討論,這次直接動手,示範如何把 Amazon S3 Vectors 接進 NVIDIA NeMo Agent Toolkit(NAT),變成真正可用的記憶層。
🤔 NAT 的記憶子系統,缺的是一塊規模化後端
NAT 是 NVIDIA 推出的開源框架,用來建構、分析與最佳化 AI agent,並且框架無關(framework-agnostic),可搭配 Strands Agents、LangChain、LlamaIndex、CrewAI 或自訂實作。它內建的記憶子系統負責儲存與擷取對話歷史、使用者偏好與長期知識,並透過 MemoryEditor 外掛介面讓開發者接上自訂後端。NAT 原生支援 Mem0、MemMachine、Redis、Zep 這幾種記憶提供者,涵蓋常見情境;但若要支撐生產環境中彈性向量儲存、強寫入一致性、並且能成本效率地擴展到數十億筆向量,文章認為 Amazon S3 Vectors 是更合適的選擇。
🧩 三步驟接上 S3 Vectors
實作拆成三個步驟:
- 建立 S3 Vectors 基礎設施:建立 vector bucket 與 index,index 維度設為 1024,對應 Amazon Titan Text Embeddings V2 的輸出,並將內容量較大的欄位標記為不可過濾(non-filterable)的 metadata。
- 實作自訂 MemoryEditor 外掛:這個外掛用 Titan Text Embeddings V2 產生 embedding,把每一筆記憶連同範圍化(scoped)的 metadata 一起寫入向量,並把搜尋條件轉譯成 S3 Vectors 的 metadata 查詢語法,再向 NAT 註冊讓它能被發現。
- 設定 Agent 工作流程:在 NAT 的 YAML 設定檔中接上這個外掛,並透過
auto_memory_agent包裝器,讓使用者訊息與 Agent 回覆自動被儲存,相關上下文也會在每次呼叫前自動注入,不需要讓 LLM 主動呼叫記憶工具。
💡 多 Agent 共用同一個記憶索引
文章用一個投資研究情境做示範:Research Agent、Analysis Agent、Synthesis Agent 三個角色共用同一個 S3 Vectors index,各自以自己的 agent_id 寫入,再用 metadata 過濾來讀取彼此的成果。Research Agent 能回想起之前蒐集過的資料,避免重複呼叫 API;Analysis Agent 能延續先前識別出的模式;Synthesis Agent 則能存取累積下來的研究發現,逐步產出更完整的報告。NAT 原生的 user_id 用於多租戶的使用者層級隔離,文章額外引入 team_id 這個 metadata 欄位,在同一個索引內做多 Agent 團隊協作的分組。隨著時間推移,瑣碎的情境記憶(episodic memory)會持續累積,文章建議定期把它們整合(consolidate)成通用知識(semantic memory),觸發方式可以是排程的 cron job、向量數量門檻,或是 Agent 在完成若干研究週期後主動發出的訊號。
⚠️ 別忘了資料治理
因為這套架構會持久化對話歷史與使用者記憶,文章特別提醒要規劃好留存政策,利用文中提到的記憶整合與刪除路徑來淘汰不再需要的資料;metadata 中不應儲存個資(PII),敏感欄位在送進 embedding 前要先遮罩或代符化(tokenize);並且建議用每租戶獨立的 index 搭配最小權限(least-privilege)的 IAM 政策,確保每個 Agent 只能存取屬於自己的那部分記憶。至於效能面,文章雖然提供了 nat eval 評估框架可以比較有無記憶的兩種跑法,但也明確說明這些只是「方向性的預期,而非已經實測出的基準數據」,實際效果會因上下文重用程度、Agent 協作數量、以及檢索的 top-k 預算大小而有所不同。
🎯 實務啟示
部署面上,文章選擇 Amazon EKS 而非全託管的 Amazon Bedrock AgentCore,理由是團隊若需要完整掌控擴展、網路與生命週期管理,EKS 搭配 IAM Roles for Service Accounts(IRSA)能原生整合 IAM 權限。每個 Agent 類型是獨立的 Kubernetes Deployment,透過 HorizontalPodAutoscaler 依 CPU 使用率自動擴展,而 S3 Vectors 的強寫入一致性代表任何 Pod 寫入的記憶都能立即被其他 Pod 看到,不需要額外處理快取失效。如果你的團隊正在評估客服、DevOps 自動化、法律研究或科學研究這類需要「越用越聰明」的多 Agent 場景,這套模式值得作為記憶層架構的參考起點。
🔗 來源
- 標題:Build agent memory with NVIDIA NeMo Agent Toolkit and Amazon S3 Vectors
- 作者/機構:Venkata Sistla(AWS)
- 連結:https://aws.amazon.com/blogs/machine-learning/build-agent-memory-with-nvidia-nemo-agent-toolkit-and-amazon-s3-vectors/
#AIAgents #AgentMemory #NVIDIA #NeMoAgentToolkit #AmazonS3Vectors #AWS #EKS #MultiAgentSystems #VectorDatabase #LLMOps
原始資料 AWS ML · 收集於 2026-10-01
摘要原文
In my previous post: Building persistent memory for multi-agent AI systems with Amazon S3 Vectors , we explored why memory engineering is the foundational discipline for production multi-agent systems. We showed how Amazon S3 Vectors , a capability of Amazon Simple Storage Service (Amazon S3), meets the architectural requirements for agent memory: semantic retrieval, rich metadata, strong consistency, and elastic scale. In this post, we move from architecture to implementation. We show you how to use Amazon S3 Vectors as the persistent memory layer within the NVIDIA NeMo Agent Toolkit (NAT) , deployed on Amazon Elastic Kubernetes Service (Amazon EKS) for full operational control. By the end of this post, you will understand how NAT’s memory subsystem works and how to implement Amazon S3 Vectors as a custom memory provider. You will also learn how to deploy the stack on Amazon EKS, using a multi-agent investment research use case as the running example. NVIDIA NeMo Agent Toolkit (NAT) is an open source framework for building, profiling, and optimizing AI agents. It’s framework-agnostic, working with Strands Agents, LangChain, LlamaIndex, CrewAI, and custom implementations. NAT provides four capabilities relevant to production agent systems: NAT includes a dedicated memory subsystem designed to store and retrieve conversation history, user preferences, and long-term knowledge across agent invocations. The memory module is extensible: you create custom memory providers (backends) by implementing NAT’s plugin interface. Key components include: NAT currently has these built-in memory providers: Mem0, MemMachine, Redis, and Zep. These cover common use cases. However, for production multi-agent systems that require elastic vector storage, strong write consistency, and cost-efficient scaling to billions of vectors, a custom provider backed by Amazon S3 Vectors is the right fit. Building persistent memory for multi-agent AI systems with Amazon S3 Vectors covers the architectural rationale in depth. The following table summarizes the properties that make S3 Vectors the right fit for NAT’s memory layer: To follow along with the implementation in this post, you need: The implementation has three steps: Step 1: Create the S3 Vectors infrastructure Step 2: Implement a custom MemoryEditor plugin Step 3: Configure the agent workflow Figure 1: The three steps to implement Amazon S3 Vectors as a NAT memory provider The following code creates a vector bucket and an index with a metadata schema designed for agent memory. The index uses 1024 dimensions to match the output of Amazon Titan Text Embeddings V2, and it marks the large content field as non-filterable metadata: After creating the bucket and index, you can implement the memory provider that reads from and writes to them. The following code implements the MemoryEditor interface as an Amazon S3 Vectors backend and registers it so that NAT can discover it: The plugin generates embeddings with Amazon Titan Text Embeddings V2, stores each memory as a vector with scoped metadata, and translates search filters into Amazon S3 Vectors metadata queries. With the plugin defined, configure it in NAT’s YAML config and wire it into an agent workflow: With the auto_memory_agent wrapper, you can capture and retrieve memory automatically. User messages and agent responses are stored, and relevant context is injected before each agent call. This design removes the need for the LLM to explicitly invoke memory tools. Because this solution persists conversation history and user memory, plan for how that data is retained and accessed. Set a retention policy for stored memories, and use the memory consolidation and removal paths in this post to expire data you no longer need. Avoid storing personally identifiable information (PII) in memory metadata, and redact or tokenize sensitive fields before you embed them. Scope access with per-tenant indexes and least-privilege IAM policies so that each agent reads and writes only the memory it owns. The following use case demonstrates this pattern in practice. Consider three specialized agents collaborating on an investment research tool: With persistent memory, each agent builds on prior work. The Research Agent recalls previously collected data, avoiding redundant API calls. The Analysis Agent builds on patterns identified in prior sessions. The Synthesis Agent accesses cumulative findings to produce progressively richer reports. Each agent uses the same S3 Vectors index but writes with its own agent_id in the metadata. Agents retrieve shared knowledge using metadata filters: NAT’s built-in multi-tenant memory isolation uses user_id to scope memory per user. For multi-agent team coordination, the team_id metadata field provides an additional grouping dimension within the same S3 Vectors index. Over time, episodic memories accumulate. Periodically consolidating them into semantic memories (generalized knowledge) keeps retrieval precise and efficient. You can trigger consolidation through a scheduled cron job, a vector count threshold, or an agent-initiated signal after a configurable number of research cycles: Amazon EKS is a deliberate choice for teams that need full operational control over their agent workloads. With Amazon EKS, you control scaling, networking, and lifecycle management, and you integrate natively with AWS Identity and Access Management (IAM) for Amazon S3 Vectors access. If you prefer a fully managed runtime, Amazon Bedrock AgentCore provides a managed alternative that removes this operational overhead. You run NAT agents as containerized services using nat serve . Each agent type is a Kubernetes Deployment with IAM access granted through IAM Roles for Service Accounts (IRSA). The following Dockerfile packages the agent with its configuration and memory plugin: The following manifests deploy the Research Agent with autoscaling: The following IAM policy grants scoped access to the memory layer. Attach it to the IAM role associated with the agent-sa service account through IRSA: After building and pushing the container image, deploy the agents: S3 Vectors provides strong write consistency. Pods and agent types can immediately see memories that agent pods store, with no cache invalidation required. The HorizontalPodAutoscaler scales agent replicas based on CPU utilization. Each replica connects to the same S3 Vectors index through IRSA, supporting consistent memory access regardless of which pod handles a given request. With NAT’s evaluation harness ( nat eval ), you can quantify the effect of memory on agent performance. Configure two evaluation runs: one with memory enabled and one without, using the same dataset: Based on the architectural properties of this design, you can expect the following qualitative outcomes when comparing these runs. These are directional expectations, not benchmarked measurements: The magnitude of these effects depends on your workload: how much context is reused across sessions, how many agents coordinate, and how large your retrieval budget (top-k) is. NAT’s hyperparameter optimizer can systematically tune top_k and similarity threshold to find the optimal cost-quality trade-off for your use case. To avoid ongoing charges from resources created in this walkthrough, delete the following: This post showed how to implement a custom NAT memory provider backed by Amazon S3 Vectors and deploy it on Amazon EKS. The key building blocks: These patterns apply to domains where agents benefit from accumulated knowledge. They include classifying memory as episodic, semantic, or procedural, sharing memory across agents with metadata filtering, and consolidating memory with an LLM. Examples include customer support, DevOps automation, legal research, and scientific discovery. For the memory architecture foundations referenced throughout this post, see Building persistent memory for multi-agent AI systems with Amazon S3 Vectors .
由 claude-code/sonnet 自動生成