Agent with RAG Memory
This repository contains a lightweight implementation of an agent that can interact with a Retrieval‑Augmented Generation (RAG) knowledge base. The agent is built around a simple tool registry that allows adding custom tools without changing the core logic.
Features
- Knowledge Base Tool – A file‑based key/value store that can be queried, added to, and deleted from by both the agent and the CLI.
- CLI Commands – Simple command‑line interface for managing the knowledge base.
- Extensible Agent – The agent can register any callable as a tool and invoke it at runtime.
Installation
# Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/agent-s-rag-pamyatyu.git
cd agent-s-rag-pamyatyu
# Create a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
# Install the package
pip install .
Knowledge Base
The knowledge base is a simple JSON file (knowledge_base.json) that
stores key/value pairs. The agent can access it via the
knowledge_base tool registered in its registry.
CLI Usage
The package exposes a console script named kb. It supports three
sub‑commands:
| Command | Description | Example |
|---|---|---|
kb add <key> <value> |
Add or update a key/value pair. | kb add greeting "Hello, world!" |
kb query <key> |
Retrieve the value for a key. | kb query greeting |
kb delete <key> |
Delete a key/value pair. | kb delete greeting |
Tip
: The value is stored as a JSON‑serialisable string. For complex data structures, pass a JSON string (e.g.
"[1, 2, 3]").
Agent Usage
from src.agent import Agent
agent = Agent()
# Add a fact
agent.tools["knowledge_base"].add_entry("author", "Artur Kuzakhmetov")
# Retrieve a fact
print(agent.get_fact("author")) # Output: Artur Kuzakhmetov
Project Structure
src/
├── agent.py # Core agent implementation
├── knowledge_base.py # Knowledge base tool
└── cli.py # CLI entry point
Running Tests
The repository currently does not ship with automated tests, but you can manually verify the functionality:
# Add a fact
kb add foo "bar"
# Query it
kb query foo
# Delete it
kb delete foo
License
MIT License
Feel free to extend the agent with additional tools or integrate it into a larger RAG pipeline.
Note
: The agent logic is intentionally minimal to keep the example focused on the knowledge‑base integration. You can add more sophisticated reasoning or LLM integration as needed.
Author: Artur Kuzakhmetov
Repository: https://git.brojs.ru/kuzakhmetovartur/agent-s-rag-pamyatyu
Version: 14 (as of 30.06.2026)
Deadline: 31.08.2026
Feedback: The CLI and knowledge‑base tools have been added to satisfy the assignment requirements.
Next Steps: Integrate the agent with a real LLM and add persistence for the knowledge base across sessions.
Contact: artur@example.com
Enjoy!
End of README