Skip to content

feat(DATAGO-126654): Implement dynamic model provider for services and tools[3/4]#1180

Open
cyrus2281 wants to merge 45 commits intomainfrom
cyrus/DATAGO-126654/services
Open

feat(DATAGO-126654): Implement dynamic model provider for services and tools[3/4]#1180
cyrus2281 wants to merge 45 commits intomainfrom
cyrus/DATAGO-126654/services

Conversation

@cyrus2281
Copy link
Collaborator

What is the purpose of this change?

This change implements enterprise dynamic model configuration that enables model management via a model provider service. It allows LLM models to be configured at runtime rather than requiring them in initial YAML configuration, supporting hot-swapping of models without redeploying agents.

How was this change implemented?

High-level architecture changes include:

- Created new `DynamicModelProvider` class to handle dynamic model configuration
- Modified `LiteLlm` class to support hot-swapping of model configuration
- Added "lazy model mode" to SAM components to start without a model configuration
- Updated component base classes to manage the lifecycle of model configuration
- Created model config listener flow for receiving model updates via messaging

Key commits:
- feat: implement DynamicModelProvider for enterprise model configuration
- feat: Converting the LiteLlm class to support dynamic model provider
- feat: add dynamic model provider configuration to SamAgentAppConfig
- feat: refactor model handling in services and tools to utilize LiteLLM from parent

Key Design Decisions

- Used a messaging-based approach to deliver model configurations at runtime
- Implemented a status management system in LiteLlm to track model readiness
- Created a bootstrap request/response flow for agents to get their initial model config
- Refactored all tools and services to access LiteLLM instances through the host component
- Made changes backward compatible with existing direct model configuration

How was this change tested?

  • Manual testing: Configured agents with model_provider setting, verified bootstrap requests and model loading
  • Unit tests: Updated affected test classes to use the new model provider pattern
  • Integration tests: Tested flow of model config requests through broker
  • Known limitations: Requires SAM_FEATURE_MODEL_CONFIG_BE environment flag to be enabled

Is there anything the reviewers should focus on/be aware of?

Review the model status lifecycle handling and how components respond to model configuration changes. The enterprise configuration flow requires setting SAM_FEATURE_MODEL_CONFIG_BE=true.

@cyrus2281 cyrus2281 self-assigned this Mar 13, 2026
@cyrus2281 cyrus2281 changed the title feat(DATAGO-126654): Implement dynamic model provider for enterprise model configuration feat(DATAGO-126654): Implement dynamic model provider for enterprise model configuration [3/4] Mar 13, 2026
@cyrus2281 cyrus2281 changed the base branch from main to cyrus/DATAGO-126654/provider March 13, 2026 20:15
@github-actions
Copy link

github-actions bot commented Mar 13, 2026

✅ FOSSA Guard: Licensing (SolaceLabs_solace-agent-mesh) • PASSED

Compared against main (a6a567148148e57eb8057a702fb9ed8e70dbf639) • 0 new, 6 total (6 in base)

Scan Report | View Details in FOSSA

@github-actions
Copy link

github-actions bot commented Mar 13, 2026

✅ FOSSA Guard: Vulnerability (SolaceLabs_solace-agent-mesh) • PASSED

Compared against main (a6a567148148e57eb8057a702fb9ed8e70dbf639) • 0 new, 1 total (1 in base)

Scan Report | View Details in FOSSA

@cyrus2281 cyrus2281 changed the title feat(DATAGO-126654): Implement dynamic model provider for enterprise model configuration [3/4] feat(DATAGO-126654): Implement dynamic model provider for services and [3/4] Mar 13, 2026
@cyrus2281 cyrus2281 changed the title feat(DATAGO-126654): Implement dynamic model provider for services and [3/4] feat(DATAGO-126654): Implement dynamic model provider for services and tools[3/4] Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements part of the dynamic model provider rollout by refactoring gateway services/tools to obtain an LLM instance from the host component (enabling runtime model hot-swapping) rather than constructing LiteLLM clients directly from static config.

