feat: NoopProvider for tests + agent_settings.vm_provider=noop config

In-memory `AgentVMProvider` used by the unit tests and as the default when
`agent_settings.vm_provider` is unset. The factory returns `NoopProvider`
when no AWS-backed provider is configured so the proxy boots cleanly without
AWS credentials.

LIT-2878
This commit is contained in:
Ishaan Jaff 2026-05-06 15:26:23 -07:00
parent 380cf11298
commit bdcda518a7
No known key found for this signature in database

View file

@ -0,0 +1,49 @@
"""
No-op `AgentVMProvider` implementation.
Used in tests and for environments without an EC2 backend. `provision` returns
a fake handle immediately; `status` always reports `running`. The provider is
the default in `factory.py` so the proxy starts up without AWS configured.
"""
from __future__ import annotations
import uuid
from litellm.proxy.agent_session_endpoints.vm_providers.base import (
AgentVMProvider,
ProvisionContext,
VMHandle,
VMState,
VMStatus,
)
class NoopProvider(AgentVMProvider):
"""In-memory provider used by tests and `vm_provider: noop` config."""
name = "noop"
def __init__(self) -> None:
self._terminated: set = set()
async def provision(self, ctx: ProvisionContext) -> VMHandle:
vm_id = f"noop-{uuid.uuid4().hex[:12]}"
return VMHandle(
vm_id=vm_id,
provider=self.name,
region=(ctx.ec2_config.region if ctx.ec2_config else None),
metadata={
"session_id": ctx.session_id,
"team_id": ctx.team_id,
"mode": ctx.mode,
},
)
async def terminate(self, vm: VMHandle) -> None:
self._terminated.add(vm.vm_id)
async def status(self, vm: VMHandle) -> VMStatus:
if vm.vm_id in self._terminated:
return VMStatus(state=VMState.TERMINATED)
return VMStatus(state=VMState.RUNNING, public_ip="127.0.0.1")