Proxies and sandbox
APIs agents can call and a sandbox to run code in. Import from lllm. Guides: Proxies, Sandbox.
Proxies
BaseProxy
BaseProxy(*args, activate_proxies: Optional[List[str]] = None, cutoff_date: Optional[datetime] = None, deploy_mode: bool = False, use_cache: bool = True, runtime: Optional[Runtime] = None, registry: Optional[Registry] = None, **kwargs)
Base class for describing an API surface that agents can call as tools.
endpoint
staticmethod
endpoint(category: str, endpoint: str, description: str, params: dict, response: list, name: Optional[str] = None, sub_category: Optional[str] = None, remove_keys: Optional[list] = None, dt_cutoff: Optional[tuple] = None, method: str = 'GET')
Decorator that records metadata about an API endpoint.
tactic_endpoint
staticmethod
tactic_endpoint(tactic_ref: str | None = None, *, tactic_url: str | None = None, config: Any = None, endpoint: Optional[str] = None, category: str = 'tactics', name: Optional[str] = None, description: Optional[str] = None, response: Any = None, method: str = 'TACTIC')
Create a proxy endpoint backed by a tactic resource ref.
register_tactic
classmethod
register_tactic(tactic_ref: str | None = None, *, tactic_url: str | None = None, endpoint: str = None, config: Any = None, category: str = 'tactics', name: str = None, description: str = None, response: Any = None, method: str = 'TACTIC')
Imperatively add a tactic-backed endpoint to this proxy class.
resolve_endpoint
resolve_endpoint(path: str) -> tuple
Find the endpoint for a documented path (or an endpoint method name).
Returns (method, endpoint_info, path_params). Paths are matched as
listed in the API directory, including {name} placeholders whose
values are returned as path_params. Only decorated endpoints can
be reached; other attributes of the proxy are never callable.
call
call(path: str, params: Optional[Dict[str, Any]] = None) -> Any
Call an endpoint: shape the params, then make the HTTP request.
The endpoint method receives the params and returns the (possibly
adjusted) params to send. Proxies that declare a base_url then
call _call_api with the full URL, adding the API key as a query
parameter (api_key_name) or a header ("*header-name").
Proxies that send requests themselves (an overridden _call_api
without base_url, e.g. an SDK client) receive the endpoint path.
Proxies with neither, and tactic endpoints, return the method's result
directly.
{name} placeholders in the endpoint path are filled from the
params, each value URL-encoded as a single path segment. A missing
value, . or .. raises ValueError.
endpoint_directory
endpoint_directory() -> List[Dict[str, Any]]
Return a structured list describing every endpoint exposed by this proxy.
api_directory
api_directory() -> Dict[str, Any]
Return proxy metadata plus the endpoint directory.
auto_test
auto_test() -> Dict[str, Dict[str, Any]]
Perform light-weight validation of endpoint metadata.
Returns a dict mapping callable name to {"status": "...", "issues": [...]}.
proxy_tactic
proxy_tactic(tactic: Tactic[Any, Any], **kwargs: Any) -> ProxyTactic
Return a proxy wrapper for tactic.
ProxyTactic
ProxyTactic(tactic: Tactic[Any, Any], *, name: str | None = None, description: str | None = None, before: ValueHook | None = None, after: ValueHook | None = None, on_error: ErrorHook | None = None, sink: RecordSink | None = None, capture_inputs: bool = False, capture_outputs: bool = False, metadata: Mapping[str, Any] | None = None)
Bases: Tactic[Any, Any]
Wrap another tactic with small before/after/error hooks.
The proxy sits at the public Tactic boundary, so it can wrap plain
Python, Pydantic AI, native, or remote tactics without knowing their
runtime internals.
ProxyRecord
Bases: BaseModel
One observed proxy call.
InMemoryProxyLog
InMemoryProxyLog()
Simple proxy record sink for tests, examples, and local tools.
Sandbox
sandbox_tactic
sandbox_tactic(tactic: Tactic[Any, Any], policy: SandboxPolicy | dict[str, Any] | None = None, **kwargs: Any) -> SandboxedTactic
Return a sandbox wrapper for tactic.
SandboxedTactic
SandboxedTactic(tactic: Tactic[Any, Any], *, policy: SandboxPolicy | dict[str, Any] | None = None, name: str | None = None, description: str | None = None)
SandboxPolicy
Bases: BaseModel
Small call-boundary policy for a tactic wrapper.
This is not OS-level isolation. It is a reusable protocol wrapper for service timeouts, payload-size budgets, and request-metadata allowlists.
SandboxError
Bases: TacticError
Base error raised by tactic sandbox wrappers.
SandboxLimitError
Bases: SandboxError
Raised when a sandbox limit or allowlist check fails.
SandboxTimeoutError
Bases: SandboxError
Raised when a sandboxed async tactic call exceeds its deadline.