Merged
Conversation
Phase 7.3: Create LLMServiceImpl that wraps CloudLLMService/VLLMLLMService (generation) and CloudProviderService (provider CRUD) behind a single Protocol-conformant facade. - modules/llm/facade.py: LLMServiceImpl + dict→TypedDict converters - Lazy llm_service access via ServiceContainer (handles backend switches) - generate() wraps sync provider call via asyncio.to_thread - stream() wraps sync generator, normalizes to StreamChunk TypedDict - resolve_backend/list_providers delegate to CloudProviderService - Registered in ServiceContainer.llm_service_facade during startup - 13 unit tests (protocol compliance, signatures, converters) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
shikhalev
approved these changes
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LLMServiceImplinmodules/llm/facade.py— unified facade implementing theLLMServiceProtocol frommodules/llm/protocols.pyCloudLLMService/VLLMLLMService(generation) andCloudProviderService(provider CRUD) behind a single interfacecontainer.llm_service— handles runtime backend switches by InternetMonitorgenerate()— sync provider call wrapped viaasyncio.to_threadstream()— sync generator consumed in thread, yields normalizedStreamChunkTypedDicts_to_stream_chunk()normalizes both plainstranddict(tool_calls) from providers_to_provider_info()converts provider dicts toProviderInfoTypedDictServiceContainer.llm_service_facadeduring orchestrator startupllm_service_facadeset during startup for direct importsScope note: This PR creates the facade layer only. Prompt assembly, RAG injection, agentic tool loops, and token accounting remain in callers (chat router, widget router). Migration of callers to use the facade is a separate step.
Closes #644
Files changed
modules/llm/facade.pyLLMServiceImpl+ convertersorchestrator.pyapp/dependencies.pyllm_service_facadefield toServiceContainerCLAUDE.mdtests/unit/test_llm_service.pyTest plan
🤖 Generated with Claude Code