fix: Make LlmResponse constructor protected for external subclassing#1137
fix: Make LlmResponse constructor protected for external subclassing#1137jinnigu wants to merge 1 commit into
Conversation
|
Hi! Could you explain more on why you aim to subclass this type ? I don't think we should make LlmResponse's constructor protected — subclassing it isn't the intended extension point.
For the underlying use case (#1134, integrating LM Studio / a custom model), the right extension point is |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
The
LlmResponseconstructor uses package-private (default) visibility, which prevents users from subclassingLlmResponseoutside of thecom.google.adk.modelspackage. This blocks custom LLM integrations (e.g., connecting LM Studio or other local models) that need to extendLlmResponse.Solution:
Change the
LlmResponseconstructor from package-private toprotected. This is the minimal change needed. It allows subclassing from external packages while still preventing arbitrary instantiation (unlikepublic). The@AutoValue-generated subclass in the same package is unaffected.Testing Plan
Unit Tests:
Added
ExternalLlmResponseSubclassTestin thecom.google.adk.models.externalpackage (outsidecom.google.adk.models) to verify that an external subclass ofLlmResponsecan be instantiated.Checklist