SelfCorrecting Agent

A lightweight Python program that demonstrates a simple selfcorrecting 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 selfcorrecting 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.json in the current working directory.

Installation

The project requires Python3.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:

SelfCorrecting 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

SelfCorrecting Agent
Type … (truncated for brevity)
S
Description
BroJS: Экзамен: Самокорректирующийся агент
Readme MIT 128 KiB
Languages
Python 63.5%
JavaScript 22%
TypeScript 14.5%