Hardware-aware dependency compatibility framework for Python ML stacks
Project description
๐พ Compatibillabuddy
An autonomous AI agent that diagnoses AND repairs broken Python ML environments โ with self-correction.
Built for the Google DeepMind ร Devpost Gemini API Hackathon โ Marathon Agent Track
๐ง An autonomous system that plans, executes, verifies, and self-corrects โ not a chatbot, not a prompt wrapper.
The Problem
$ pip install torch numpy pandas scikit-learn
# โ
Successfully installed ...
$ python -c "import torch; print(torch.cuda.is_available())"
# โ False โ wrong CUDA version for your GPU driver
$ python -c "import sklearn"
# โ ImportError: numpy ABI incompatibility
ML environments don't just have version conflicts โ they have hardware mismatches, ABI breaks, and runtime incompatibilities that pip, uv, and poetry can't catch. These failures waste hours of developer time across the ML ecosystem.
Compatibillabuddy treats hardware as a first-class dependency and ships an autonomous Gemini-powered agent that can diagnose AND repair these issues without human intervention.
How It Works
flowchart TD
A["๐ง User: 'Fix my environment'"] --> B["๐ธ Snapshot Environment"]
B --> C["๐ฉบ Run Doctor (diagnose)"]
C --> D{Issues Found?}
D -- No --> E["โ
Report: Environment Healthy"]
D -- Yes --> F["๐ง Gemini Plans Fix Order"]
F --> G["๐ง Execute Fix (pip install/uninstall)"]
G --> H["๐ Verify Fix (re-diagnose)"]
H --> I{Improved?}
I -- Yes --> J{More Issues?}
J -- Yes --> G
J -- No --> K["โ
Report: All Fixed + Changelog"]
I -- No --> L["โช Rollback to Snapshot"]
L --> M["๐ Try Alternative Fix"]
M --> H
The agent doesn't guess โ it runs real diagnostics via structured tools, executes real pip commands with safety guardrails, and verifies every fix before moving on. If a fix makes things worse, it rolls back automatically and tries an alternative.
Installation
# Core framework (no AI, works offline)
pip install compatibillabuddy
# With Gemini-powered AI agent
pip install "compatibillabuddy[agent]"
Quick Start
1. Diagnose Your Environment (No AI Required)
# Human-readable console report
compatibuddy doctor
# Machine-readable JSON
compatibuddy doctor --format json
# Save to file
compatibuddy doctor --output report.json --format json
2. Autonomous Repair (Gemini Agent)
# Set your API key
export GEMINI_API_KEY="your-key-here" # Linux/Mac
$env:GEMINI_API_KEY = "your-key-here" # PowerShell
# Dry run โ see what the agent WOULD do (safe, default)
compatibuddy repair
# Live mode โ actually execute fixes
compatibuddy repair --live
# JSON output for programmatic use
compatibuddy repair --format json
# Choose model and retry limits
compatibuddy repair --model gemini-2.5-pro --max-retries 5
3. Interactive Chat
# Start an interactive session with the agent
compatibuddy agent
# You: What GPU do I have?
# Agent: [calls tool_probe_hardware] You have an NVIDIA RTX 4090 with CUDA 12.3...
# You: Run a diagnosis
# Agent: [calls tool_run_doctor] Found 2 issues...
# You: Fix the CUDA mismatch
# Agent: [calls tool_snapshot_environment, tool_run_pip, tool_verify_fix] ...
Architecture
compatibillabuddy/
โโโ hardware/ # GPU detection, nvidia-smi parsing, platform info
โ โโโ probe.py # probe_hardware() โ HardwareProfile
โ โโโ inspector.py # inspect_environment() โ EnvironmentInventory
โโโ kb/ # Knowledge base of known-bad combinations
โ โโโ engine.py # TOML rulepack loader + evaluator
โ โโโ rulepacks/ # Community-extensible rule definitions
โ โโโ ml_core.toml
โโโ engine/ # Core diagnosis orchestrator
โ โโโ models.py # Pydantic v2 models (GPU, packages, issues)
โ โโโ doctor.py # diagnose() โ DiagnosisResult
โ โโโ report.py # Rich console + JSON report formatters
โโโ agent/ # Gemini-powered autonomous agent
โ โโโ config.py # API key resolution, model selection
โ โโโ tools.py # 9 tools: diagnose, repair, snapshot, rollback
โ โโโ core.py # AgentSession: chat loop + auto_repair()
โโโ cli/ # Typer CLI
โโโ doctor.py # compatibuddy doctor
โโโ agent.py # compatibuddy agent (interactive)
โโโ repair.py # compatibuddy repair (autonomous)
Agent Tools
The Gemini agent has access to 9 structured tools โ not arbitrary shell access:
| Tool | Purpose |
|---|---|
tool_probe_hardware |
Detect OS, CPU, GPU, CUDA version |
tool_inspect_environment |
List all installed Python packages |
tool_run_doctor |
Full compatibility diagnosis |
tool_explain_issue |
Detailed explanation of a specific issue |
tool_search_rules |
Search knowledge base for rules about a package |
tool_snapshot_environment |
Capture pip freeze as rollback point |
tool_run_pip |
Execute pip install/uninstall with safety guardrails |
tool_verify_fix |
Re-diagnose and compare before/after |
tool_rollback |
Restore packages to a previous snapshot |
Safety Guardrails
The repair agent operates under strict safety constraints:
- Virtual environment isolation โ refuses to modify system Python
- Snapshot before every change โ full rollback capability
- Dry-run by default โ shows what it would do without executing
- Protected package blocklist โ never uninstalls pip, setuptools, wheel, or itself
- Operation limit โ stops after 10 pip commands per session
- Only pip install/uninstall โ no arbitrary shell commands
- Automatic rollback โ if a fix introduces new problems, reverts immediately
What Makes This Different
| Feature | Compatibillabuddy | Generic AI Chatbot |
|---|---|---|
| Runs real diagnostics | โ Structured tool calls | โ Guesses from description |
| Executes real fixes | โ pip commands with guardrails | โ "Try running this command..." |
| Verifies every fix | โ Re-diagnoses after each change | โ No verification |
| Self-corrects | โ Rollback + alternative on failure | โ No error recovery |
| Works offline | โ
compatibuddy doctor (no AI) |
โ Requires API |
| Hardware-aware | โ GPU/CUDA as first-class dependency | โ Ignores hardware |
| Extensible rules | โ TOML rulepacks, community-driven | โ Hardcoded knowledge |
| Production quality | โ PyPI, 280+ tests, CI/CD | โ Demo/prototype |
Known Compatibility Rules
The bundled ml_core.toml rulepack covers:
- CUDA mismatches โ PyTorch, TensorFlow, JAX vs. detected CUDA version
- NumPy ABI breaks โ pandas, scikit-learn, scipy built against incompatible NumPy
- Driver conflicts โ GPU driver version vs. framework requirements
Rules are written in TOML and can be extended by the community:
[[rule]]
id = "cuda-torch-mismatch"
description = "PyTorch installed without CUDA support on a CUDA-capable system"
severity = "error"
category = "cuda-mismatch"
fix_suggestion = "pip install torch --index-url https://download.pytorch.org/whl/cu121"
[rule.when]
package_installed = "torch"
gpu_vendor = "nvidia"
Development
git clone https://github.com/jemsbhai/compatibillabuddy.git
cd compatibillabuddy
pip install -e ".[all]"
# Run tests
pytest
# Lint
ruff check src/ tests/
ruff format --check src/ tests/
# Integration tests (requires GEMINI_API_KEY)
pytest tests/integration/ -m integration -v
Tech Stack
- Python 3.10+ (tested on 3.10โ3.13)
- Pydantic v2 โ structured data models with JSON schema export
- Typer + Rich โ CLI with beautiful terminal output
- google-genai SDK โ Gemini function calling for the agent
- packaging โ PEP 440 version matching
- pytest โ 280+ tests with CI on 3 OS ร 4 Python versions
- Hatchling โ modern Python build backend
License
MIT โ see LICENSE.
Author
Muntaser Syed โ muntaser@ieee.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compatibillabuddy-0.2.1.tar.gz.
File metadata
- Download URL: compatibillabuddy-0.2.1.tar.gz
- Upload date:
- Size: 57.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56ab0d2e7e386fbfb556c128406e779040bda5a01444495d7e829dd567b3a1c8
|
|
| MD5 |
ddd134807d082cc1c3ea013e98bcf026
|
|
| BLAKE2b-256 |
0970a974971865fc6a18d1e648a6a66a6175c18a22892c1bd1ae248c623d1944
|
Provenance
The following attestation bundles were made for compatibillabuddy-0.2.1.tar.gz:
Publisher:
release.yml on jemsbhai/compatibillabuddy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compatibillabuddy-0.2.1.tar.gz -
Subject digest:
56ab0d2e7e386fbfb556c128406e779040bda5a01444495d7e829dd567b3a1c8 - Sigstore transparency entry: 934950049
- Sigstore integration time:
-
Permalink:
jemsbhai/compatibillabuddy@7f9113fc17120def1ee545b72d742baeea2d5c60 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jemsbhai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f9113fc17120def1ee545b72d742baeea2d5c60 -
Trigger Event:
push
-
Statement type:
File details
Details for the file compatibillabuddy-0.2.1-py3-none-any.whl.
File metadata
- Download URL: compatibillabuddy-0.2.1-py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
706ff116aa5b4964a6d4112728834bdae9b40b26da9ffc49f4f52bcf6e7d93b2
|
|
| MD5 |
60c79458ec8cd44a4121102f37a270a6
|
|
| BLAKE2b-256 |
df483335ae593359f96955a665024b6869522d541cf733906e62b3477485e832
|
Provenance
The following attestation bundles were made for compatibillabuddy-0.2.1-py3-none-any.whl:
Publisher:
release.yml on jemsbhai/compatibillabuddy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compatibillabuddy-0.2.1-py3-none-any.whl -
Subject digest:
706ff116aa5b4964a6d4112728834bdae9b40b26da9ffc49f4f52bcf6e7d93b2 - Sigstore transparency entry: 934950083
- Sigstore integration time:
-
Permalink:
jemsbhai/compatibillabuddy@7f9113fc17120def1ee545b72d742baeea2d5c60 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jemsbhai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f9113fc17120def1ee545b72d742baeea2d5c60 -
Trigger Event:
push
-
Statement type: