loom.ai.config¶
Typed configuration for the ai: deployment section.
Parsed via ctx.section(ConfigKey.AI, AiConfig) through the existing
loom.core.config loader, so ${oc.env:...} interpolations and the
secret resolver apply before the decode, unchanged. Validation is fail-fast
per struct and every issue carries a stable
AgentErrorCode; AiConfig aggregates the
issues found across every model role and endpoint and raises once.
Functions
|
Report whether |
|
Report whether |
|
Whether hostname names this machine and nothing else. |
|
Strip userinfo and query so an invalid-URL message cannot leak a secret. |
|
Return why a remote URL is unsafe, or |
|
Collect the issues of every |
|
Collect the issues of one endpoint's |
|
|
|
Collect the coherence, URL and credential issues of a |
|
Collect the issues of a subprocess |
|
Collect the issues of every |
|
Collect the fields of one server that its |
|
Collect the issues of one |
|
Collect the fault of one remote URL, redacted so it cannot leak a secret. |
|
Collect the coherence and environment issues of a |
|
Announce a plaintext loopback URL, which is allowed only because it is one. |
Classes
|
One named remote A2A agent ( |
|
A2A exposure settings (FR-041). |
|
Per-agent HTTP exposure opt-in (FR-029a, FR-045a). |
|
Deployment configuration of the AI pillar ( |
|
One named MCP server ( |
- class loom.ai.config.McpServerConfig(*, transport='http', url=None, headers_ref=None, auth=None, timeout_ms=20000, command=None, args=(), env=None)[source]¶
Bases:
LoomFrozenStructOne named MCP server (
ai.mcp_servers.<name>).Artifacts name a server; this is where the server lives. Keeping the transport, the address or command, the credential reference and the deadline here is what lets the same artifact move between environments unchanged.
- Parameters:
- transport¶
httpfor a remote endpoint,stdiofor a subprocess of this worker. Each transport accepts its own fields and refuses the other’s.- Type:
- url¶
https://server URL, free of userinfo and query string. Required underhttp; refused understdio.- Type:
str | None
- headers_ref¶
Reference to headers resolved by the secrets resolver. Never a literal secret. The resolved payload must be a single
Name=valueheader pair, a shape checked at start-up rather than here; a bearer token belongs inauth: {kind: bearer}. Mutually exclusive withauth.- Type:
str | None
- auth¶
Named authentication strategy and its settings, flattened:
kindselects an entry point registered inloom.ai.remote_authand every other key is passed to it as a keyword argument. Mutually exclusive withheaders_ref.
- class loom.ai.config.A2AAgentConfig(*, url, headers_ref=None, auth=None)[source]¶
Bases:
LoomFrozenStructOne named remote A2A agent (
ai.a2a_agents.<name>).The credential is declared exactly as an MCP server declares it, and for the same reason: the artifact names the agent, the deployment says how to authenticate to it.
- class loom.ai.config.AgentEndpointConfig(*, enabled, auth, allow_anonymous=False)[source]¶
Bases:
LoomFrozenStructPer-agent HTTP exposure opt-in (FR-029a, FR-045a).
An agent absent from
ai.endpointsis never mounted; presence requires naming the authentication explicitly — there is no default.
- class loom.ai.config.A2AConfig(*, base_url, expose)[source]¶
Bases:
LoomFrozenStructA2A exposure settings (FR-041).
- expose¶
Agent names to publish. Must be non-empty: empty means none, never all (FR-041a).
- Raises:
AgentCompilationError – With
A2A_EXPOSE_EMPTYwhenexposenames no agent.- Parameters:
- class loom.ai.config.AiConfig(*, engine, models, specs=(), skills_root=None, mcp_servers=<factory>, a2a_agents=<factory>, a2a=None, endpoints=<factory>, startup_timeout_ms=10000, remote_clients='required', max_concurrent_runs=8, max_prompt_bytes=65536, max_state_bytes=65536, health_cache_ttl_ms=5000, max_agent_depth=1)[source]¶
Bases:
LoomFrozenStructDeployment configuration of the AI pillar (
ai:section).- specs¶
Glob patterns of agent artifacts, relative to the app root. Mutually exclusive with the manifest
AGENTSattribute: exactly one of the two declares the artifacts of an application, and declaring both is a compilation error.
- models¶
Model-role bindings; must contain every role an agent declares.
- Type:
- mcp_servers¶
Named remote MCP servers artifacts refer to by name.
- Type:
- a2a_agents¶
Named remote A2A agents artifacts refer to by name.
- Type:
- a2a¶
A2A exposure; absent means no card and no A2A endpoints (FR-041).
- Type:
loom.ai.config.A2AConfig | None
- endpoints¶
Per-agent HTTP opt-in (FR-029a).
- startup_timeout_ms¶
Total budget of start-up: opening every live client concurrently and validating the declared tool filters share one deadline, whatever the number of servers.
- Type:
- remote_clients¶
Start-up tolerance for the MCP servers and A2A agents the deployment connects to,
required(the default) oroptional. Underoptionala client that fails to connect is logged and dropped instead of aborting start-up, so an application can boot with no network. It tolerates nothing else: a missing client factory is a wiring bug and stays fatal, a server that did open and whose tool listing times out still fails start-up, and no client becomes lazy — one that never opened is not reconnected later.- Type:
- max_prompt_bytes¶
Enforced while reading the request body, against the
promptfield alone (FR-015).- Type:
- max_state_bytes¶
Enforced while reading the request body, against the raw
statebytes alone and before they are decoded — measuring the wire size is what keeps the check cheap. Joinsmax_prompt_bytesin the body’s own cap (FR-015); a caller’sstateover this limit is refused with a413namingstate, independently of the prompt’s own cap.- Type:
- max_agent_depth¶
Longest chain of nested agent runs one task may open, counting the top-level run itself. A use case reaches a named agent through an
Agent()marker parameter, and that handle’sruncounts as one more entry in the same chain the run that reached the use case already opened. Defaults to1, under which the top-level run alone already consumes the whole budget: an output hook, or any other use case an agent’s run invokes, that itself declares anAgent()marker finds no depth left, and the whole class of agent-calls-agent cycles is unreachable without deliberately raising this value.- Type:
- Raises:
AgentCompilationError – Aggregating one issue per invalid model binding (incomplete provider settings, literal secret in
credentials_ref), per unsafe remote server or agent (bad URL, inline credentials, out-of-range timeout), per endpoint without a namedauth, for an unknownremote_clientsmode, and for amax_agent_depthbelow 1 — which would refuse every run, including the top-level one.- Parameters:
engine (str)
models (dict[str, InferenceTarget])
skills_root (str | None)
mcp_servers (dict[str, McpServerConfig])
a2a_agents (dict[str, A2AAgentConfig])
a2a (A2AConfig | None)
endpoints (dict[str, AgentEndpointConfig])
startup_timeout_ms (int)
remote_clients (str)
max_concurrent_runs (int)
max_prompt_bytes (int)
max_state_bytes (int)
health_cache_ttl_ms (int)
max_agent_depth (int)