Files
self-healing-demo-v1/agent.py
OpenHarness Self-Heal 2453ce884d Fix controlled-failure crash in run skill
The 'run' skill raised RuntimeError for scenario='controlled-failure',
causing HTTP500 in production. Return the safe recovered result instead,
matching the existing regression test.

Fingerprint: 8c31f04b20bc68ab54843d6f
2026-07-18 12:09:54 +00:00

30 lines
1.1 KiB
Python

from __future__ import annotations
from a2a_pack import A2AAgent, NoAuth, RunContext, skill
class SelfHealingDemo(A2AAgent):
name = "self-healing-demo-v1"
description = "A live demonstration of bounded, auditable source self-repair."
version = "0.1.0"
@skill(description="Return the current self-healing demo state.")
async def status(self, ctx: RunContext[NoAuth]) -> dict[str, object]:
return {
"ok": True,
"agent": self.name,
"message": "The agent is online. Trigger the controlled failure once to exercise repair.",
}
@skill(description="Run the demo workflow, including its controlled production failure.")
async def run(
self,
ctx: RunContext[NoAuth],
scenario: str = "normal",
) -> dict[str, object]:
if scenario == "controlled-failure":
# Repaired: the controlled invoice total handler previously raised a
# RuntimeError. It now returns the safe recovered result.
return {"ok": True, "scenario": scenario, "result": "recovered"}
return {"ok": True, "scenario": scenario, "result": "healthy"}