· via dev.to (home feed)
SelfHeal beta brings verified, reversible LLM patching to running Python apps
A beta tool called SelfHeal detects failing Python functions, asks an LLM for a patch, verifies it with syntax checks and pytest in a copied workspace, then hot-swaps the code after approval, with rollback if activation fails.

SelfHeal enters beta
A new project called SelfHeal is taking aim at one of the more tedious parts of operating software: the failure that happens while an application is running. According to a post on dev.to by user sanu_sharma00, SelfHeal watches Python functions for trouble — an exception, or a failed health check — and responds by asking a large language model to write a patch. The repaired code is then verified in an isolated copy of the workspace, and only swapped into the live function once it passes and a human signs off.
The package installs from pip as pyselfheal-rt and is imported under the name selfheal. The announcement describes it as a Python SDK built around a Rust core, with the code published on GitHub under sanusharma-ui/selfheal. It is explicitly a beta, so the usual caveats about stability and changing interfaces apply.
How the repair pipeline works
The dev.to post lays out a multi-stage flow designed to keep an autonomous patcher on a short leash:
- A function under SelfHeal's watch fails, either by raising an error or by failing a health check.
- The failure is handed to an LLM, which is asked to produce a patch.
- The patch is applied in a copied workspace rather than directly in the live process.
- The patched code is verified with a syntax check and a pytest run.
- If verification succeeds and the operator approves, the running function is updated with the repaired version.
- If activation then fails, SelfHeal rolls back to the previous implementation.
Two design choices stand out. First, the LLM never writes straight into the running system: its output has to clear the copied workspace and the verification stage before anything else happens. Second, the approval gate means a patch cannot go live silently — a human is in the loop before any live code changes, which matters for anything serving production traffic or handling user data.
Verification and rollback
The safety story rests heavily on the verification stage. A syntax check catches obviously broken output, and a pytest run exercises the patched code against the project's existing tests before activation. That makes the quality of a team's test suite the effective safety net: thin coverage means a weak check, while a well-tested function gives the pipeline real evidence that a patch behaves as intended.
Rollback covers the remaining gap. Even a patch that passes verification can misbehave once it meets live conditions, and in that case the tool reverts to the prior version of the function. The goal is that a bad repair does not leave the application in a worse state than the original failure.
It is worth noting what the automated checks do not do: they do not review the patch for correctness beyond what the tests cover, and they do not judge whether the LLM's fix addresses the root cause rather than a symptom. The human approval step is where those judgements land, which keeps the operator relevant even as the mechanical work is automated.
Why it matters
SelfHeal sits in a small but growing niche: tools that let LLMs act on live systems rather than just suggest code in an editor. Hot-patching a running process has traditionally been treated as a last resort, because an incorrect change can compound an outage instead of fixing one. SelfHeal's answer is to combine the three ingredients that make automated repair plausible at all — isolated verification, human approval and reversible activation — on top of an LLM patch generator, packaged so an ordinary Python codebase can opt specific functions in.
For teams, the interesting question is whether this model earns trust on low-stakes failures first, such as a misbehaving utility function or a flaky endpoint, before anyone points it at critical paths. As a beta announced in a single dev.to post, SelfHeal is more a signal of direction than a finished product. But the direction — LLM-driven maintenance of running software, with verification and rollback as first-class features rather than afterthoughts — is one worth watching.
- #python
- #llm
- #ai-tools
- #open-source
- #debugging