System Architecture
Core Features
Data Management
Frontend Components
Backend Systems
The following files were used as context for generating this wiki page:
This page outlines key aspects of the developer workflow within the project, focusing on code quality enforcement and the implementation of advanced agent capabilities. It covers the use of pre-commit hooks to maintain code standards and the Mem0Teachability component, which enhances agent intelligence by enabling memory and learning from interactions.
The developer workflow is designed to ensure consistent code style, identify potential issues early in the development cycle, and provide robust, intelligent agent functionalities through memory management.
The project utilizes pre-commit hooks to automate code quality checks and formatting before commits are made. This ensures that all committed code adheres to defined standards, reducing the overhead of manual reviews and maintaining a clean, consistent codebase.
The configuration specifies two primary hooks for Python files: ruff for linting and formatting, and isort for sorting import statements.
The .pre-commit-config.yaml file defines the hooks.
repos:
- repo: local
hooks:
- id: ruff
name: Ruff
entry: ruff check
language: system
types: [python]
args: [--fix]
- id: isort
name: isort
entry: isort
language: system
types: [python]
args: ["--profile", "black"]Sources: .pre-commit-config.yaml:1-15
To use these hooks, ensure pre-commit is installed (pip install pre-commit) and initialized in your repository (pre-commit install).
The following flowchart illustrates the typical developer workflow involving pre-commit hooks.
The Mem0Teachability class is a crucial component that enhances the capabilities of autogen agents by integrating memory management through the mem0 library. This allows agents to "remember" information, tasks, and advice from past conversations, making them more intelligent and adaptable over time.
Mem0Teachability Class OverviewMem0Teachability is an AgentCapability designed to be added to ConversableAgent instances. It intercepts messages to store new information (teachings) and retrieve relevant past information to augment current conversations.
The Mem0Teachability class can be configured with several parameters during instantiation.
The add_to_agent method integrates Mem0Teachability with a ConversableAgent. It registers a hook to process every last received message and updates the agent's system message to reflect its new memory capabilities.
The process_last_received_message method is registered as a hook for the process_last_received_message event on the ConversableAgent. This ensures that every incoming message is evaluated for memory storage and retrieval.
An internal TextAnalyzerAgent is initialized using the agent's llm_config. This analyzer is crucial for interpreting messages to extract tasks, advice, questions, and answers for memory operations.
The agent's system_message is augmented with a note indicating its new ability to remember user teachings, informing the LLM of its enhanced capabilities.
When an agent receives a message, the process_last_received_message hook is triggered. This method orchestrates the interaction with the mem0 client, deciding whether to retrieve relevant memories, store new information, or both.
_consider_memo_storage)This method analyzes the incoming message to identify information suitable for storage. It uses the TextAnalyzerAgent to determine if the message contains a task/advice pair or a question/answer pair.
mem0.mem0.
Sources: cookbooks/helper/mem0_teachability.py:49-87_consider_memo_retrieval)This method retrieves relevant memories from mem0 based on the current message.
mem0 for question-answer pairs that are relevant to the input message, using the recall_threshold and max_num_retrievals parameters.mem0._analyze)The _analyze method is a private helper that uses the TextAnalyzerAgent to interpret parts of the conversation. It sends the text to be analyzed along with specific instructions to the TextAnalyzerAgent and returns its response. This is critical for extracting structured information (tasks, advice, questions, answers) from natural language.
Sources: cookbooks/helper/mem0_teachability.py:116-123