-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Problem:
The Evolving Agents Toolkit (EAT) currently uses SmartContext for transient, task-specific context. It lacks a persistent, queryable long-term memory system that allows agents (especially SystemAgent) to learn from past workflows, decisions, and outcomes. This limits their ability to build cumulative knowledge and improve planning based on historical experience. The user desires a "smart memory based on agent goals, capabilities, and previous workflow tasks," a "smart list of messages," and a "mini database that is a memory and context that has database capabilities," all implemented following EAT's philosophy where "all is an agent or a tool."
Proposed Solution:
Implement an advanced "Smart Memory" system as an ecosystem of specialized agents and tools. This system will manage persistent storage (in MongoDB) of agent experiences and contextual facts. Core agents like SystemAgent will interact with this memory ecosystem via dedicated tools to retrieve relevant historical information, build richer contexts for sub-tasks, and record new learnings.
Key New Agents and Tools:
-
MemoryManagerAgent(New Agent):- Purpose: The central agent responsible for orchestrating the storage and retrieval of long-term memories and contextual facts. It acts as an interface to the underlying MongoDB memory collections.
- LLM: Can be a relatively simple LLM, primarily focused on understanding requests for its tools.
- Capabilities (exposed via
SmartAgentBus):store_agent_experience: Allows other agents to submit structured data about a completed task/workflow to be stored.retrieve_relevant_experiences: Allows agents to query for past experiences relevant to a current goal or task.summarize_message_history: (Could be a capability) Takes a list of messages and a target goal, returns a concise summary.- (Optional)
store_contextual_fact,retrieve_contextual_facts.
- Internal Tools (not directly exposed, used by
MemoryManagerAgentitself):MongoExperienceStoreTool: Interacts with theeat_agent_experiencesMongoDB collection (CRUD operations, embedding generation for queryable fields if not handled by direct Mongo write).MongoFactStoreTool(Optional): Interacts witheat_contextual_facts.SemanticExperienceSearchTool: Performs semantic searches over theeat_agent_experiencescollection using embedded fields.MessageSummarizationTool: Uses an LLM to summarize message lists.
-
ContextBuilderTool(New Tool forSystemAgentand other complex agents):- Purpose: Dynamically constructs an optimized
SmartContextobject to be passed to another agent for a specific sub-task. This tool encapsulates the logic of assembling relevant information. - Functionality (invoked by
SystemAgent):- Receives: target agent details, assigned sub-task/goal description, current broad workflow context (e.g.,
SystemAgent'sSmartContext). - Uses
RequestAgentTool(fromSmartAgentBustools) to callMemoryManagerAgent.retrieve_relevant_experienceswith the sub-task/goal. - Uses
RequestAgentToolto callMemoryManagerAgent.summarize_message_history(if needed) on the current long message history, tailored to the sub-task. - Queries
SmartLibrary(usingSearchComponentTool) for components relevant to the sub-task, potentially using context from retrieved experiences. - Assembles a new, lean
SmartContextinstance containing:- The specific
current_taskdescription for the recipient. - Summaries of highly relevant past experiences from
MemoryManagerAgent. - The "smart list of messages" (summarized history).
- Pointers/metadata of necessary components from
SmartLibrary.
- The specific
- Returns the populated
SmartContextobject (or its JSON representation).
- Receives: target agent details, assigned sub-task/goal description, current broad workflow context (e.g.,
- Purpose: Dynamically constructs an optimized
-
ExperienceRecorderTool(New Tool forSystemAgentand other agents):- Purpose: Facilitates the recording of completed tasks/workflows as structured experiences.
- Functionality (invoked by
SystemAgentafter a significant task/workflow):- Receives: summary of the goal, components involved, input context summary, key decisions, final outcome, output summary, and any feedback.
- Structures this data into the format expected by
MemoryManagerAgent.store_agent_experience. - Uses
RequestAgentToolto callMemoryManagerAgent.store_agent_experienceto persist the memory.
MongoDB Collections (Managed by MemoryManagerAgent's internal tools):
eat_agent_experiences: (As defined in the previous version of this issue) Stores records of completed tasks/workflows with embeddable fields for semantic search.experience_id,primary_goal_description(embedded),sub_task_description(embedded),initiating_agent_id,involved_components,input_context_summary(embedded),key_decisions_made,final_outcome,output_summary(embedded),feedback_signals,timestamp.
- (Optional)
eat_contextual_facts: For atomic learned facts.
Workflow:
SystemAgentPlanning:- When
SystemAgentreceives a new complex goal, it can useContextBuilderToolto query for relevant past experiences related to this goal before generating a detailed plan. - The
ContextBuilderToolinternally callsMemoryManagerAgent.retrieve_relevant_experiences. - The retrieved experiences inform
SystemAgent's decision on component selection, workflow structure, etc.
- When
SystemAgentTask Delegation:- When
SystemAgentdelegates a sub-task to a worker agent (viaSmartAgentBus.request_capability), it first usesContextBuilderTool. ContextBuilderToolcrafts a tailoredSmartContextfor the worker agent, including relevant past experiences and a summarized message history related to the sub-task.
- When
- Worker Agent Execution:
- The worker agent receives this rich, relevant
SmartContext.
- The worker agent receives this rich, relevant
SystemAgentRecording Experience:- After a workflow (or a significant part of it) is completed,
SystemAgentusesExperienceRecorderTool. ExperienceRecorderToolformats the outcome and callsMemoryManagerAgent.store_agent_experienceto save the learning.
- After a workflow (or a significant part of it) is completed,
Tasks:
- Define Schemas: Finalize MongoDB document structures for
eat_agent_experiences(andeat_contextual_factsif pursued). - Implement
MemoryManagerAgent:- Develop its internal tools (
MongoExperienceStoreTool,SemanticExperienceSearchTool,MessageSummarizationTool). - Define its
AgentMetaand capabilities for theSmartAgentBus. - Implement its
ReActAgentlogic to handle requests for its capabilities by calling its internal tools.
- Develop its internal tools (
- Implement
ContextBuilderTool:- Develop the logic as described above, ensuring it interacts with
MemoryManagerAgent(via bus) andSmartLibrary.
- Develop the logic as described above, ensuring it interacts with
- Implement
ExperienceRecorderTool:- Develop logic to structure data and call
MemoryManagerAgent(via bus).
- Develop logic to structure data and call
- Integrate Tools with
SystemAgent:- Add
ContextBuilderToolandExperienceRecorderTooltoSystemAgent's available tools. - Modify
SystemAgent's main ReAct loop:- To use
ContextBuilderToolduring planning and before delegating tasks. - To use
ExperienceRecorderToolafter completing significant tasks.
- To use
- Add
- Register
MemoryManagerAgent: EnsureMemoryManagerAgentis created and registered on theSmartAgentBusduring EAT initialization. - Testing: Create multi-step scenarios to test:
MemoryManagerAgent's ability to store and retrieve experiences.ContextBuilderTool's effectiveness in creating relevant, lean contexts.ExperienceRecorderTool's ability to correctly log experiences.SystemAgent's improved planning and context passing due to the new memory ecosystem.
- Documentation: Update
ARCHITECTURE.mddescribing the new Smart Memory agent-tool ecosystem.
Acceptance Criteria:
MemoryManagerAgentis functional and registered on theSmartAgentBus, managing experience data in MongoDB.ContextBuilderToolandExperienceRecorderToolare implemented and usable bySystemAgent.SystemAgentdemonstrates use of these tools to:- Retrieve relevant past experiences to inform its current planning.
- Construct and pass tailored
SmartContext(with summarized messages and relevant experience insights) to sub-agents. - Record outcomes of its orchestrations into the persistent memory via
MemoryManagerAgent.
- The "smart list of messages" (summarized message history) functionality is evident in the context passed between agents.
- The "mini-database" capability (querying
eat_agent_experiences) is demonstrable throughMemoryManagerAgent.retrieve_relevant_experiences. - The entire system adheres to the "everything is an agent or a tool" philosophy for memory management.
Potential Challenges:
- Defining effective prompts and logic for
MemoryManagerAgent's internal tools (especiallyMessageSummarizationToolandSemanticExperienceSearchTool). - Ensuring the
ContextBuilderTooldoesn't become a bottleneck; its operations (multiple LLM calls, bus requests) need to be efficient. - The complexity of
SystemAgent's ReAct loop increases with the integration of these new memory tools. - Robustly defining what constitutes a "significant task" worthy of being recorded as an experience.