loom.ai.inference¶
Model binding value type shared by the compiler and the engine.
InferenceTarget lives in its own module rather than in
loom.ai.config because it is a value type of the pillar: the compiler
embeds it in the plan and the engine consumes it, so it is not a
config-parsing detail.
Secret containment (data-model invariant 4, FR-018): credentials_ref and
options never leave the process in clear text. The mechanism is
fail-closed — on construction both values are rewrapped into types msgspec
refuses to encode, so msgspec.json.encode (and msgspec.to_builtins,
msgspec.msgpack.encode) raise TypeError instead of leaking them, and
repr/str redact them. Rejecting the encode was chosen over silent
redaction because a plan that reaches a wire encoder with a secret reference
aboard is a bug worth surfacing, not smoothing over. Decoding through the
config loader is unaffected: msgspec.convert builds the struct from plain
values and __post_init__ wraps them afterwards.
Module Attributes
How the engine asks the model for the structured answer. |
|
Values |
Classes
|
One resolved model binding for a model role ( |
|
Options mapping that redacts itself and refuses msgspec encoding. |
|
Secret reference that redacts itself and refuses msgspec encoding. |
- loom.ai.inference.OutputMode¶
How the engine asks the model for the structured answer.
promptedis deliberately absent: the engine strips markdown fences before validating a prompted answer while loom decodes the raw text part, so a fenced answer would pass the engine and fail loom.This is the single source of truth for the set: adding a member here makes every exhaustive dispatch over it (
_spec.build_output_type) fail type checking until it handles the new mode, instead of degrading to a default at run time.alias of
Literal[‘tool’, ‘native’]
- loom.ai.inference.OUTPUT_MODES: Final[tuple[OutputMode, ...]] = ('tool', 'native')¶
Values
InferenceTarget.output_modeaccepts, derived fromOutputMode.
- class loom.ai.inference.InferenceTarget(*, provider, model, region=None, endpoint=None, output_mode=None, credentials_ref=None, options=<factory>)[source]¶
Bases:
LoomFrozenStructOne resolved model binding for a model role (
ai.models.<role>).repr/strshowprovider,model,region,endpointandoutput_modebut never the values ofcredentials_reforoptions— the plan carries this struct, so an unredacted repr in a start-up traceback is the concrete leak path. Encoding the struct with msgspec raises when either secret-bearing field is set (see the module docstring for the rationale).- Parameters:
- output_mode¶
How the engine asks the model for the structured answer (
toolornative, seeOutputMode).Noneleaves the choice to the engine. Typedstrrather thanOutputModebecause msgspec validates aLiteralduring the decode, before__post_init__: an unknown value would surface as a rawValidationErrorinstead of theOUTPUT_MODE_UNKNOWNissue naming the role. The set is enforced byloom.ai.config._validate_model_binding.- Type:
str | None
- credentials_ref¶
Reference resolved by the existing secrets resolver. Never a literal secret (FR-018).
- Type:
str | None
- options¶
Vendor-specific settings. Confined here; never reaches the artifact.
- Type:
collections.abc.Mapping[str, Any]