7ae19c1b893e37f18af86d214f5f12719658d618
Self‑Correcting Agent
A lightweight Python program that demonstrates a simple self‑correcting agent.
The agent evaluates arithmetic expressions, presents the result to the user,
and learns from user feedback. Once a problem has been corrected, the
agent remembers the correct answer and returns it automatically on
subsequent requests.
Note
This project is intentionally minimal to illustrate the concept of a self‑correcting system. It is not intended for production use.
Features
- Safe evaluation of arithmetic expressions (
+,-,*,-,**). - Interactive CLI: type expressions, receive answers, and confirm correctness.
- Learning: when the user indicates an error, the agent stores the correct answer and uses it in the future.
- Persistence: learned knowledge is saved to
knowledge.jsonin the current working directory.
Installation
The project requires Python 3.8 or newer.
# Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent.git
cd ekzamen-samokorrektiruyuschiysya-agent
# (Optional) Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\\Scripts\\activate
# Install dependencies (none required for the core functionality)
pip install -r requirements.txt # Empty file, kept for compatibility
Usage
Run the program from the command line:
python -m src.index
You will see a prompt:
Self‑Correcting Agent
Type 'exit' to quit.
Enter problem:
Enter an arithmetic expression, e.g.:
Enter problem: 2 + 3 * 4
The program will output:
Answer: 14
Is this correct? (y/n):
- y if the answer is correct.
- n and then provide the correct answer if the program made a mistake.
To exit, type exit or quit.
Example Session
Self‑Correcting Agent
Type … (truncated for brevity)
Languages
Python
63.5%
JavaScript
22%
TypeScript
14.5%