Conversation
…ironments - Fix critical bug where agent creation used FileStorage ResourceLoader in production - Pass injected ResourceLoader from ChatHandler to get_production_agent() - Add fallback compatibility layer for dev tools that call agent functions directly - Improve test clarity by removing unnecessary patch decorators - Add logging to track which ResourceLoader type is being used This ensures GCS/cloud storage works correctly in beta/prod environments instead of failing with FileStorage-only ResourceLoader. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude encountered an error —— View job Code Review in Progress
|
|
@claude can you do the review again? |
|
Claude finished @xCatG's task —— View job Code Review Complete ✅I've thoroughly reviewed this PR and the dependency injection fix looks excellent. The tests are passing which confirms the fix resolves the production issue. Todo List:
✅ Strengths1. Root Cause Analysis & Fix
2. Backwards Compatibility
3. Test Improvements
4. Code Quality
✅ Technical AnalysisDependency Injection Pattern ( # Use the injected resource_loader or create a fallback one
if resource_loader is None:
# Try dependency injection first, then fallbackThis is well-architected - follows the dependency inversion principle while maintaining dev compatibility. Handler Integration ( agent = await get_production_agent(..., resource_loader=resource_loader)Proper integration - the injected ResourceLoader from FastAPI now flows through to agent creation. Storage Backend Usage (
|

Summary
Root Cause
The
get_production_agent()function was importing and using a hardcoded FileStorage-based ResourceLoader instead of using the properly configured ResourceLoader (GCS/S3) that gets injected through FastAPI's dependency system. This caused 500 errors in beta/prod when trying to read resources from cloud storage.Solution
get_production_agent()to accept an optionalresource_loaderparameterChatHandler._generate_character_response()to pass the injected ResourceLoaderTesting
patchdecorators)Test Plan
🤖 Generated with Claude Code