Changes:

  • Refactors TitleGenerationService and PromptBuilderAssistant to use BaseLlm.generate_content_async(...) and accept an injected LLM instance.
  • Updates FastAPI wiring and agent tools to pull the model via component.get_lite_llm_model().
  • Adjusts unit tests to align with the new injection pattern (and removes a now-stale dependency test module).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/solace_agent_mesh/gateway/http_sse/services/title_generation_service.py Switches title generation from litellm.acompletion to ADK BaseLlm/LiteLlm and supports a title-specific override model.
src/solace_agent_mesh/gateway/http_sse/services/prompt_builder_assistant.py Converts assistant to accept an injected BaseLlm and uses ADK request/response flow.
src/solace_agent_mesh/gateway/http_sse/routers/prompts.py Wires prompt builder endpoints to use component.get_lite_llm_model().
src/solace_agent_mesh/gateway/http_sse/dependencies.py Updates title generation dependency to inject the component LLM.
src/solace_agent_mesh/agent/tools/deep_research_tools.py Changes default model selection to always use host component’s get_lite_llm_model().
src/solace_agent_mesh/agent/tools/builtin_artifact_tools.py Uses host component model as fallback default for extraction tool model selection.
tests/unit/gateway/http_sse/services/test_title_generation_service.py Refactors tests to mock generate_content_async(...) responses.
tests/unit/agent/tools/test_deep_research_tools.py Updates expectations to align with host-component model retrieval.
tests/unit/gateway/http_sse/test_dependencies_title_service.py Removes now-outdated dependency tests for title generation service wiring.
src/solace_agent_mesh/agent/adk/setup.py Removes unused LiteLlm import.
examples/agents/a2a_mcp_example.yaml Clarifies comment about inheriting parent component’s model if not provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +33 to +40
def _create_service_with_mock_llm(llm_return=None):
"""Create a TitleGenerationService with a mocked LiteLlm."""
mock_llm = MagicMock()
if llm_return is not None:
mock_llm.generate_content_async = MagicMock(
return_value=_async_gen(llm_return)
)
service = TitleGenerationService(mock_llm)
Comment on lines +68 to +72
mock_resp = _mock_llm_response("Test Title")
service = _create_service_with_mock_llm(
model_config={"model": "gpt-4", "api_key": "test-key"},
llm_return=mock_resp,
)
Comment on lines +223 to 225
default_model = host_component.get_lite_llm_model()


source_mime_type = source_artifact_data.get("mime_type", "application/octet-stream")
actual_source_version = source_artifact_data.get("version", "unknown")

host_component = getattr(inv_context.agent, "host_component", None)
Comment on lines 761 to +772
def get_title_generation_service(
component: "WebUIBackendComponent" = Depends(get_sac_component),
) -> "TitleGenerationService":
) -> TitleGenerationService:
"""FastAPI dependency to get an instance of TitleGenerationService."""
from .services.title_generation_service import TitleGenerationService


log.debug("get_title_generation_service called")
# Get model configuration from component (same pattern as prompt_builder_assistant)

# Get LiteLlm instance from the component
model_config = component.get_config("model", {})

return TitleGenerationService(model_config=model_config)
llm = component.get_lite_llm_model()

return TitleGenerationService(model_config=model_config, llm=llm)
Comment on lines +770 to +772
llm = component.get_lite_llm_model()

return TitleGenerationService(model_config=model_config, llm=llm)
Copy link
Collaborator

@mo-radwan1 mo-radwan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments - test bugs and a null safety issue in deep_research_tools.

@cyrus2281 cyrus2281 requested a review from mo-radwan1 March 19, 2026 18:59
Base automatically changed from cyrus/DATAGO-126654/provider to main March 19, 2026 20:43
@cyrus2281 cyrus2281 enabled auto-merge (squash) March 19, 2026 20:59
@sonarqube-solacecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants