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

# Fine-tuning cookbook: tune a model and compare it on the same task

> Run a task on a base model, fine-tune it, run the same task on the tuned checkpoint, and compare the two runs.

> [!WARNING]
>
> **Experimental.** Fine-tuning's operations, fields, and limits can change between releases.

This cookbook runs the whole loop once, end to end: an agent does a task on a base model, you fine-tune that model and score it against the untuned baseline, a second agent runs the **same** task on the tuned checkpoint, and you compare the two runs. Every request is shown as cURL, CLI, and TypeScript; the tab you pick stays selected. Set up your client as in [Fine-tuning](https://docs.labelbox.com/recursion/fine-tuning.md#set-up). Ids and numbers below come from a real run.

The task is small on purpose, so a run takes minutes: classify five support tickets and save the result as `triage.md`.

```text theme={"theme":"css-variables"}
Classify each support ticket as bug, billing, or how-to. Save the result as triage.md with one line per ticket in the form "<number>: <label>".

1. The export button does nothing when I click it.
2. I was charged twice for my March subscription.
3. How do I add a teammate to my workspace?
4. The mobile app crashes when I open settings.
5. Please send me an invoice for last quarter.
```

> [!NOTE]
>
> You need fine-tuning and evaluations enabled for your organization, an [environment](https://docs.labelbox.com/recursion/environments.md) for the sessions, and the Developer or Admin role: it covers creating agents, starting sessions, creating and cancelling fine-tuning jobs, and starting evaluations. See [Fine-tuning](https://docs.labelbox.com/recursion/fine-tuning.md) for how fine-tuning is enabled. Without evaluations, starting evaluations in step 4 returns `400 invalid_request`.

You need an [environment](https://docs.labelbox.com/recursion/environments.md) for the sessions. Create one, or use any environment you already have, and keep its `environmentId`.

## 1. Run the task on the base model

Create an agent on the base model. Take the model id of **Inkling 2 Small** from the model list, under its maker; it is the same model the fine-tuning job in step 2 trains (the job names it `thinkingmachines/Inkling-2-Small`). See [Agent setup](https://docs.labelbox.com/recursion/agents.md).

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v2/agents' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Idempotency-Key: cookbook-agent-base' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "name": "Cookbook: base model",
>     "model": "<base-model-id>",
>     "system": "You are a support triage assistant. Follow the task exactly and save deliverables as files."
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents create-agent-v2 --input-stdin <<'JSON'
> {"Idempotency-Key":"cookbook-agent-base","body":{"name":"Cookbook: base model","model":"<base-model-id>","system":"You are a support triage assistant. Follow the task exactly and save deliverables as files."}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.createAgentV2({
>   "Idempotency-Key": "cookbook-agent-base",
>   body: {
>     name: "Cookbook: base model",
>     model: "<base-model-id>",
>     system: "You are a support triage assistant. Follow the task exactly and save deliverables as files.",
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

The response carries `agentId` (here `5058a0fe-b1c9-43f7-b9bb-8eb7ab7b712c`). Start a session with the task and the environment.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v2/sessions' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Idempotency-Key: cookbook-session-base' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "agentId": "5058a0fe-b1c9-43f7-b9bb-8eb7ab7b712c",
>     "environmentId": "276001d2-f5f2-4736-84b2-bb1bcc1d561e",
>     "message": "Classify each support ticket as bug, billing, or how-to. Save the result as triage.md with one line per ticket in the form \"<number>: <label>\".\n\n1. The export button does nothing when I click it.\n2. I was charged twice for my March subscription.\n3. How do I add a teammate to my workspace?\n4. The mobile app crashes when I open settings.\n5. Please send me an invoice for last quarter."
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents start-session-v2 --input-stdin <<'JSON'
> {"Idempotency-Key":"cookbook-session-base","body":{"agentId":"5058a0fe-b1c9-43f7-b9bb-8eb7ab7b712c","environmentId":"276001d2-f5f2-4736-84b2-bb1bcc1d561e","message":"Classify each support ticket as bug, billing, or how-to. Save the result as triage.md with one line per ticket in the form \"<number>: <label>\".\n\n1. The export button does nothing when I click it.\n2. I was charged twice for my March subscription.\n3. How do I add a teammate to my workspace?\n4. The mobile app crashes when I open settings.\n5. Please send me an invoice for last quarter."}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.startSessionV2({
>   "Idempotency-Key": "cookbook-session-base",
>   body: {
>     agentId: "5058a0fe-b1c9-43f7-b9bb-8eb7ab7b712c",
>     environmentId: "276001d2-f5f2-4736-84b2-bb1bcc1d561e",
>     message: "Classify each support ticket as bug, billing, or how-to. Save the result as triage.md with one line per ticket in the form \"<number>: <label>\".\n\n1. The export button does nothing when I click it.\n2. I was charged twice for my March subscription.\n3. How do I add a teammate to my workspace?\n4. The mobile app crashes when I open settings.\n5. Please send me an invoice for last quarter.",
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

The session is accepted right away:

```json theme={"theme":"css-variables"}
{
  "sessionId": "cc59d531-d49d-5034-b18c-966ef9f4b6c8",
  "statusUrl": "/managed-agents/v2/sessions/cc59d531-d49d-5034-b18c-966ef9f4b6c8"
}
```

Read it until it leaves `active`; see [Sessions](https://docs.labelbox.com/recursion/sessions.md#watch-it-work). `costState` stays `so_far` until the sandbox stops at the environment's idle stop (30 minutes by default) and its charges settle, which can take up to an hour more. Read the session again until it is `final` before you compare costs; see [Usage and cost](https://docs.labelbox.com/recursion/usage-and-cost.md#know-when-a-figure-is-final).

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl 'https://api.recursion.labelbox.com/managed-agents/v2/sessions/cc59d531-d49d-5034-b18c-966ef9f4b6c8?view=summary' \
>   -H "Authorization: Bearer $RECURSION_API_KEY"
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents get-session-v2 --input-stdin <<'JSON'
> {"sessionId":"cc59d531-d49d-5034-b18c-966ef9f4b6c8","view":"summary"}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.getSessionV2({
>   sessionId: "cc59d531-d49d-5034-b18c-966ef9f4b6c8",
>   view: "summary",
> });
> if (error !== undefined) throw new Error(error.message);
> ```

```json theme={"theme":"css-variables"}
{
  "sessionId": "cc59d531-d49d-5034-b18c-966ef9f4b6c8",
  "status": "completed",
  "executionState": "idle",
  "stopReason": "end_turn",
  "costUsd": "0.009878064",
  "costState": "so_far"
}
```

The agent saved `triage.md` with `1: bug`, `2: billing`, `3: how-to`, `4: bug`, `5: billing`.

## 2. Fine-tune and read the scores

Create a short training run that saves a checkpoint after every step. A baseline job (`steps: 0`) scores the untuned model on its own; it is optional here, because a trained job already reports its untuned score as `summary.evalReward.base`. This cookbook creates both so you can see how much held-out scores vary between runs.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v2/fine-tuning-jobs' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Idempotency-Key: cookbook-baseline' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "model": "thinkingmachines/Inkling-2-Small",
>     "dataset": "automationbench-public-600",
>     "name": "Cookbook: untuned baseline",
>     "settings": {
>       "steps": 0,
>       "evalSet": "quick"
>     }
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents create-fine-tuning-job --input-stdin <<'JSON'
> {"Idempotency-Key":"cookbook-baseline","body":{"model":"thinkingmachines/Inkling-2-Small","dataset":"automationbench-public-600","name":"Cookbook: untuned baseline","settings":{"steps":0,"evalSet":"quick"}}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.createFineTuningJob({
>   "Idempotency-Key": "cookbook-baseline",
>   body: {
>     model: "thinkingmachines/Inkling-2-Small",
>     dataset: "automationbench-public-600",
>     name: "Cookbook: untuned baseline",
>     settings: {
>       steps: 0,
>       evalSet: "quick",
>     },
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v2/fine-tuning-jobs' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Idempotency-Key: cookbook-tune' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "model": "thinkingmachines/Inkling-2-Small",
>     "dataset": "automationbench-public-600",
>     "name": "Cookbook: tune Inkling",
>     "settings": {
>       "steps": 2,
>       "checkpointEvery": 1,
>       "evalEvery": 1,
>       "evalSet": "quick"
>     }
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents create-fine-tuning-job --input-stdin <<'JSON'
> {"Idempotency-Key":"cookbook-tune","body":{"model":"thinkingmachines/Inkling-2-Small","dataset":"automationbench-public-600","name":"Cookbook: tune Inkling","settings":{"steps":2,"checkpointEvery":1,"evalEvery":1,"evalSet":"quick"}}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.createFineTuningJob({
>   "Idempotency-Key": "cookbook-tune",
>   body: {
>     model: "thinkingmachines/Inkling-2-Small",
>     dataset: "automationbench-public-600",
>     name: "Cookbook: tune Inkling",
>     settings: {
>       steps: 2,
>       checkpointEvery: 1,
>       evalEvery: 1,
>       evalSet: "quick",
>     },
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

Follow each job as in [Fine-tuning](https://docs.labelbox.com/recursion/fine-tuning.md#follow-a-run). Both ran in about seven minutes here. When the tuned job succeeds, read its scores: `base` is the untuned model's score at step 0 and `final` the score after training.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl 'https://api.recursion.labelbox.com/managed-agents/v2/fine-tuning-jobs/ec93afa1-6627-59b7-a733-5fa91deea3d5' \
>   -H "Authorization: Bearer $RECURSION_API_KEY"
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents get-fine-tuning-job --input-stdin <<'JSON'
> {"jobId":"ec93afa1-6627-59b7-a733-5fa91deea3d5"}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.getFineTuningJob({
>   jobId: "ec93afa1-6627-59b7-a733-5fa91deea3d5",
> });
> if (error !== undefined) throw new Error(error.message);
> ```

```json theme={"theme":"css-variables"}
{
  "jobId": "ec93afa1-6627-59b7-a733-5fa91deea3d5",
  "name": "Cookbook: tune Inkling",
  "status": "succeeded",
  "attempt": 1,
  "summary": {
    "evalReward": {"base": 0.6516666666666666, "final": 0.6566666666666666}
  }
}
```

| Tuned run (`ec93afa1-6627-59b7-a733-5fa91deea3d5`) | Steps | `base` | `final` |
| - | - | - | - |
| Quick held-out set | 2 | 0.6517 | 0.6567 |

The separate baseline job (`776fd97b-c35c-54ef-aeda-506a39306036`) scored the same untuned model on the same quick held-out set at 0.6317. That is 0.02 below the tuned job's own `base`, with no training in between: held-out scores vary from run to run because the model samples its answers, and that variation is larger than this tune's gain. Compare `base` with `final` inside one job, and treat a difference smaller than the run-to-run spread as noise.

Two steps move the held-out reward by about 0.005, well inside that spread: this tune barely moves results, and the cookbook shows the mechanics, not a gain. Longer runs on the full task sets can move the score more; the spread above was measured on the 10-task `quick` held-out set, so it does not carry over to the 120-task `full` set, and scores on `quick` and `full` are not comparable. These full runs each trained 40 to 50 steps on the `full` train and held-out sets and gained 0.0125 to 0.04:

| Job | Model | Steps | Held-out reward before | Held-out reward after |
| - | - | - | - | - |
| `78b86dfd-a86f-5a4e-ad9b-e8ea7948bc21` | Inkling-2-Small | 45 | 0.8061 | 0.8202 |
| `9a516393-e336-5f86-b364-3903b3d6b4f6` | NVIDIA-Nemotron-3-Super-120B-A12B-BF16 | 40 | 0.3485 | 0.3610 |
| `fd50b2b4-e614-5bb0-b62e-1de375f8f22c` | NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16 | 50 | 0.1142 | 0.1549 |

Even these gains are modest, so compare against a baseline on the same held-out set before you rely on a tuned model. See [Run a long job](https://docs.labelbox.com/recursion/fine-tuning.md#run-a-long-job) for how to run one.

## 3. Run the same task on the tuned checkpoint

List the checkpoints and copy the `tunedModel` of the one you want. Every saved checkpoint is a model; this run saved one after each step.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl 'https://api.recursion.labelbox.com/managed-agents/v2/fine-tuning-jobs/ec93afa1-6627-59b7-a733-5fa91deea3d5/checkpoints' \
>   -H "Authorization: Bearer $RECURSION_API_KEY"
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents list-fine-tuning-job-checkpoints --input-stdin <<'JSON'
> {"jobId":"ec93afa1-6627-59b7-a733-5fa91deea3d5"}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.listFineTuningJobCheckpoints({
>   jobId: "ec93afa1-6627-59b7-a733-5fa91deea3d5",
> });
> if (error !== undefined) throw new Error(error.message);
> ```

Create an agent whose model is that value, with the same instructions, and start the same task in the same environment.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v2/agents' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Idempotency-Key: cookbook-agent-tuned' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "name": "Cookbook: tuned model",
>     "model": "<tunedModel>",
>     "system": "You are a support triage assistant. Follow the task exactly and save deliverables as files."
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents create-agent-v2 --input-stdin <<'JSON'
> {"Idempotency-Key":"cookbook-agent-tuned","body":{"name":"Cookbook: tuned model","model":"<tunedModel>","system":"You are a support triage assistant. Follow the task exactly and save deliverables as files."}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.createAgentV2({
>   "Idempotency-Key": "cookbook-agent-tuned",
>   body: {
>     name: "Cookbook: tuned model",
>     model: "<tunedModel>",
>     system: "You are a support triage assistant. Follow the task exactly and save deliverables as files.",
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v2/sessions' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Idempotency-Key: cookbook-session-tuned' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "agentId": "88769121-b189-4e7e-bafa-8fd9bdfcb282",
>     "environmentId": "276001d2-f5f2-4736-84b2-bb1bcc1d561e",
>     "message": "Classify each support ticket as bug, billing, or how-to. Save the result as triage.md with one line per ticket in the form \"<number>: <label>\".\n\n1. The export button does nothing when I click it.\n2. I was charged twice for my March subscription.\n3. How do I add a teammate to my workspace?\n4. The mobile app crashes when I open settings.\n5. Please send me an invoice for last quarter."
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents start-session-v2 --input-stdin <<'JSON'
> {"Idempotency-Key":"cookbook-session-tuned","body":{"agentId":"88769121-b189-4e7e-bafa-8fd9bdfcb282","environmentId":"276001d2-f5f2-4736-84b2-bb1bcc1d561e","message":"Classify each support ticket as bug, billing, or how-to. Save the result as triage.md with one line per ticket in the form \"<number>: <label>\".\n\n1. The export button does nothing when I click it.\n2. I was charged twice for my March subscription.\n3. How do I add a teammate to my workspace?\n4. The mobile app crashes when I open settings.\n5. Please send me an invoice for last quarter."}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.startSessionV2({
>   "Idempotency-Key": "cookbook-session-tuned",
>   body: {
>     agentId: "88769121-b189-4e7e-bafa-8fd9bdfcb282",
>     environmentId: "276001d2-f5f2-4736-84b2-bb1bcc1d561e",
>     message: "Classify each support ticket as bug, billing, or how-to. Save the result as triage.md with one line per ticket in the form \"<number>: <label>\".\n\n1. The export button does nothing when I click it.\n2. I was charged twice for my March subscription.\n3. How do I add a teammate to my workspace?\n4. The mobile app crashes when I open settings.\n5. Please send me an invoice for last quarter.",
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

Read the session as before. The tuned agent finished the task and saved the same `triage.md`; its session cost `0.004380146`, final.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl 'https://api.recursion.labelbox.com/managed-agents/v2/sessions/1df0dda0-d7b1-56ce-839e-fd00f3857289?view=summary' \
>   -H "Authorization: Bearer $RECURSION_API_KEY"
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents get-session-v2 --input-stdin <<'JSON'
> {"sessionId":"1df0dda0-d7b1-56ce-839e-fd00f3857289","view":"summary"}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.getSessionV2({
>   sessionId: "1df0dda0-d7b1-56ce-839e-fd00f3857289",
>   view: "summary",
> });
> if (error !== undefined) throw new Error(error.message);
> ```

## 4. Compare the two runs

Both sessions are finished, so an evaluator agent can grade them against the same criteria. Any agent in your organization can grade; give it a model and instructions that judge a finished session. Pick a model id from the model list.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v2/agents' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Idempotency-Key: cookbook-grader' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "name": "Cookbook grader",
>     "model": "<evaluator-model-id>",
>     "system": "You grade a finished support-triage session against the criteria. Check triage.md in the workspace and cite what you found. Do not redo the task."
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents create-agent-v2 --input-stdin <<'JSON'
> {"Idempotency-Key":"cookbook-grader","body":{"name":"Cookbook grader","model":"<evaluator-model-id>","system":"You grade a finished support-triage session against the criteria. Check triage.md in the workspace and cite what you found. Do not redo the task."}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.createAgentV2({
>   "Idempotency-Key": "cookbook-grader",
>   body: {
>     name: "Cookbook grader",
>     model: "<evaluator-model-id>",
>     system: "You grade a finished support-triage session against the criteria. Check triage.md in the workspace and cite what you found. Do not redo the task.",
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

The response carries `agentId` (here `f02dc7ae-83ad-450a-bd7f-b68047528523`). Start one evaluation per session in one batch. See [Outcome rubrics](https://docs.labelbox.com/recursion/outcomes.md) for how criteria are written. Starting a batch takes no `Idempotency-Key` and is not safe to retry: a retry starts another batch. A verdict appears in the list only when its evaluation finishes, so before sending the request again, list sessions with `evaluationTargetSessionId=<target>` and the evaluation kind, or list evaluation runs. Check each item of the response too: an item with `errorCode` did not start.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl -X POST 'https://api.recursion.labelbox.com/managed-agents/v1/evaluations' \
>   -H "Authorization: Bearer $RECURSION_API_KEY" \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "evaluatorAgentId": "f02dc7ae-83ad-450a-bd7f-b68047528523",
>     "criteria": [
>       {
>         "criterion_key": "triage-file",
>         "criterion_text": "triage.md exists and has exactly five lines in the form \"<number>: <label>\", numbered 1 to 5, each label one of bug, billing or how-to."
>       },
>       {
>         "criterion_key": "labels-correct",
>         "criterion_text": "The labels are 1: bug, 2: billing, 3: how-to, 4: bug, 5: billing."
>       }
>     ],
>     "targets": {
>       "session_ids": [
>         "cc59d531-d49d-5034-b18c-966ef9f4b6c8",
>         "1df0dda0-d7b1-56ce-839e-fd00f3857289"
>       ]
>     }
>   }'
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents start-evaluations --input-stdin <<'JSON'
> {"body":{"evaluatorAgentId":"f02dc7ae-83ad-450a-bd7f-b68047528523","criteria":[{"criterion_key":"triage-file","criterion_text":"triage.md exists and has exactly five lines in the form \"<number>: <label>\", numbered 1 to 5, each label one of bug, billing or how-to."},{"criterion_key":"labels-correct","criterion_text":"The labels are 1: bug, 2: billing, 3: how-to, 4: bug, 5: billing."}],"targets":{"session_ids":["cc59d531-d49d-5034-b18c-966ef9f4b6c8","1df0dda0-d7b1-56ce-839e-fd00f3857289"]}}}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.startEvaluations({
>   body: {
>     evaluatorAgentId: "f02dc7ae-83ad-450a-bd7f-b68047528523",
>     criteria: [{
>       criterion_key: "triage-file",
>       criterion_text: "triage.md exists and has exactly five lines in the form \"<number>: <label>\", numbered 1 to 5, each label one of bug, billing or how-to.",
>     }, {
>       criterion_key: "labels-correct",
>       criterion_text: "The labels are 1: bug, 2: billing, 3: how-to, 4: bug, 5: billing.",
>     }],
>     targets: {
>       session_ids: ["cc59d531-d49d-5034-b18c-966ef9f4b6c8", "1df0dda0-d7b1-56ce-839e-fd00f3857289"],
>     },
>   },
> });
> if (error !== undefined) throw new Error(error.message);
> ```

```json theme={"theme":"css-variables"}
{
  "evaluationBatchId": "290a5734-d1cf-44c2-b0d7-39718f232e40",
  "items": [
    {"targetSessionId": "cc59d531-d49d-5034-b18c-966ef9f4b6c8", "evaluationSessionId": "beb92c5b-267c-4617-99a9-3ed467ef8c37"},
    {"targetSessionId": "1df0dda0-d7b1-56ce-839e-fd00f3857289", "evaluationSessionId": "b8ef726d-39a1-40f8-8c33-21f3c70537ea"}
  ]
}
```

Each evaluation runs as its own session and takes a few minutes. List the verdicts for your evaluator agent, so other evaluations in the organization do not mix in; each item has the target session, the `result`, a `summary`, and a verdict with a rationale for each criterion.

> [tab] cURL
>
> ```bash theme={"theme":"css-variables"}
> curl 'https://api.recursion.labelbox.com/managed-agents/v2/evaluations?evaluatorAgentId=f02dc7ae-83ad-450a-bd7f-b68047528523&limit=10' \
>   -H "Authorization: Bearer $RECURSION_API_KEY"
> ```

> [tab] CLI
>
> ```bash theme={"theme":"css-variables"}
> recursion managed-agents list-managed-agent-evaluations-v2 --input-stdin <<'JSON'
> {"evaluatorAgentId":"f02dc7ae-83ad-450a-bd7f-b68047528523","limit":10}
> JSON
> ```

> [tab] TypeScript
>
> ```typescript theme={"theme":"css-variables"}
> const { data, error } = await recursion.managedAgents.listManagedAgentEvaluationsV2({
>   evaluatorAgentId: "f02dc7ae-83ad-450a-bd7f-b68047528523",
>   limit: 10,
> });
> if (error !== undefined) throw new Error(error.message);
> ```

| Run | Agent | Result | Criteria |
| - | - | - | - |
| Base model, session `cc59d531` | `5058a0fe` | pass | `triage-file` pass, `labels-correct` pass |
| Tuned checkpoint, session `1df0dda0` | `88769121` | pass | `triage-file` pass, `labels-correct` pass |

Compare more than pass or fail: the verdict rationales, the held-out scores from step 2, and cost. Tuned-model turns are charged per token like any model. Once both sessions are `final`, their totals (here base `0.034016485`, tuned `0.004380146`) also include sandbox time, which differs between runs, so they do not isolate the model. To compare each session's own token counts, use `listSessionUsage`; see [Usage and cost](https://docs.labelbox.com/recursion/usage-and-cost.md). In the console, open **Advanced**, then **Evaluations**: **Activity** lists each evaluation run with its evaluating agent, progress, and result, and its **Targets** tab shows the verdict and the criteria it checked. To compare agents over time, use the **Quality** tab with the source set to **Evaluations**.

## What can go wrong

* **`400` when starting evaluations.** "Evaluations are not enabled for this organization." (`invalid_request`) means evaluations are off. A `404` means an evaluator agent or session id is wrong. A session that has not finished comes back as an item with `errorCode` `invalid_request`: wait for it to finish, then start that one again.
* **`400` creating the tuned agent.** The model id is not a tuned-model id: copy `tunedModel` exactly.
* **The tuned session ends `failed` with a model error.** The id is well formed but names no checkpoint. Copy it again from the checkpoint list; see [Fine-tuning](https://docs.labelbox.com/recursion/fine-tuning.md#use-a-tuned-model-in-an-agent).

## Clean up

Delete what you created when you are done: the sessions, the base, tuned, and evaluator agents, and the environment if you made one. Fine-tuning jobs and their checkpoints are kept; there is no delete for a job. Evaluation verdicts stay after you delete the sessions.

## Next steps

> [card] [Fine-tuning](https://docs.labelbox.com/recursion/fine-tuning.md)
>
> Every operation, with examples of the common ones.

> [card] [Fine-tuning reference](https://docs.labelbox.com/recursion/fine-tuning-reference.md)
>
> Settings, states, and metrics.

> [card] [Outcome rubrics](https://docs.labelbox.com/recursion/outcomes.md)
>
> How criteria are written.

> [card] [Limits](https://docs.labelbox.com/recursion/limits.md#fine-tuning)
>
> Every fine-tuning bound.
