पाठ 22 / 25
Servers और Agents का परीक्षण
Tool functions का unit-test करें और agent के लिए छोटा end-to-end eval जोड़ें।
परीक्षण की दो परतें
चूँकि MCP tools सादे functions हैं, उनका किसी भी कोड की तरह सीधा unit-test करें: सामान्य input, ग़लत input, सीमा के मामले। फिर छोटा end-to-end eval जोड़ें: कुछ यथार्थपूर्ण user अनुरोध, असली agent से चलाकर, "search_issues को सही keyword के साथ बुलाया" जैसी जाँचों के साथ। Tool description बदलने पर इसे फिर चलाएँ, क्योंकि इससे model का व्यवहार बदलता है।
pytest unit test
Tests function को सीधे बुलाते हैं, बिना model या protocol के, इसलिए वे तेज़ और निश्चित हैं।
import pytest
from server import search_issues
def test_limit_must_be_in_range():
with pytest.raises(ValueError):
search_issues("crash", limit=0)
def test_returns_at_most_limit(fake_tracker):
assert len(search_issues("crash", limit=3)) <= 3त्वरित जाँच: Tool description बदलने के बाद evals दोबारा क्यों चलाएँ?
- Descriptions प्रभावित करते हैं कि model tool कैसे चुनता और उपयोग करता है
- Python में यह ज़रूरी है
- Descriptions compile होते हैं
- इससे server reset होता है
Answer
Descriptions प्रभावित करते हैं कि model tool कैसे चुनता और उपयोग करता है — Description उस prompt का हिस्सा है जो model देखता है, इसलिए बदलने से व्यवहार बदल सकता है।