Files
crewAI/lib
Devin AI e94de13f06 Fix issue #3764: Implement lazy loading for knowledge sources
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>
2025-10-21 20:23:17 +00:00
..
2025-10-20 17:34:38 -04:00