पाठ 18 / 25

Tool Errors और छटपटाहट

Model को उपयोगी errors लौटाएँ पर जब विफलताएँ जमा होती रहें तो रुक जाएँ।

सुधरने दें, पर एक हद तक

Tool विफल हो तो error को tool result के रूप में (error चिह्नित करके) लौटाएँ ताकि model सुधर सके, जैसे ग़लत argument ठीक करना। पर errors आते रहें तो model छटपटा रहा है। लगातार विफलताएँ गिनें, और कुछ बार के बाद आख़िरी error के साथ रुककर आगे भेजें।

Error result लौटाना

is_error flag model को बताता है कि call विफल हुआ। लगातार गिनती किसी भी सफलता पर शून्य हो जाती है।

try:
    content, ok = run_tool(block.name, block.input), True
except Exception as exc:
    content, ok = f"Tool failed: {exc}", False

results.append({"type": "tool_result", "tool_use_id": block.id,
                "content": content, "is_error": not ok})
failures = 0 if ok else failures + 1
if failures >= 3:
    return escalate("3 consecutive tool failures", last_error=content)

त्वरित जाँच: लगातार tool विफलताएँ क्यों गिनें?

  • यह पकड़ने के लिए कि model छटपटा रहा है और सुधर नहीं रहा
  • Tools को धीमा करने के लिए
  • क्योंकि errors अच्छे हैं
  • विफलताएँ छिपाने के लिए
Answer

यह पकड़ने के लिए कि model छटपटा रहा है और सुधर नहीं रहा — बिना सफलता के विफलताओं की कड़ी का मतलब है कि और retries शायद मदद नहीं करेंगे।