Skip to content

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

@wucm667

Description

@wucm667

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions