Files
8.-samopisnyy-poiskovyy-age…/README.md
T
kuzakhmetovartur 9dafd2991f
CI / build (3.1) (push) Has been cancelled
CI / build (3.11) (push) Has been cancelled
CI / build (3.8) (push) Has been cancelled
CI / build (3.9) (push) Has been cancelled
feat: solution for '8. Самописный поисковый агент на основе deep agents from scratch'
2026-07-01 13:41:05 +03:00

2.1 KiB
Raw Blame History

Custom Search Agent DeepAgents from Scratch

This repository contains a minimal implementation of a deep search agent that:

  • Generates deterministic mock search results.
  • Creates virtual files in memory during execution.
  • Exports those virtual files to a specified directory on disk.

The agent is fully selfcontained, does not rely on external APIs, and is fully testable.

Project Structure

.
├── src
│   ├── agent.py      # Core agent implementation
│   └── run.py        # CLI entry point
├── tests
│   └── test_agent.py # Unit tests
├── requirements.txt
└── README.md

Installation

# Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Usage

Commandline

python -m src.run --query "python" --output "./search_results"

This will:

  1. Search for "python" (mock results).
  2. Create two virtual files (result_1.txt, result_2.txt) in memory.
  3. Export those files to ./search_results.

Programmatic

from src.agent import CustomSearchAgent

agent = CustomSearchAgent(max_results=3)
results = agent.search("deep learning")
print(results)          # List of (title, snippet) tuples
agent.export_virtual_files("./output")

Testing

Run the unit tests with:

python -m unittest discover -s tests

All tests should pass, confirming that:

  • The agent initializes correctly.
  • Search results are deterministic.
  • Virtual files are created during search.
  • Export writes the correct files to disk.

Extending the Agent

The CustomSearchAgent inherits from DeepAgent. To add real search logic:

  1. Override search to perform actual queries (e.g., to a local index).
  2. Use create_virtual_file to store any generated data.
  3. Call export_virtual_files when you need to persist the data.

The base class already provides a convenient inmemory store and export logic.

License

This project is released under the MIT License.