contract tool
Use contract to read the contract that a training script saved beside its model,
with the data file, the split, the inputs, the steps, the validation and the model file. It
reads the JSON file and runs no binary. Pass its result to gates.
contract(file)- Changes no file
- A second call with the same arguments changes nothing more
- Stays inside the project
Tags: pipeline.
Description
Section titled “Description”The server gives the agent this description of the tool.
Read the contract that a training script saved beside its model: the data file and target, the split, the input columns, the steps of the Pipeline, the validation scores, and the model file with the versions that wrote it and the project files it imports when it loads. Changes no file.
It fails when the file does not have that shape, or when the data file, the model file or a code file it names is not in the project. Pass the result to gates.
Arguments
Section titled “Arguments”Type: string. Required.
The contract, a JSON file inside the project root.
Result
Section titled “Result”What a training script saves beside its model: all that a later run needs to load the model, check its input and repeat the split.
The 85 fields of the result
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
discovery |
object or null | no | null |
|
discovery.question |
object | yes | The question that the agent asked find. | |
discovery.question.task |
string | yes | The task, as it was given to find. | |
discovery.candidates |
object | yes | Candidates ranked separately within each kind, including entries read through api. | |
discovery.candidates.symbols |
list of object | no | ||
discovery.candidates.symbols[].kind |
string | yes | ||
discovery.candidates.symbols[].package |
string | yes | ||
discovery.candidates.symbols[].name |
string | yes | ||
discovery.candidates.symbols[].callable |
"class", "function", "method", "property" or null |
yes | ||
discovery.candidates.symbols[].parameters |
list of string | yes | ||
discovery.candidates.symbols[].parameters_written |
list of string | no | The parameter list as the source writes it: each parameter with its type annotation and default, and a * or / that stands alone between parameters. A stub file writes ... for a default, which says only that the parameter is optional. | |
discovery.candidates.symbols[].summary |
string | yes | ||
discovery.candidates.symbols[].members |
list of object | yes | ||
discovery.candidates.symbols[].members[].name |
string | yes | ||
discovery.candidates.symbols[].members[].parameters |
list of string | yes | ||
discovery.candidates.symbols[].members[].parameters_written |
list of string | no | The parameter list as the source writes it: each parameter with its type annotation and default, and a * or / that stands alone between parameters. A stub file writes ... for a default, which says only that the parameter is optional. | |
discovery.candidates.symbols[].members[].summary |
string | yes | ||
discovery.candidates.symbols[].members[].property |
boolean | no | false |
The member is read and not called. |
discovery.candidates.symbols[].rules |
list of string | yes | ||
discovery.candidates.symbols[].signature |
string or null | yes | Return indexed parameter names. parameters_written has the defaults and kinds. |
|
discovery.candidates.rules |
list of object | no | ||
discovery.candidates.rules[].kind |
string | yes | ||
discovery.candidates.rules[].package |
string | yes | ||
discovery.candidates.rules[].name |
string | yes | ||
discovery.candidates.rules[].callable |
"class", "function", "method", "property" or null |
yes | ||
discovery.candidates.rules[].parameters |
list of string | yes | ||
discovery.candidates.rules[].parameters_written |
list of string | no | The parameter list as the source writes it: each parameter with its type annotation and default, and a * or / that stands alone between parameters. A stub file writes ... for a default, which says only that the parameter is optional. | |
discovery.candidates.rules[].summary |
string | yes | ||
discovery.candidates.rules[].members |
list of object | yes | ||
discovery.candidates.rules[].members[].name |
string | yes | ||
discovery.candidates.rules[].members[].parameters |
list of string | yes | ||
discovery.candidates.rules[].members[].parameters_written |
list of string | no | The parameter list as the source writes it: each parameter with its type annotation and default, and a * or / that stands alone between parameters. A stub file writes ... for a default, which says only that the parameter is optional. | |
discovery.candidates.rules[].members[].summary |
string | yes | ||
discovery.candidates.rules[].members[].property |
boolean | no | false |
The member is read and not called. |
discovery.candidates.rules[].rules |
list of string | yes | ||
discovery.candidates.rules[].signature |
string or null | yes | Return indexed parameter names. parameters_written has the defaults and kinds. |
|
discovery.candidates.recipes |
list of object | no | ||
discovery.candidates.recipes[].kind |
string | yes | ||
discovery.candidates.recipes[].package |
string | yes | ||
discovery.candidates.recipes[].name |
string | yes | ||
discovery.candidates.recipes[].callable |
"class", "function", "method", "property" or null |
yes | ||
discovery.candidates.recipes[].parameters |
list of string | yes | ||
discovery.candidates.recipes[].parameters_written |
list of string | no | The parameter list as the source writes it: each parameter with its type annotation and default, and a * or / that stands alone between parameters. A stub file writes ... for a default, which says only that the parameter is optional. | |
discovery.candidates.recipes[].summary |
string | yes | ||
discovery.candidates.recipes[].members |
list of object | yes | ||
discovery.candidates.recipes[].members[].name |
string | yes | ||
discovery.candidates.recipes[].members[].parameters |
list of string | yes | ||
discovery.candidates.recipes[].members[].parameters_written |
list of string | no | The parameter list as the source writes it: each parameter with its type annotation and default, and a * or / that stands alone between parameters. A stub file writes ... for a default, which says only that the parameter is optional. | |
discovery.candidates.recipes[].members[].summary |
string | yes | ||
discovery.candidates.recipes[].members[].property |
boolean | no | false |
The member is read and not called. |
discovery.candidates.recipes[].rules |
list of string | yes | ||
discovery.candidates.recipes[].signature |
string or null | yes | Return indexed parameter names. parameters_written has the defaults and kinds. |
|
discovery.choice |
object | yes | The candidate that the agent chose, and why. | |
discovery.choice.name |
string | yes | The selected candidate's exact name. | |
discovery.choice.reason |
string | yes | Why this candidate fits the task. | |
discovery.choice.symbols |
list of string | yes | Indexed callable symbols the code must call, including a recipe's symbols. | |
data |
object | yes | ||
data.file |
string | yes | The data file, relative to the project root. | |
data.target |
string | yes | The column the model predicts. | |
data.rows |
integer | yes | Rows in the file, before the split. | |
split |
object | yes | How the rows were divided once, before any step was fitted. | |
split.seed |
integer | yes | The random_state of the split. | |
split.test_size |
number | yes | The share of the rows held out. | |
split.stratified |
boolean | yes | True when the split keeps the target's proportions. | |
split.train_rows |
integer | yes | ||
split.test_rows |
integer | yes | ||
inputs |
list of object | yes | ||
inputs[].column |
string | yes | ||
inputs[].dtype |
string | yes | ||
steps |
list of object | yes | ||
steps[].name |
string | yes | ||
steps[].estimator |
string | yes | The class name, such as ColumnTransformer. | |
validation |
object | yes | ||
validation.splitter |
object | yes | ||
validation.splitter.class |
string | yes | ||
validation.splitter.args |
object | yes | ||
validation.scoring |
string | yes | The scorer name, such as accuracy. | |
validation.folds |
integer | yes | ||
validation.cv_scores |
list of number | yes | One score per fold. | |
validation.test_score |
number | yes | The score on the held out rows. | |
model |
object | yes | ||
model.file |
string | yes | The saved model, relative to the project root. | |
model.type |
string | yes | The class of the saved object, with its module. | |
model.versions |
object | yes | Python and each library that wrote the file. | |
model.code |
list of string | no | The project files the model imports when it loads, relative to the project root. A Pipeline saves a function such as the one in a FunctionTransformer by its module and name, so the model loads only where that module can be imported. |
Example
Section titled “Example”With the server's root at samples/pipeline:
{"file":"model/contract.json"}The result has discovery, data, split, inputs, steps, validation and model. These
are its validation and model, where each "..." stands for a version.
{"validation":{"splitter":{"class":"StratifiedKFold","args":{"n_splits":5,"shuffle":true,"random_state":0}},"scoring":"accuracy","folds":5,"cv_scores":[0.9807692307692307,0.9807692307692307,1.0,1.0,0.9803921568627451],"test_score":0.9883720930232558},"model":{"file":"model/model.joblib","type":"sklearn.pipeline.Pipeline","versions":{"python":"...","scikit-learn":"...","pandas":"...","numpy":"...","joblib":"..."},"code":["features.py"]}}Errors
Section titled “Errors”A file that is missing or does not match the contract's schema fails with the reason.