contract
agentic_ml.core.contract
¶
The contract every agent-written model.py must satisfy.
A trial is a directory containing a model.py module that defines a class named Model.
This module describes that interface, documents it for the agent prompt, and provides helpers
to dynamically import and validate a generated module.
TrialModel
¶
Bases: Protocol
Structural type describing a fitted trial model.
ContractError
¶
Bases: Exception
Raised when a generated model.py does not satisfy the contract.
validate_model_class
¶
validate_model_class(cls: type) -> None
Validate that cls exposes the required methods.
Source code in src/agentic_ml/core/contract.py
80 81 82 83 84 85 86 87 | |
load_model_class
¶
load_model_class(directory: str | Path) -> type
Import directory/model.py and return its validated Model class.
helpers.py (if present) is loaded first under the name helpers so that
model.py can import it. This executes the generated code and is a trust boundary.
Source code in src/agentic_ml/core/contract.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |