System Architecture
The deployment system uses a plugin-based architecture where strategies are self-contained packages that can be added without modifying core code.Module Breakdown
Directory Structure
Core Components
1. DeploymentFactory (factory.py)
The orchestrator that manages the full deployment pipeline.
Responsibilities:
- Coordinate selection, adaptation, and runner creation
- Handle strategy validation
- Create unified Software instances
| Method | Input | Output |
|---|---|---|
create() | DeployStrategy, DeployConfig, optional strategies list | Software |
list_strategies() | None | List[str] |
explain_strategy() | strategy: str | str description |
2. SelectorAgent (selector/agent.py)
LLM-based strategy selection that analyzes code and chooses the optimal deployment target.
Responsibilities:
- Gather selector instructions from all strategies
- Query coding agent to analyze repository
- Return
DeploymentSettingwith chosen strategy
| Method | Input | Output |
|---|---|---|
select() | SolutionResult, optional allowed_strategies, optional resources | DeploymentSetting |
explain() | SolutionResult | str human-readable explanation |
3. AdapterAgent (adapter/agent.py)
Code transformation and deployment using coding agents.
Responsibilities:
- Create adapted workspace (copy of original)
- Load adapter instructions for target strategy
- Run coding agent to transform code
- Extract endpoint URL and run interface from output
- Return
AdaptationResult
| Method | Input | Output |
|---|---|---|
adapt() | SolutionResult, DeploymentSetting, optional allowed_strategies | AdaptationResult |
4. StrategyRegistry (strategies/base.py)
Auto-discovery system for deployment strategies.
Responsibilities:
- Scan
strategies/directory on startup - Load configuration and instructions for each strategy
- Provide access to strategy metadata and runner classes
| Method | Input | Output |
|---|---|---|
list_strategies() | optional allowed: List[str] | List[str] |
get_strategy() | name: str | DeployStrategyConfig |
get_selector_instruction() | name: str | str markdown content |
get_adapter_instruction() | name: str | str markdown content |
get_runner_class() | name: str | type (Runner subclass) |
get_default_run_interface() | name: str | Dict[str, Any] |
5. Runner (Abstract Base Class)
Infrastructure-specific execution handler. Responsibilities:- Execute code (via import, subprocess, HTTP, etc.)
- Health checking
- Resource cleanup
| Runner | Strategy | Execution Method |
|---|---|---|
LocalRunner | local | Python importlib + function call |
DockerRunner | docker | HTTP requests to container |
ModalRunner | modal | modal.Function.remote() |
BentoMLRunner | bentoml | HTTP to BentoCloud/local |
LangGraphRunner | langgraph | LangGraph Cloud API |
6. DeployedSoftware (software.py)
Unified wrapper that users interact with.
Responsibilities:
- Wrap any runner with consistent interface
- Normalize all responses to
{"status": "...", "output": ...} - Provide convenience methods
Data Models
DeployConfig
Configuration for deploying software.DeploymentSetting
Result of strategy selection.AdaptationResult
Result of code adaptation.DeploymentInfo
Metadata about the deployment.Complete Data Flow
Strategy Plugin Architecture
Each strategy is a self-contained directory with:config.yaml Structure
How Strategies Are Discovered
- On import,
StrategyRegistry.get()scansstrategies/directory - Each subdirectory with
selector_instruction.mdANDadapter_instruction.mdis registered DeployStrategyenum is dynamically created from discovered strategies- Runner classes are lazy-loaded from
runner.pywhen needed