eino icon indicating copy to clipboard operation
eino copied to clipboard

[ADK] Add pluggable memory middleware based on Retriever/Indexer/Embedding

Open wucm667 opened this issue 7 months ago • 1 comments

Summary

I would like to propose a pluggable memory middleware for Eino ADK agents.

Eino already provides core component abstractions such as Retriever, Indexer, and Embedding, and ADK already provides middleware hooks around agent/model execution. However, there is currently no standard ADK-level memory middleware that connects these pieces into a reusable agent memory workflow.

Motivation

When building long-running or general-purpose agents on top of Eino, application developers often need:

  • Retrieve relevant long-term memory before model invocation
  • Inject retrieved memory into the model context in a controlled format
  • Write important facts, user preferences, or task summaries back to memory
  • Support memory namespaces such as user/session/agent/project
  • Keep memory provider implementations outside of Eino core

Without a standard middleware abstraction, each application has to implement its own memory injection, memory write policy, and storage integration.

Proposed Design

Add an ADK memory middleware abstraction that supports:

  • BeforeModelRewriteState: retrieve and inject memory into model input
  • AfterModelRewriteState or event-based hooks: extract/write memory after model or agent output
  • Configurable memory namespace resolver
  • Configurable memory formatting
  • Configurable memory write policy
  • Integration with existing Retriever, Indexer, and Embedding interfaces
  • No dependency on a specific vector database in Eino core

A rough API could look like:

type MemoryStore interface {
    Search(ctx context.Context, query string, opts ...MemoryOption) ([]*schema.Document, error)
    Save(ctx context.Context, docs []*schema.Document, opts ...MemoryOption) error
}

type MemoryMiddlewareConfig struct {
    Store MemoryStore
    NamespaceResolver func(ctx context.Context, input *adk.AgentInput) string
    QueryBuilder func(ctx context.Context, messages []*schema.Message) string
    MemoryFormatter func(ctx context.Context, docs []*schema.Document) []*schema.Message
    WritePolicy func(ctx context.Context, event *adk.AgentEvent) ([]*schema.Document, bool, error)
}

Expected Benefits

  • Makes Eino ADK easier to use for long-running agents
  • Encourages a common memory pattern across Eino applications
  • Keeps vector DB implementations in eino-ext while providing the reusable ADK abstraction in Eino core
  • Helps framework users build agent systems with durable memory without reinventing middleware logic

Related Context

This is not a request to add a specific vector database implementation to Eino core. The request is for a general ADK middleware abstraction that can work with existing Eino component interfaces and external memory backends.

wucm667 avatar Apr 24 '26 12:04 wucm667

Hey, You mean an interface that long running agents cannot hit the context window that fast?

Or more like a interface for RAG Implementations?

gterminator avatar Jul 26 '26 16:07 gterminator