latent.serve.api¶
serve(make_agent) — the programmatic entry point (ADR-005 D1, ADR-006 D1).
Keyed off AgentProtocol (a latent-native agent or a FrameworkAdapter-wrapped
foreign one), not BaseAgent — so any conforming agent serves. Builds the
AgentServer and runs it; plain serving is ready immediately, --share flips
readiness after registration (see latent.serve.share).
Functions¶
serve¶
serve(make_agent: AgentFactory, name: str = 'agent', host: str = '0.0.0.0', port: int = 8080, secret: str, invoke_timeout_s: float = DEFAULT_INVOKE_TIMEOUT_S, max_concurrency: int | None = None, keep_alive_s: float | None = None, fd: int | None = None, manifest: AgentManifest | None = None) -> None
Build the FastAPI AgentServer for make_agent and run it (blocking).
make_agent is called once here to fail fast if it doesn't produce an
AgentProtocol, then once per request inside the server (fresh instance).
max_concurrency caps concurrent connections/tasks before uvicorn sheds
load with 503 (env LATENT_SERVE_MAX_CONCURRENCY); keep_alive_s sets the
idle keep-alive (env LATENT_SERVE_KEEP_ALIVE). Both fall back to env then
defaults when unset. A 503 from the concurrency limit maps to
unavailable→fallback in the proxy, so an overloaded pod sheds, not OOMs.
fd serves on an inherited listening socket instead of binding host:port
(env LATENT_SERVE_FD), so a parent can reserve the port race-free and hand
the descriptor to this child.
manifest is served at GET /v1/manifest; unset, it is built from the
agent's class (:func:~latent.serve.manifest.build_agent_manifest).
When AGENT_KNOWLEDGE_DIGEST is set, the pinned bundle is fetched before
the agent is built (:mod:latent.serve.knowledge_fetch).