PresetSpec data
model, the PresetBody persisted shape, the preset-specific errors, and
the PresetStore Protocol.
A preset is a base tool with a partial set of keyword arguments baked in,
exposed as a new named, versioned tool. It is the FIRST typed VIEW over the
generic versioned-document store (kind="preset"): the store holds the opaque
body, this Protocol is the typed interface over it. tai42-contract owns only the
Protocol + models + errors; the concrete view that delegates to the store,
validates/reshapes the body, and maps the generic errors to these preset errors
lives in the skeleton (no versioning code in the view).
CARRY_FORWARD
tai42_contract.presets.models.CARRY_FORWARD
CarryForward
tai42_contract.presets.models.CarryForward
save_version
editable field the caller did not provide — carry the ACTIVE value forward.
fixed_kwargs / extensions clear with an empty container, so
None is their carry-forward sentinel; output_schema has no empty
container (its cleared state IS None), so it needs a distinct sentinel to
tell “not provided” (carry forward) apart from an explicit None (clear).
PresetBody
tai42_contract.presets.models.PresetBody
base_tool is the tool the preset binds; description is the preset’s
human description; fixed_kwargs are the baked kwargs (each becomes a
hidden, fixed constant on the bound tool). extensions is a list of
extension COMBOS — the SAME shape as a manifest extensions map value,
each combo element an extension name or a {"name", "config"} mapping
binding author config (e.g. an ask_external verifier) — fed unconverted
to the structured runtime-attach API at register (an empty outer list means
no extensions; an empty INNER combo is rejected by the validating view).
output_schema is an optional author-set OUTPUT JSON Schema (an object
schema): on an AGENT base it is baked into the run tool’s response_format
so the agent FORCES a structured output matching it; on a plain tool it is
advertised as the bound tool’s output schema and every result is validated
against it at run time.
Every field must survive carry-forward on a version save: dropping
extensions would make the branch tools vanish on reload, dropping
base_tool would break the bind, dropping description would strip the
tool’s description, and dropping output_schema would silently un-enforce
the structured output.
Attributes
PresetError
tai42_contract.presets.errors.PresetError
name.
Attributes
PresetExistsError
tai42_contract.presets.errors.PresetExistsError
name already exists.
PresetNameConflictError
tai42_contract.presets.errors.PresetNameConflictError
name collides with an existing base tool.
A preset must never silently shadow a real tool, so the register/create path
raises this loudly rather than overwriting the tool.
PresetNotFoundError
tai42_contract.presets.errors.PresetNotFoundError
name.
PresetSpec
tai42_contract.agent.base.PresetSpec
StructuredTool at
run time (see resolve_tools). A sub-flow is base_tool="flow" with
fixed_kwargs={"flow_graph": ...}.
Attributes
PresetStore
tai42_contract.presets.PresetStore
kind="preset".
Delegation, body validation/reshaping, and error mapping are the concrete
(skeleton) view’s job — this Protocol pins only the surface. A preset body is
always the full PresetBody ({base_tool, description, fixed_kwargs, extensions}); the editable-field methods reconstruct it under the
carry-forward rules documented on save_version.
Members
create_preset
tai42_contract.presets.PresetStore.create_preset
spec carries name/description/
base_tool/fixed_kwargs; extensions (the combos list) and the
optional output_schema ride alongside — all of them land in the
persisted PresetBody. Raise PresetExistsError on a
duplicate name, PresetNameConflictError if the name collides with
a base tool.
Parameters
save_version
tai42_contract.presets.PresetStore.save_version
PresetBody, so the view reconstructs
the new body by ALWAYS carrying base_tool forward from the ACTIVE
version body, then applying each of fixed_kwargs, extensions under
one UNIFORM sentinel: omitted/None = carry the active value forward
unchanged; an explicit empty list (extensions=[]) = deliberately CLEAR
that field. An explicitly provided empty list is a value, never “not
provided”. output_schema follows the SAME rule but with a distinct
CARRY_FORWARD sentinel (its cleared state is None, so None
cannot double as “not provided”): omitted = carry forward, an explicit
None = clear, an explicit dict = wins. description is editable per
version: None = carry the active description forward, an explicit
non-empty string = set it. The RESULTING description — explicit or carried
— is validated non-empty (raising ValueError, surfaced as a 400),
so an explicit "" is rejected and a carry-forward from a legacy body
with an empty description raises rather than persisting an empty tool
docstring. An empty INNER combo
([[]] or any [] member of extensions) is REJECTED. The new body
never DROPS a field. Raise PresetNotFoundError if the preset is
absent.
Parameters
list_presets
tai42_contract.presets.PresetStore.list_presets
get_preset
tai42_contract.presets.PresetStore.get_preset
PresetNotFoundError if
absent.
Parameters
get_active_kwargs
tai42_contract.presets.PresetStore.get_active_kwargs
fixed_kwargs. Raise
PresetNotFoundError if absent.
Parameters
list_versions
tai42_contract.presets.PresetStore.list_versions
is_current
signal. Raise PresetNotFoundError if the preset is absent.
Parameters
get_version
tai42_contract.presets.PresetStore.get_version
PresetVersionNotFoundError if that
version does not exist.
Parameters
get_active_body
tai42_contract.presets.PresetStore.get_active_body
{base_tool, description, fixed_kwargs, extensions}) so reload/startup can re-register from
the whole body, not just fixed_kwargs. Raise
PresetNotFoundError if absent.
Parameters
rollback
tai42_contract.presets.PresetStore.rollback
version (no data copy). Raise
PresetVersionNotFoundError if that version does not exist.
Parameters
soft_delete
tai42_contract.presets.PresetStore.soft_delete
PresetNotFoundError if absent.
Parameters
rename_preset
tai42_contract.presets.PresetStore.rename_preset
name to new_name, delegating to the generic
store’s rename under kind="preset". The version history, every per-version
tags label, and the active_version pointer are preserved by the store
contract — a rename moves a key, it never rewrites the body. Raise
PresetNotFoundError for an absent name, PresetExistsError
when new_name is already a live preset, and PresetNameConflictError
when the injected collision predicate says new_name is held by a live
non-preset tool (the same predicate create_preset consults).
Parameters
PresetVersionNotFoundError
tai42_contract.presets.errors.PresetVersionNotFoundError
version exists for preset name.
Attributes

