Failure-Mode Audit Kit
The 7 Silent Killers of Production AI Agents
graph/nodes.py · FM-01
from pydantic import BaseModel, ValidationError
class UpdateDeal(BaseModel):
deal_id: str
stage: Literal["open", "won", "lost"]
def call_tool(state: GraphState):
try:
args = UpdateDeal.model_validate_json(state["tool_call"])
return {"validated_args": args, "error": None}
except ValidationError as e:
# feed the exact traceback into the self-correction node
return {"error": str(e), "attempts": state["attempts"] + 1}
graph.add_conditional_edges("call_tool",
lambda s: "self_correct" if s["error"] and s["attempts"] < 3 else "execute")