mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
This commit fixes a bug where knowledge sources were being loaded eagerly during agent/crew initialization, causing authentication errors (401) when users didn't have proper credentials configured. Changes: - Modified Knowledge class to use lazy loading pattern - Added _sources_loaded private attribute to track loading state - Knowledge sources are now loaded only when first queried - Removed eager add_sources() calls from agent.set_knowledge() and crew.create_crew_knowledge() - Added comprehensive tests for lazy loading behavior The fix ensures that: 1. Knowledge sources don't require authentication during initialization 2. Sources are loaded on-demand when actually needed (first query) 3. Subsequent queries don't reload sources 4. Explicit add_sources() calls still work as expected Fixes #3764 Co-Authored-By: João <joao@crewai.com>