> ## Documentation Index
> Fetch the complete documentation index at: https://docs.veadk.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Run an evaluation and export its report

Score existing answers with a released dataset and a Python evaluator, then export a verifiable CSV report. This example uses Data mode and requires no deployed runtime.

Use an account with evaluation permissions, Bash and jq. Configure CLI credentials for the account and set `ACCOUNT_ID` to its main account ID. Run these commands in the same Bash session and working directory.

## Choose a workspace

```bash theme={null}
agentkit eval workspace list --account-id "$ACCOUNT_ID" --json | jq -r '.Result.EvalWorkspaces[].Id'
```

Set `WORKSPACE_ID` to an authorized workspace ID from the results. The remaining steps create resources in this workspace.

## Create and publish a dataset

> [!WARNING]
>
> Uploaded cases are stored in the evaluation workspace. Use data approved for evaluation.

```bash theme={null}
set -euo pipefail
created=$(agentkit eval dataset create --workspace-id "$WORKSPACE_ID" --name answer-samples \
  --fields '[{"Name":"answer","Type":"String","Required":true}]' --json)
DATASET_ID=$(jq -er '.Result.DatasetId' <<< "$created")
schema_rev=$(jq -er '.Result.Version.Schema.Revision' <<< "$created")

agentkit eval dataset item batch-create --workspace-id "$WORKSPACE_ID" --dataset-id "$DATASET_ID" \
  --expected-schema-revision "$schema_rev" --items '[{"Data":[{"Key":"answer","Type":"String","Value":"Paris"}]}]'
latest=$(agentkit eval dataset get --workspace-id "$WORKSPACE_ID" --dataset-id "$DATASET_ID" --version-type Latest --json)
jq -e '.Result.Dataset.CanPublish' <<< "$latest"
data_rev=$(jq -er '.Result.Dataset.Version.Revision' <<< "$latest")
DATASET_RELEASE_ID=$(agentkit eval dataset version publish --workspace-id "$WORKSPACE_ID" \
  --dataset-id "$DATASET_ID" --expected-revision "$data_rev" --version-name answers-v1 --json | jq -er '.Result.Version.VersionId')
```

Writing cases requires the schema revision. Publishing requires the content revision read after the write. The experiment uses the resulting fixed version ID.

## Publish a Python evaluator

Save the following evaluator as `judge.py`. It checks whether an answer is nonempty and returns a score, a label and a reason.

```python theme={null}
def evaluate(answer):
    if answer.strip():
        return {"score": 1, "label": "present", "reason": "Answer contains text."}
    return {"score": 0, "label": "empty", "reason": "Answer contains no text."}
```

```bash theme={null}
judge=$(agentkit eval evaluator create --workspace-id "$WORKSPACE_ID" --name answer-check \
  --evaluator-type Code --evaluation-type ScoreEvaluation --code "$(cat judge.py)" \
  --input-variables '[{"name":"answer","property":{"type":"string"},"required":true}]' --json)
EVALUATOR_ID=$(jq -er '.Result.EvaluatorVersion.EvaluatorId' <<< "$judge")
judge_rev=$(jq -er '.Result.EvaluatorVersion.Revision' <<< "$judge")
EVALUATOR_RELEASE_ID=$(agentkit eval evaluator version publish --workspace-id "$WORKSPACE_ID" \
  --evaluator-id "$EVALUATOR_ID" --expected-revision "$judge_rev" --version-name judge-v1 --json | jq -er '.Result.EvaluatorVersion.VersionId')
```

## Create and start an experiment

Map the dataset field `answer` to the evaluator parameter with the same name. Pin both releases so future runs use the same inputs and scoring rule.

> [!WARNING]
>
> Starting a run consumes evaluation resources. Agent evaluators and inference mode also call the model or target service and may incur charges.

```bash theme={null}
jq -n --arg eid "$EVALUATOR_ID" --arg vid "$EVALUATOR_RELEASE_ID" \
  '[{EvaluatorId:$eid,VersionId:$vid,FieldMappings:[{SourceField:"answer",TargetFieldName:"answer"}]}]' > evaluators.json
EXPERIMENT_ID=$(agentkit eval experiment create --workspace-id "$WORKSPACE_ID" --name answer-quality \
  --evaluation-mode Data --dataset-id "$DATASET_ID" --dataset-version-id "$DATASET_RELEASE_ID" \
  --evaluators @evaluators.json --run-now false --json | jq -er '.Result.ExperimentId')
RUN_ID=$(agentkit eval experiment run start --workspace-id "$WORKSPACE_ID" \
  --experiment-id "$EXPERIMENT_ID" --json | jq -er '.Result.Run.RunId')
run_args=(--workspace-id "$WORKSPACE_ID" --experiment-id "$EXPERIMENT_ID" --run-id "$RUN_ID")
```

## Check results and export CSV

```bash theme={null}
report=$(agentkit eval experiment run report "${run_args[@]}" --json)
jq '.Result | {status: .Run.Status, partial: .IsPartial}' <<< "$report"
agentkit eval experiment run case list "${run_args[@]}" --json
```

Repeat the report query at intervals until the status is `Succeeded`, `Failed` or `Stopped` and `IsPartial` is `false`. Inspect individual scores with a case ID and `experiment run case get`. Failed runs can also be exported.

```bash theme={null}
jq -e '.Result | (.IsPartial == false) and (.Run.Status | IN("Succeeded", "Failed", "Stopped"))' <<< "$report" > /dev/null
export_dir=$(mktemp -d)
agentkit eval experiment run export-report "${run_args[@]}" --client-token answer-report --json > "$export_dir/export.json"
jq -e '.Result.IsPartial == false' "$export_dir/export.json" > /dev/null
curl --fail --silent --show-error --location "$(jq -er '.Result.DownloadUrl' "$export_dir/export.json")" -o "$export_dir/report.csv"
test "$(wc -c < "$export_dir/report.csv" | tr -d ' ')" = "$(jq -er '.Result.FileSize' "$export_dir/export.json")"
(cd "$export_dir" && printf '%s  report.csv\n' "$(jq -er '.Result.SHA256' export.json)" | shasum -a 256 -c -)
```

The download and verification use curl and shasum. Download before `ExpiresAt` and protect the response containing the signed URL. After verification, `report.csv` holds the snapshot for that run.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.