This document details the architectural design of the Evolving Agents Toolkit (EAT), focusing on its core components, interactions, its unified MongoDB backend, and the role of the Smart Memory ecosystem in enabling advanced autonomous learning and evolution.
The Evolving Agents Toolkit aims to provide a robust framework for building ecosystems of autonomous AI agents. The core philosophy is agent-centric: the system itself is managed and orchestrated by specialized agents (like the SystemAgent), which leverage tools to interact with underlying services and manage other components. All primary data, including component metadata, embeddings, agent registrations, operational logs, LLM caches, intent plans, and detailed agent experiences (Smart Memory), is now persisted in MongoDB.
Key goals of the architecture include:
- Autonomy & Evolution: Enable agents, components, and even system strategies to be created, evaluated, and improved over time, significantly informed by past experiences.
- Modularity & Reusability: Promote component reuse through discovery and adaptation via the
SmartLibrary. - Interoperability: Support agents and tools built with different underlying frameworks.
- Decoupled Communication: Facilitate capability-based communication via the
SmartAgentBus. - Governance & Safety: Embed safety through
Firmwareand an optional human-in-the-loop review process. - Deep Contextual Understanding: Provide agents with rich, task-relevant context dynamically constructed from
SmartLibrary, current task data, and historical experiences from Smart Memory. - Orchestration: Enable complex goal achievement through
SystemAgent-driven workflow generation and execution. - Cumulative Learning & Self-Improvement: The Smart Memory ecosystem is central to enabling agents, particularly
SystemAgent, to learn from past workflows, decisions, and outcomes. This learning directly informs better problem-solving, more effective component evolution, and potentially the evolution of the system's own operational strategies. - Unified & Scalable Backend: Utilize MongoDB for all persistent data.
graph TD
User["User / External System"] -- High-Level Goal --> SA[("SystemAgent\n(Orchestrator, Learner)")];;;agent
subgraph "Core Infrastructure & Services (MongoDB Backend)"
direction LR
SL["Smart Library\n(Components, Versions)"];;;service
SM["Smart Memory\n(Agent Experiences - `eat_agent_experiences`)"];;;service
SB["Smart Agent Bus\n(Discovery, Routing - `eat_agent_registry`, `eat_agent_bus_logs`)"];;;service
LLMS["LLM Service\n(Reasoning, Embeddings, Generation - Cache: `eat_llm_cache`)"];;;service
FW["Firmware\n(Governance Rules)"];;;service
MongoDB[("MongoDB Atlas / Server\n(Primary Data Store, Vector Search)")]:::infra
end
subgraph "Key Agents & Factories"
direction LR
MMA[("MemoryManagerAgent\n(Manages Smart Memory via Bus)")];;;agent
AgentF["Agent Factory"];;;infra
ToolF["Tool Factory"];;;infra
ArchZ["ArchitectZero\n(Optional: Solution Design)"];;;agent
EvoS["EvolutionStrategistAgent\n(Optional: Proactive Evolution Suggestions)"];;;agent
end
%% SystemAgent Core Interactions
SA -- Uses --> ToolsSystem["SystemAgent Tools\n(Search, Create, Evolve, Request, Workflow, IntentReview, ContextBuilder, ExperienceRecorder...)"];;;tool
SA -- Uses --> LLMS
SA -- Relies on --> AgentF
SA -- Relies on --> ToolF
%% Smart Memory Interactions
ToolsSystem -- Records/Retrieves Experiences via Bus --> MMA
MMA -- Manages --> SM
SM -- Stores/Retrieves --> MongoDB
MMA -- Uses Internal Tools --> LLMS
%% For summarization, embedding (if not done by MongoExperienceStoreTool)
%% SmartLibrary Interactions
ToolsSystem -- Manages Components --> SL
SL -- Stores/Retrieves --> MongoDB
SL -- Uses --> LLMS
%% For T_raz, embeddings
%% AgentBus Interactions
ToolsSystem -- Interacts via --> SB
SB -- Stores Registry/Logs --> MongoDB
MMA -- Registers/Uses --> SB
ArchZ -- Registers/Uses --> SB
EvoS -- Registers/Uses --> SB
Ecosystem["Managed Agents / Tools"] -- Registers/Uses --> SB
%% Evolution Strategist Interactions (Optional)
SA -.->|Optional: Requests Evolution Insights| EvoS
EvoS -- Analyzes --> SL
EvoS -- Analyzes --> SM
EvoS -- Analyzes --> ComponentTracker["ComponentExperienceTracker\n(Metrics in AgentBus logs or dedicated store)"]
%% ComponentExperienceTracker data source
%% Other Dependencies
AgentF -- Uses --> Providers["Providers\n(BeeAI, OpenAI, etc)"]
AgentF -- Uses --> SL
ToolF -- Uses --> SL
ToolF -- Uses --> LLMS
ToolsSystem -- Influenced By --> FW
%% Optional Design Interaction
SA -.->|Optional: Requests Design via Bus| ArchZ
%% Final Result Flow
SA -- Final Result --> User
classDef agent fill:#9cf,stroke:#333,stroke-width:2px;
classDef service fill:#f9f,stroke:#333,stroke-width:2px;
classDef tool fill:#ccf,stroke:#333,stroke-width:2px;
classDef infra fill:#eee,stroke:#666,stroke-width:1px,color:#333;
style SA fill:#69c,stroke:#000,stroke-width:3px,color:#fff;
style SM fill:#c9f,stroke:#333,stroke-width:2px; %% Highlight Smart Memory
style MMA fill:#9cf,stroke:#333,stroke-width:2px;
Diagram Key: agent = Core EAT Agent, service = Core EAT Service, tool = SystemAgent's Internal Tools, infra = Supporting Infrastructure. Smart Memory is highlighted as a key service.
The toolkit is composed of several key interacting components, all leveraging MongoDB for persistence where applicable.
The central orchestrator, a beeai_framework.agents.react.ReActAgent.
- Role:
- Manages the lifecycle of components (agents, tools) by searching the
SmartLibrary, creating new ones (usingCreateComponentTool), or evolving existing ones (usingEvolveComponentTool). - Facilitates communication and task delegation via the
SmartAgentBus(usingRequestAgentTool,DiscoverAgentTool). - Handles complex, multi-step task execution, often by generating and processing internal workflows (using
GenerateWorkflowTool,ProcessWorkflowTool). - Crucially, actively utilizes the Smart Memory ecosystem for enhanced decision-making:
- Uses
ContextBuilderToolbefore significant planning or component selection to gather relevant past experiences and message summaries from theMemoryManagerAgent. This provides deep, historical context. - Uses
ExperienceRecorderToolafter completing tasks or workflows to record significant outcomes, decisions, and learnings into Smart Memory, fostering continuous improvement for itself and the system.
- Uses
- Manages optional human-in-the-loop review processes via intent review tools.
- Manages the lifecycle of components (agents, tools) by searching the
- Key Tools (Expanded):
- SmartLibrary Tools:
SearchComponentTool,CreateComponentTool,EvolveComponentTool. - SmartContext & Memory Tools:
TaskContextTool(for T_raz generation for search queries),ContextBuilderTool(constructs rich context using Smart Memory and SmartLibrary),ExperienceRecorderTool(records outcomes to Smart Memory). - AgentBus Tools:
RegisterAgentTool,RequestAgentTool,DiscoverAgentTool. - Workflow Tools:
GenerateWorkflowTool,ProcessWorkflowTool. - Intent Review Tools (Optional):
WorkflowDesignReviewTool,ComponentSelectionReviewTool,ApprovePlanTool.
- SmartLibrary Tools:
A specialized ReActAgent for designing solutions, typically invoked by SystemAgent via the SmartAgentBus.
- Role: Analyzes complex requirements, queries
SmartLibraryand potentiallySmartMemory(if equipped with tools or via SystemAgent proxy) for existing patterns or components, and designs multi-component solutions. - Output: A structured solution design (e.g., JSON) that
SystemAgentcan use as a blueprint for workflow generation or component creation.
This is a critical addition for enabling advanced learning and autonomous evolution.
MemoryManagerAgent:- Role: A
ReActAgentacting as the central orchestrator for the storage and retrieval of long-term memories (experiences). Registered on theSmartAgentBus(e.g.,memory_manager_agent_default_id). It exposes a generalprocess_taskcapability, allowing other agents (primarilySystemAgentvia its tools) to send natural language requests for memory operations (e.g., "store this experience: {...}", "find experiences related to: 'invoice processing errors'"). - Internal Tools:
MongoExperienceStoreTool: Handles CRUD operations for experiences in theeat_agent_experiencesMongoDB collection, including generating embeddings for searchable text fields within an experience.SemanticExperienceSearchTool: Performs semantic (vector) searches over stored experiences ineat_agent_experiencesbased on natural language queries.MessageSummarizationTool: Uses an LLM to summarize message histories relevant to a specific goal, often requested byContextBuilderTool.
- Role: A
ContextBuilderTool(Tool forSystemAgent):- Purpose: Dynamically constructs an optimized
SmartContextinstance forSystemAgentto use for a specific sub-task. - Functionality: Invoked by
SystemAgent. It usesRequestAgentToolto query theMemoryManagerAgent(to retrieve relevant past experiences and message summaries) and also directly queriesSmartLibraryfor relevant components. It assembles this information into a focusedSmartContext.
- Purpose: Dynamically constructs an optimized
ExperienceRecorderTool(Tool forSystemAgent):- Purpose: Facilitates the recording of completed tasks, sub-tasks, or entire workflows as structured experiences.
- Functionality: Invoked by
SystemAgent. It structures task details (goal, components used, inputs, decisions, outputs, outcome, reasoning snippets) and usesRequestAgentToolto send this structured data to theMemoryManagerAgentfor persistence in Smart Memory.
- MongoDB Collection:
eat_agent_experiences:- Purpose: Stores structured records of agent experiences.
- Key Fields: Includes
experience_id,primary_goal_description(embedded),sub_task_description(embedded),input_context_summary(embedded),components_used,key_decisions_made,final_outcome,output_summary(embedded),feedback_signals,timestamp, and generatedembeddingsfor its searchable text fields. (A detailed schema is ineat_agent_experiences_schema.md). - Vector Search Index: Requires an Atlas Vector Search index (e.g.,
vector_index_experiences_default) on its embedding fields.
Persistent storage and discovery for reusable components (agents, tools, firmware).
- MongoDB Collection:
eat_components(or configurable name). - Stores: Each component as a MongoDB document including its
id,name,record_type,domain,description,code_snippet,version,tags,metadata(likeapplicability_text), and crucially, itscontent_embedding(E_orig) andapplicability_embedding(E_raz). - Discovery (Dual Embedding on MongoDB):
- Uses MongoDB Atlas Vector Search (or equivalent) on the
content_embeddingandapplicability_embeddingfields within theeat_componentscollection. - Supports Task-Aware Semantic Search: Primarily queries against
applicability_embeddingusing task context, then refines usingcontent_embeddingsimilarity.
- Uses MongoDB Atlas Vector Search (or equivalent) on the
- Versioning & Evolution: Tracks component versions and parentage within MongoDB documents.
- Interface: Methods like
create_record,find_record_by_id,semantic_search,evolve_recordnow perform CRUD and search operations against MongoDB. - Indexing Pipeline: When records are created/updated:
T_orig(functional text from_get_record_vector_text) is embedded to getcontent_embedding.T_raz(applicability text fromgenerate_applicability_textviaLLMService) is generated and embedded to getapplicability_embedding.- Both embeddings and
T_raz(in metadata) are stored directly in the component's MongoDB document.
graph TD
SLI["SmartLibrary Interface"] -->|Manages| Records["Component Records (MongoDB Documents)\n(id, name, ..., content_embedding, applicability_embedding, metadata.applicability_text)"]
Records -- Stored in --> MongoDBLib["MongoDB (eat_components collection)"]:::infra
MongoDBLib -- Vector Indexes on --> VIdxContent["Content Embedding (E_orig)"]
MongoDBLib -- Vector Indexes on --> VIdxApp["Applicability Embedding (E_raz)"]
SLI -->|Uses| LLMSLib["LLM Service (Embeddings & T_raz Generation)"]
subgraph "Storage & Search (MongoDB)"
direction LR
Records -- CRUD Ops --> MongoDBLib
VIdxContent -- Used by --> SemanticSearch["SmartLibrary.semantic_search()\n(MongoDB $vectorSearch)"]
VIdxApp -- Used by --> SemanticSearch
end
LLMSLib -- Generates E_orig, E_raz --> Records
LLMSLib -- Generates T_raz --> Records[metadata.applicability_text]
classDef infra fill:#eee,stroke:#666,stroke-width:1px,color:#333;
Diagram Note: MongoDBLib and LLMSLib are used to avoid name clashes with the main diagram's MongoDB and LLMS if rendered separately.
Manages inter-agent communication and capability discovery.
- Agent Registry (MongoDB Collection):
eat_agent_registry. Stores agent registration documents (id, name, capabilities, status, etc.). Key infrastructure agents likeMemoryManagerAgentare registered here.- Optionally, capability descriptions can be embedded (
capability_description_embedding) and stored here for semantic discovery of capabilities using MongoDB Vector Search.
- Optionally, capability descriptions can be embedded (
- Execution Logs (MongoDB Collection):
eat_agent_bus_logs. Stores logs of System and Data Bus operations, providing valuable data forComponentExperienceTrackerand auditing. - Role: Central nervous system for capability-based requests (Data Bus) and agent/service registration/discovery (System Bus).
- Discovery:
- Finds registered agents based on
capability_id(metadata query oneat_agent_registry). - For
task_description-based discovery, it can query agent descriptions (potentially with vector search ondescription_embeddingineat_agent_registry) or leverageSmartLibraryto find agent components suitable for the task.
- Finds registered agents based on
- Resilience: Circuit breakers (currently file-based, future MongoDB) help manage agent availability.
- Interface: Methods like
register_agent,discover_agents,request_capability, etc., now interact with MongoDB.
graph TD
SABI["AgentBus Interface"] -->|Manages| Reg["Agent Registry (MongoDB 'eat_agent_registry')"]
SABI -->|Logs to| ExecLogs["Execution Logs (MongoDB 'eat_agent_bus_logs')"]
SABI -->|Uses for Discovery| LLMSBus["LLM Service (for embedding query if vector searching descriptions)"]
SABI -->|Monitors| CB["Circuit Breakers (File-based)"]
Reg -- Optional Vector Index on --> AgentDescEmbeds["Agent Description Embeddings"]
Reg -- Optional Vector Index on --> CapEmbeds["Capability Description Embeddings"]
subgraph "Data Bus Communication (request_capability)"
direction LR
Requester --> SABI
SABI -->|"Finds Provider (Queries Reg)"| Reg
SABI -->|"Routes Request"| Provider["Agent/Tool Instance"]
Provider -->|"Returns Result"| SABI
SABI -->|"Returns Result"| Requester
end
Diagram Note: LLMSBus used for clarity. Discovery uses MongoDB queries (metadata or vector).
Data structure for passing task-relevant information between components, especially to agents.
- Role: Carries current task data, user input, intermediate results from previous steps, and a description of the current task (
current_task). - Enhancement via
ContextBuilderTool: It is dynamically enriched by theContextBuilderTool. This tool populates theSmartContextwith:- Summaries of relevant past experiences and message histories (retrieved via the
MemoryManagerAgentfromSmartMemory). - Information about relevant existing components (retrieved from
SmartLibrary). This provides agents likeSystemAgentwith deeper, historically-informed context for their current tasks.
- Summaries of relevant past experiences and message histories (retrieved via the
- Interaction with
SmartLibrary: Thecurrent_taskdescription it holds (often enhanced) is used bySmartLibrary.semantic_searchto leverage the dual embeddings (E_raz) for more accurate, task-aware component retrieval.
- Role: A specialized agent (potentially a
ReActAgent) designed to proactively analyze system performance, component experiences, and library structure to identify and suggest opportunities for evolution. It acts as a higher-level "improvement engine." - Data Sources for Analysis:
ComponentExperienceTracker: For quantitative performance metrics (success/failure rates, execution times, error frequencies) derived fromSmartAgentBuslogs or a dedicated metrics store.SmartMemory(viaMemoryManagerAgent): To analyze patterns in successful/failed experiences, understanding why components perform as they do in specific contexts. This provides qualitative insights.SmartLibrary: To understand the current inventory of components, their versions, and identify gaps or redundancies.- A/B Test Results (if applicable, from
eat_ab_test_resultscollection): To compare versions of components. LibraryAuditorAgentoutputs: Can consume reports about unused, orphaned, or low-performing components.
- Output: Evolution proposals or directives. These could be:
- Suggestions to
SystemAgent(e.g., "Evolve component X to better handle task Y, as it has failed N times. Consider incorporating logic from component Z which succeeded on similar tasks."). - Direct initiation of evolution tasks via
EvolveComponentToolif granted sufficient autonomy. - Proposals for creating entirely new components to fill identified capability gaps.
- Suggestions to
Providers(e.g.,BeeAIProvider,OpenAIAgentsProvider): Abstract the specifics of interacting with different underlying AI agent frameworks. They handle the creation and execution of agents built with those frameworks.AgentFactory: Uses theProviderRegistryto select the appropriateFrameworkProviderbased on a component's specified framework (e.g., "beeai", "openai-agents"). It then delegates agent creation to that provider. It can also instantiate tools directly if they are simple Python classes.
- Role: A simple Inversion of Control (IoC) container (
DependencyContainer) manages the instantiation and sharing of core singleton services likeMongoDBClient,LLMService,SmartLibrary,SmartAgentBus, and key agents likeSystemAgent,MemoryManagerAgent. - Benefits: Decouples components, simplifies initialization, and makes dependencies explicit. Components can request their dependencies from the container rather than instantiating them directly.
- Role: Provides a unified interface for interacting with Large Language Models (LLMs) for tasks like text generation, code generation, and text embedding.
- Frameworks: Utilizes
LiteLLM(viabeeai-framework) for broad compatibility with various LLM providers (OpenAI, Anthropic, Ollama, etc.). - Caching (
LLMCacheon MongoDB):- LLM completions and embedding results are cached to reduce redundant API calls, save costs, and speed up repeated operations.
- The cache (
eat_llm_cachecollection in MongoDB) uses Time-To-Live (TTL) indexes for automatic expiration of old entries.
- Role: The
Firmwareclass provides a mechanism to inject standardized governance rules, ethical guidelines, and operational constraints into agents and tools, particularly during their creation or evolution. - Functionality: It generates a base prompt incorporating general rules and can include domain-specific rules (e.g., for "medical" or "finance"). This prompt is typically prepended to the main instruction set given to LLMs when generating or modifying component code or behavior.
- Persistence: Firmware rules themselves are typically code-defined within the
Firmwareclass, not dynamically stored as individualSmartLibrarycomponents, though specific firmware configurations or overrides could potentially be.
- Role:
Adapters(e.g.,OpenAIToolAdapter,OpenAIGuardrailsAdapter) serve as bridges between EAT's internal component structures/interfaces and the specific requirements of external AI agent SDKs or frameworks (like OpenAI Agents SDK). - Functionality:
OpenAIToolAdapter: Converts EAT-compatible tools (e.g., BeeAI tools, dynamic tools) into a format usable by OpenAI Agents.OpenAIGuardrailsAdapter: Converts EAT'sFirmwareconcepts into input/output guardrails compatible with the OpenAI Agents SDK.
- Importance: They enable interoperability and allow EAT to leverage components and functionalities from various ecosystems.
- Role: Provides an optional human-in-the-loop (HITL) mechanism for reviewing and approving actions قبل execution, enhancing safety and control.
IntentPlanStorage (MongoDB Collection):eat_intent_plans.- When intent review is enabled for the "intents" level,
ProcessWorkflowToolgeneratesIntentPlanobjects (detailing each step, its parameters, and justification). - These
IntentPlanobjects are serialized and stored as documents in this MongoDB collection.
- When intent review is enabled for the "intents" level,
- Review Process:
- The
IntentReviewAgent(or a human user directly) uses tools likeApprovePlanTool. ApprovePlanToolloads theIntentPlanfrom MongoDB by itsplan_id, facilitates the review, and then updates the plan's status (e.g., "APPROVED", "REJECTED") and any reviewer comments directly in its MongoDB document.
- The
- Other Review Tools:
WorkflowDesignReviewToolandComponentSelectionReviewToolallow for earlier-stage reviews, though their outputs might not always be persisted as formalIntentPlanobjects unless they feed into one.
The SmartAgentBus is the central nervous system for the EAT ecosystem, facilitating both system-level management and data-level interactions between components. It operates as a dual-bus system, with distinct functionalities for managing the agent/tool registry and for routing capability requests. Both aspects now leverage MongoDB for persistence.
A. System Bus Functionality (Management & Discovery):
- Registration:
- Agents and tools (components) are registered with the
SmartAgentBususing tools likeRegisterAgentTool(typically invoked bySystemAgentor during system initialization fromSmartLibrary). - Registration involves providing metadata about the component, including its ID, name, type (AGENT/TOOL), description, and a list of capabilities it offers.
- This registration data is stored in the
eat_agent_registryMongoDB collection. Each entry includes the component's metadata and, importantly, an embedding of its description (description_embedding) if semantic discovery is enabled.
- Agents and tools (components) are registered with the
- Discovery:
- Agents (like
SystemAgent) can discover other components based on various criteria:- By Capability ID: Requesting all agents that offer a specific
capability_id. The bus queries theeat_agent_registryfor matching capability entries. - By Task Description (Semantic Discovery): An agent can provide a natural language
task_description. TheSmartAgentBus(or a tool likeDiscoverAgentTool) can:- Embed this
task_description. - Perform a vector search against the
description_embeddingfield in theeat_agent_registrycollection to find agents whose overall purpose matches the task. - Alternatively, it can leverage
SmartLibrary.semantic_searchto find component definitions (which might be more fine-grained) suitable for the task, and then check if those components are registered and active on the bus.
- Embed this
- By Capability ID: Requesting all agents that offer a specific
- Discovery results include information about the found agents, their status (e.g., active, circuit-broken), and potentially relevance scores.
- Agents (like
- Status Management: The bus can track the health and status of registered agents (e.g., using circuit breakers, though the state for these is currently file-based with plans to move to MongoDB).
B. Data Bus Functionality (Capability Request & Execution):
- Request Routing:
- When an agent (Requester) needs a specific capability performed (e.g.,
SystemAgentusingRequestAgentTool), it sends a request to theSmartAgentBus. - The request typically includes the
capability_idand thecontent(input data/parameters) for that capability. - The
SmartAgentBususes its registry (eat_agent_registry) to find one or more active and healthy agents (Providers) that offer the requestedcapability_idand meet any other criteria (like minimum confidence). - If multiple providers are found, the bus might employ a selection strategy (e.g., round-robin, load-based, highest confidence – currently simpler, often takes the first suitable).
- When an agent (Requester) needs a specific capability performed (e.g.,
- Execution:
- The bus routes the request
contentto the selected Provider agent/tool instance. - The Provider executes the capability using the provided
content. - The result of the execution is returned to the
SmartAgentBus.
- The bus routes the request
- Response Delivery: The
SmartAgentBusrelays the result back to the original Requester. - Logging: All significant Data Bus operations (requests, which agent handled it, success/failure, duration) are logged to the
eat_agent_bus_logsMongoDB collection. This provides an audit trail and data forComponentExperienceTracker.
C. Key Characteristics:
- Decoupling: Agents do not need direct references to each other. They request capabilities, and the bus handles routing. This promotes modularity and makes it easier to add, remove, or update components.
- Dynamic Discovery: The system can adapt to new agents becoming available or existing ones changing their capabilities.
- Centralized Management: The bus provides a central point for monitoring agent interactions and managing the ecosystem.
- Resilience (via Circuit Breakers): The bus can temporarily prevent requests to agents that are consistently failing, improving overall system stability.
- MongoDB Backend: Storing the registry and logs in MongoDB enhances scalability, persistence, and the ability to perform complex queries over historical interactions.
This dual-bus architecture, backed by MongoDB, is fundamental to EAT's ability to orchestrate a dynamic and evolving ecosystem of agents and tools.
The core logic for how SmartLibrary uses dual embeddings remains, but the task_context itself is now often significantly richer due to pre-processing by ContextBuilderTool which queries SmartMemory.
- Query Formulation:
SystemAgent(or another agent) has aquery(what it's looking for) and atask_description(the current task it's trying to solve). - Context Enrichment (via
ContextBuilderTool): Often, before searching the library,SystemAgentwill useContextBuilderTool. This tool queriesSmartMemory(viaMemoryManagerAgent) for relevant past experiences and message summaries related to thetask_description. It also queriesSmartLibraryfor an initial set of relevant components. The output ofContextBuilderToolprovides an enriched task context. - Embedding for Search:
LLMServiceembeds the originalquery(for E_orig) and the (potentially enriched)task_description(for E_raz). - Applicability Search (MongoDB
$vectorSearch):SmartLibrary.semantic_searchuses thetask_descriptionembedding (E_raz_query) to query theapplicability_embeddingfield in theeat_componentsMongoDB collection. This prioritizes components whose purpose aligns with the current task. - Refinement & Scoring:
SmartLibraryretrieves candidate component documents from MongoDB, which include theircontent_embedding(E_orig).- It calculates the similarity between the
queryembedding (E_orig_query) and each candidate'scontent_embedding. - A
final_scoreis computed by combining the task relevance score (from applicability search) and the content similarity score, often weighted (e.g.,task_weight). Usage history can also provide a small boost.
- Result:
SmartLibraryreturns a list of the most relevant component documents, ranked by theirfinal_score.
sequenceDiagram
participant Agent as Requesting Agent (e.g., SystemAgent)
participant CtxBuilder as ContextBuilderTool
participant MMA as MemoryManagerAgent
participant SL as SmartLibrary (MongoDB backed)
participant MongoDB as MongoDB (eat_components, eat_agent_experiences)
participant LLM_Emb as Embedding Service
Agent->>Agent: Formulate Initial Task Query / Description
Agent->>CtxBuilder: BuildContext(Task Description)
CtxBuilder->>MMA: RequestRelevantExperiences(Task Description via Bus)
MMA->>MongoDB: SemanticSearch on 'eat_agent_experiences'
MongoDB-->>MMA: Past Relevant Experiences
MMA-->>CtxBuilder: Experiences
CtxBuilder->>SL: StandardSearchForComponents(Task Description)
SL->>MongoDB: SemanticSearch on 'eat_components' (can use T_orig and T_raz)
MongoDB-->>SL: Relevant Library Components
SL-->>CtxBuilder: Library Components
CtxBuilder-->>Agent: Enriched SmartContext (contains experiences, components, original task)
Note over Agent: Agent now has richer context for its next action.
Agent->>Agent: Refine Query & Task Context (using Enriched SmartContext results)
Agent->>LLM_Emb: Embed Query (E_orig_query), Embed Task Context (E_raz_query)
LLM_Emb-->>Agent: Query Embeddings
Agent->>SL: semantic_search(Refined Query, Refined Task Context, ...)
SL->>MongoDB: $vectorSearch on 'applicability_embedding' with E_raz_query
MongoDB-->>SL: Top-K Candidate Component Documents
SL->>SL: Re-rank/Score (combining task and content similarity)
SL-->>Agent: Final Relevant Component Documents & Scores
This is a central flow enabled by the Smart Memory ecosystem:
- Task Initiation:
SystemAgentreceives a high-level goal. - Context Building (Proactive):
SystemAgentusesContextBuilderTool.ContextBuilderToolsends a request toMemoryManagerAgent(viaSmartAgentBus) with the current sub-task description.MemoryManagerAgentusesSemanticExperienceSearchToolto find relevant past experiences fromeat_agent_experiences.MemoryManagerAgentusesMessageSummarizationToolto summarize relevant recent message history (if provided toContextBuilderTool).ContextBuilderToolalso queriesSmartLibrary(MongoDBeat_components) for potentially relevant existing components.ContextBuilderToolreturns a structured dataset containing these findings toSystemAgent.
- Informed Planning & Action:
SystemAgentincorporates this rich context (past successes/failures, relevant components, message summaries) into its planning:- More accurate component selection (via
SearchComponentToolnow using better task context, or by directly choosing fromContextBuilderTool's suggestions). - Better workflow design (via
GenerateWorkflowTool). - More targeted parameters for tool/agent execution.
- More accurate component selection (via
- Task Execution:
SystemAgentorchestrates the execution of the planned steps. - Experience Recording: After a significant sub-task or the overall task is completed (or fails),
SystemAgentusesExperienceRecorderTool.ExperienceRecorderToolstructures the key details of the just-completed experience (goal, input summary, components used, decisions, output summary, outcome, reasoning snippets).- It sends this structured experience to
MemoryManagerAgent(viaSmartAgentBus). MemoryManagerAgentusesMongoExperienceStoreToolto save the experience (including generating its embeddings) into theeat_agent_experiencescollection in MongoDB.
- Learning Loop Closure: The newly recorded experience is now available for future
ContextBuilderToolqueries, allowing the system to learn and improve over time.
Smart Memory plays a vital role in making component evolution more targeted and effective:
- Identification of Need:
SystemAgentmight identify a need for evolution based on repeated failures for a specific task type (retrieved from Smart Memory).- Or,
EvolutionStrategistAgentmight analyzeeat_agent_experiencesandComponentExperienceTrackerdata to proactively suggest evolutions.
- Contextual Evolution Prompting: When
SystemAgentdecides to evolve a component usingEvolveComponentTool:- It first uses
ContextBuilderToolto gather context related to the component-to-be-evolved and the problem it's failing to solve (or the new capability needed). - This context (e.g., "Component X failed 3 times on task Y when input was Z, resulting in error W. Component A handles similar inputs P successfully.") is used to formulate a much more specific and informed "changes" description for
EvolveComponentTool.
- It first uses
- LLM-Driven Evolution:
EvolveComponentTooluses the LLM to generate new code based on the parent component's code and this rich, contextual "changes" description. - New Version in Library: The evolved component is saved as a new version in
SmartLibrary. - Future Use: This new, contextually-evolved component is now available for future tasks and will be discoverable via
SmartLibrarysearches, further improving system performance.
The SystemAgent uses GenerateWorkflowTool to create a YAML definition of steps based on a task or a design from ArchitectZero. This generation can be informed by context retrieved via ContextBuilderTool. The ProcessWorkflowTool then parses this YAML, substitutes parameters, and either:
- Converts it into an
IntentPlan(if intent review is enabled for 'intents'), which is saved to MongoDB (eat_intent_plans) for review. - Returns a list of processed steps for direct execution if intent review is not active for that stage.
The DependencyContainer is used at application startup to instantiate and wire together core services (MongoDBClient, LLMService, SmartLibrary, SmartAgentBus, Firmware) and key agents (SystemAgent, ArchitectZero, MemoryManagerAgent, IntentReviewAgent). This promotes loose coupling and centralized management of shared resources. Core components like SmartLibrary and SmartAgentBus have initialize() methods that might perform further setup, like loading data from MongoDB or syncing registries, once all their dependencies are available.
- Design Review (Optional):
SystemAgentcan useWorkflowDesignReviewToolto get human/AI feedback on a high-level solution design (e.g., fromArchitectZero) before detailed planning. - Component Selection Review (Optional):
SystemAgentcan useComponentSelectionReviewToolafter aSearchComponentToolrun to get human/AI validation of the chosen components. - Intent Plan Generation & Persistence: If intent review for the 'intents' level is active,
ProcessWorkflowTool(used bySystemAgent) generates a detailedIntentPlanobject. This object, containing each step, its parameters, and justification, is serialized and saved as a document in theeat_intent_plansMongoDB collection. Theplan_idis returned. - Intent Plan Review (Core):
SystemAgent(or a human operator) then usesApprovePlanTool, providing theplan_id.ApprovePlanToolloads theIntentPlanfrom MongoDB, facilitates interactive or AI-assisted review, and updates the plan's status (e.g., toAPPROVEDorREJECTED) and reviewer comments directly in its MongoDB document. - Execution Post-Approval: If the
IntentPlanisAPPROVED,SystemAgentwould typically load this approved plan (or its constituent intents) from MongoDB to guide the safe execution of the task.
sequenceDiagram
participant SysA as SystemAgent
participant PWT as ProcessWorkflowTool
participant MongoDBReview as MongoDB (eat_intent_plans)
participant Reviewer as IntentReviewAgent / Human
participant APT as ApprovePlanTool
Note over SysA: Task requires workflow
SysA->>PWT: ProcessWorkflow(workflowYAML, objective, ...)
Note over PWT: Intent Review Enabled for 'intents'
PWT->>PWT: Parse YAML, Substitute Params
PWT->>PWT: Validate Steps & Generate IntentPlan Object
PWT->>MongoDBReview: Save/Upsert IntentPlan Object (as document)
MongoDBReview-->>PWT: Confirm Save (e.g., plan_id)
PWT-->>SysA: Return plan_id (and status: intent_plan_created)
Note over SysA: Review Required for plan_id
SysA->>Reviewer: Request Intent Plan Review (Pass plan_id)
Reviewer->>APT: Use ApprovePlanTool (Input: plan_id)
APT->>MongoDBReview: Load IntentPlan document by plan_id
MongoDBReview-->>APT: Return IntentPlan document
Note over APT: Presents Plan to Reviewer for decision
APT->>Reviewer: Get Approval/Rejection Decision & Comments
Reviewer-->>SysA: Return Decision (Approved/Rejected, comments)
alt Plan Approved
APT->>MongoDBReview: Update IntentPlan document status to APPROVED, add comments
SysA->>MongoDBReview: (Later) Load Approved Intents from Plan for execution
SysA-->>Caller: Final Result
else Plan Rejected
APT->>MongoDBReview: Update IntentPlan document status to REJECTED, add reason
SysA->>SysA: Halt Execution / Report Rejection
SysA-->>Caller: Report Rejection / Failure
end
EAT is designed for interoperability. The ProviderRegistry and FrameworkProvider abstract base class allow integration with various agent frameworks (e.g., BeeAI, OpenAI Agents SDK). AgentFactory uses this registry to instantiate agents based on the framework specified in their SmartLibrary record. Adapters (like OpenAIToolAdapter) help bridge EAT's internal tool formats with those expected by specific SDKs. This modular design allows the EAT ecosystem to leverage agents and tools built with different technologies.
Safety and governance are integrated through:
Firmware: Injects common ethical and operational rules into components during their creation or evolution, guiding LLM behavior.- Intent Review System: Provides optional human-in-the-loop checkpoints at various stages (design, component selection, intent execution) to validate system plans and actions before they proceed. The persistence of
IntentPlans in MongoDB aids auditability. SmartAgentBusCircuit Breakers: Help prevent cascading failures by temporarily disabling agents that repeatedly fail or timeout.- Smart Memory: While primarily for learning, recorded experiences (especially failures and their contexts) can be analyzed to identify systemic risks or unsafe component behaviors, contributing to long-term safety improvements.
This enhanced architecture, with Smart Memory at its core, provides a more powerful foundation for EAT to achieve its goal of building adaptive, learning, and autonomously evolving AI agent systems. The ability to learn from rich, contextualized past experiences allows the system to make more intelligent decisions about current tasks and future evolutions.