Vega SDK — Action Contracts API

Action Contracts API

Planner-safe, human-authored self-descriptions for Actions, plus the validation helper and SDK bounds constants.

Import

python
from vega_capability_sdk import (
ActionContractValidationError,
ActionSelfDescription,
validate_action_self_description,
)

Constants

TermMeaning
MAX_CONTRACT_TEXT_CHARS = 1024Maximum characters in each contract text item.
MAX_CONTRACT_ITEMS = 32Maximum items in each list field.

ActionSelfDescription

python
@dataclass(frozen=True, slots=True)
class ActionSelfDescription:
description: str
can: tuple[str, ...] = ()
cannot: tuple[str, ...] = ()
requires: tuple[str, ...] = ()
guarantees: tuple[str, ...] = ()
limitations: tuple[str, ...] = ()
@classmethod
def from_mapping(cls, value: Mapping[str, Any]) -> ActionSelfDescription: ...
def to_dict(self) -> dict[str, Any]: ...

Planner-safe self-description for one Action. description is required; the five list fields are optional string tuples. from_mapping accepts only these six field names, trims text, and rejects blank required text, blank list items, or lists larger than 32 items.

Validation rules

TermMeaning
Missing or blank descriptionActionContractValidationError
Unknown fieldActionContractValidationError listing the unknown names
List field supplied as a string or non-sequenceActionContractValidationError
More than 32 items in a listActionContractValidationError
Text longer than 1024 charactersActionContractValidationError
Blank list itemActionContractValidationError

Example

python
description = validate_action_self_description(
{
"description": "Speak a short text message.",
"can": ["Render text through the configured speech backend."],
"cannot": ["Guarantee that a listener heard the message."],
"requires": ["An initialized and healthy speech backend."],
"guarantees": ["Reports success after backend acknowledgement."],
"limitations": ["Text length is constrained by the Action schema."],
}
)