@@ -110,6 +110,187 @@ elif existing_system_type == "utility_system":
110110 add_utility_function(existing_util_path, new_function)
111111```
112112
113+ ## 0.5. Documentation-First API Integration (CRITICAL FOUNDATION)
114+
115+ ### **READ DOCUMENTATION BEFORE IMPLEMENTATION - MANDATORY**
116+
117+ ```python
118+ # FORBIDDEN: Implementing API integration without reading documentation
119+ from langchain import some_module # WRONG - guessing at API usage
120+ result = some_module.do_something() # WRONG - assuming how it works
121+
122+ # REQUIRED: Documentation-first approach
123+ # Step 1: Read official API documentation
124+ # Step 2: Understand correct usage patterns
125+ # Step 3: Implement using documented methods
126+ from langsmith import Client
127+
128+ # Correct usage based on official documentation
129+ client = Client(api_key=api_key)
130+ prompt = client.pull_prompt("prompt_name", include_model=True) # Documented method
131+ ```
132+
133+ ### **Mandatory Documentation Review Process**
134+
135+ Before implementing ANY integration with special libraries:
136+
137+ 1. **MANDATORY: Read Official Documentation**
138+ - LangChain: https://python.langchain.com/docs/
139+ - LangGraph: https://langchain-ai.github.io/langgraph/
140+ - LangSmith: https://docs.smith.langchain.com/
141+ - Any other special library: Find and read official docs
142+
143+ 2. **MANDATORY: Understand API Contracts**
144+ - Read method signatures
145+ - Understand parameters and return types
146+ - Review code examples
147+ - Check version compatibility
148+
149+ 3. **MANDATORY: Use Documented Patterns**
150+ - Follow official examples
151+ - Use documented method names
152+ - Respect parameter conventions
153+ - Handle errors as documented
154+
155+ 4. **FORBIDDEN: Guessing or Assuming**
156+ - Don't guess at method names
157+ - Don't assume API behavior
158+ - Don't use deprecated patterns
159+ - Don't ignore version differences
160+
161+ ### **Special Library Integration Standards**
162+
163+ ```python
164+ # REQUIRED: Documentation-first integration pattern
165+
166+ class DocumentedAPIIntegration:
167+ """Integration following official documentation."""
168+
169+ def __init__(self):
170+ # Step 1: Read docs for initialization
171+ # Documentation: https://docs.library.com/client
172+ self.client = ProperClientClass(
173+ param1="value", # As documented
174+ param2="value" # As documented
175+ )
176+
177+ def use_api_method(self):
178+ """Use API method exactly as documented."""
179+ # Step 2: Read docs for method usage
180+ # Documentation: https://docs.library.com/methods
181+
182+ try:
183+ # Use documented method with documented parameters
184+ result = self.client.documented_method(
185+ required_param="value",
186+ optional_param="value"
187+ )
188+
189+ # Handle result as documented
190+ return self._process_documented_result(result)
191+
192+ except DocumentedException as e:
193+ # Handle errors as documented
194+ self._handle_documented_error(e)
195+
196+ # FORBIDDEN: Undocumented usage
197+ class UndocumentedIntegration:
198+ def __init__(self):
199+ # WRONG - guessing at initialization
200+ self.client = GuessedClass() # Not in docs
201+
202+ def use_api_method(self):
203+ # WRONG - guessing at method names
204+ result = self.client.maybe_this_works() # Not documented
205+ return result # Hope it works!
206+ ```
207+
208+ ### **Documentation Sources Priority**
209+
210+ **Priority Order** (check in this order):
211+
212+ 1. **Official Documentation** (highest priority)
213+ - Main docs site
214+ - API reference
215+ - Official examples
216+
217+ 2. **Release Notes / Changelog**
218+ - Breaking changes
219+ - Deprecated methods
220+ - New features
221+
222+ 3. **Official GitHub Repository**
223+ - Source code (if needed)
224+ - Issue tracker
225+ - Official examples directory
226+
227+ 4. **Community Resources** (lowest priority, verify against official docs)
228+ - Stack Overflow
229+ - Blog posts
230+ - Third-party tutorials
231+
232+ ### **Version Compatibility Checks**
233+
234+ ```python
235+ # REQUIRED: Check and document version compatibility
236+
237+ # Document versions at top of file
238+ """
239+ Integration with LangChain/LangSmith
240+
241+ Dependencies:
242+ - langchain==0.1.0 (or compatible)
243+ - langsmith==0.1.0 (or compatible)
244+ - langgraph==0.1.0 (or compatible)
245+
246+ Documentation references:
247+ - https://docs.smith.langchain.com/reference/python-client
248+ - https://python.langchain.com/docs/get_started/introduction
249+ """
250+
251+ import importlib.metadata
252+
253+ def check_version_compatibility():
254+ """Verify library versions match documentation."""
255+ required_versions = {
256+ 'langchain': '>=0.1.0',
257+ 'langsmith': '>=0.1.0',
258+ 'langgraph': '>=0.1.0'
259+ }
260+
261+ for package, version_req in required_versions.items():
262+ try:
263+ installed = importlib.metadata.version(package)
264+ logger.info(f"{package} version: {installed}")
265+ except importlib.metadata.PackageNotFoundError:
266+ logger.error(f"{package} not installed!")
267+ ```
268+
269+ ### **Integration Testing with Documentation**
270+
271+ ```python
272+ # REQUIRED: Test against documented behavior
273+
274+ def test_langsmith_integration():
275+ """Test LangSmith integration using documented API."""
276+
277+ # Based on: https://docs.smith.langchain.com/reference/python-client
278+ from langsmith import Client
279+
280+ # Test documented initialization
281+ client = Client(api_key="test-key")
282+ assert client is not None
283+
284+ # Test documented method
285+ # Documentation states: client.pull_prompt(prompt_name, include_model=True)
286+ try:
287+ prompt = client.pull_prompt("test_prompt", include_model=True)
288+ # Success - API used correctly
289+ except Exception as e:
290+ # Handle as documented
291+ logger.error(f"Failed as documented: {e}")
292+ ```
293+
113294## 1. Data Integrity and Authenticity
114295
115296### **NO FAKE VALUES - CRITICAL PRINCIPLE**
0 commit comments