> ## Documentation Index
> Fetch the complete documentation index at: https://ritika-fa61c43f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /reset — Initialize a New CRM Pipeline Episode

> POST /reset initializes a fresh episode, loads messy CRM data for the configured task, and returns the first observation with task objective and sources.

`POST /reset` is always the first call you make. It generates a new episode UUID, loads the appropriate messy CRM dataset for the configured task, snapshots the hidden ground truth into isolated per-episode server memory keyed by that UUID, and returns an initial `CRMPipelineObservation`. All in-memory Pandas DataFrames are freshly copied so that concurrent episodes cannot corrupt each other's state.

## Task Selection

The task loaded is controlled by the `TASK_ID` environment variable set on the server process. You do not pass this in the request body.

| `TASK_ID` | Difficulty | Description |
| - | - | - |
| `t1` *(default)* | Easy | Normalize a single `web_forms` dataset — fix dates, lowercase emails, strip whitespace, remove bots |
| `t2` | Medium | Deduplicate the `legacy_db` dataset across two sources — identify fuzzy-matched customers and merge |
| `t3` | Hard | Resolve a 3-way conflict merge across `salesforce`, `web_leads`, and `legacy_db` using explicit conflict rules |

> [!NOTE]
>
> To switch tasks, set `TASK_ID=t2` (or `t3`) in your Docker environment or
> shell before starting the server. A running server uses the value frozen at
> the time of the `/reset` call.

## Request

`POST /reset` accepts an empty JSON body. No fields are required.

```bash theme={null}
curl -X POST http://localhost:8080/reset \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Response

The response always wraps a `CRMPipelineObservation` object alongside top-level convenience scalars.

### Task 1 (`t1`) — Single Source

```json theme={null}
{
  "observation": {
    "done": false,
    "reward": 0.0,
    "current_task_objective": "Normalize web_forms dataset",
    "schema_target": {
      "customer_id": "string",
      "name": "string (stripped)",
      "email": "string (lowercase, stripped)",
      "signup_date": "string ISO 8601 or empty",
      "phone": "string E.164 format (+1...) or empty"
    },
    "available_sources": ["web_forms"],
    "current_view": "Select a source to view.",
    "data_quality_report": "",
    "last_action_feedback": "Environment reset natively for task t1. Episode UUID: 3f8a1b2c-d4e5-6f7a-8b9c-0d1e2f3a4b5c",
    "conflict_rules": null
  },
  "reward": 0.0,
  "done": false
}
```

### Task 2 (`t2`) — Two Sources

```json theme={null}
{
  "observation": {
    "done": false,
    "reward": 0.0,
    "current_task_objective": "Deduplicate legacy_db dataset",
    "schema_target": {
      "customer_id": "string",
      "name": "string (stripped)",
      "email": "string (lowercase, stripped)",
      "signup_date": "string ISO 8601 or empty",
      "phone": "string E.164 format (+1...) or empty"
    },
    "available_sources": ["web_forms", "legacy_db"],
    "current_view": "Select a source to view.",
    "data_quality_report": "",
    "last_action_feedback": "Environment reset natively for task t2. Episode UUID: 7c3e9d1a-f2b4-5e6d-9a8b-7c0d1e2f3a4b",
    "conflict_rules": null
  },
  "reward": 0.0,
  "done": false
}
```

### Task 3 (`t3`) — Three Sources with Conflict Rules

```json theme={null}
{
  "observation": {
    "done": false,
    "reward": 0.0,
    "current_task_objective": "Merge Salesforce, Web Leads, Legacy databases",
    "schema_target": {
      "customer_id": "string",
      "email": "string (lowercase, canonical from Salesforce)",
      "phone": "string (E.164, prefer Web Leads when available)"
    },
    "available_sources": ["salesforce", "web_leads", "legacy_db"],
    "current_view": "Select a source to view.",
    "data_quality_report": "",
    "last_action_feedback": "Environment reset natively for task t3. Episode UUID: a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "conflict_rules": {
      "email": "prefer_salesforce",
      "phone": "prefer_web_leads",
      "customer_id": "prefer_salesforce"
    }
  },
  "reward": 0.0,
  "done": false
}
```

## Response Fields

**observation** `object` *required*

The full `CRMPipelineObservation` object representing the initial environment state.

**observation fields**

**observation.done** `boolean`

Always `false` immediately after reset. Becomes `true` only when a
`SUBMIT_PIPELINE` action is executed with `step_count >= 3`.

**observation.reward** `float`

Always `0.0` after reset. Reward only accrues on subsequent `/step` calls.

**observation.current\_task\_objective** `string`

Human-readable description of the active task. Maps directly to the
`tasks[].description` entry in `openenv.yaml`. Use this string to orient
your agent before it begins profiling sources.

**observation.schema\_target** `object`

The exact output schema your final DataFrame must satisfy to earn a high
grader score. Keys are column names; values describe the required format
(e.g., `"string ISO 8601 or empty"`, `"string E.164 format (+1...) or empty"`).
The grader performs case-insensitive, stripped exact-string comparison
against this schema on every column.

**observation.available\_sources** `array of strings`

The list of DataFrame names currently loaded in server memory for this
episode. Pass these names as the `source` field in subsequent `/step`
actions. New names are added to this list after `EXECUTE_SQL` or
`MERGE_SOURCES` actions that produce an `output_table`.

**observation.current\_view** `string`

A markdown-formatted table showing the top 3 rows of the most recently
viewed source. Always `"Select a source to view."` immediately after reset.
Populated by `VIEW_SOURCE` actions.

**observation.data\_quality\_report** `string | null`

A per-column quality summary rendered as Markdown, showing data type and
null count for each column. Always empty (`""`) after reset. Populated by
`PROFILE_SOURCE` actions.

**observation.last\_action\_feedback** `string`

Human-readable confirmation of the last operation. After reset, this field
contains the episode UUID confirmation string in the format:
`"Environment reset natively for task {task_id}. Episode UUID: {uuid}"`.
**Extract and store this UUID** — you will need it when calling
`/grader/{episode_id}`.

**observation.conflict\_rules** `object | null`

Present only for Task 3 (`t3`). A per-column dictionary declaring which
source takes priority when columns collide during a three-way merge.
For example: `{"email": "prefer_salesforce", "phone": "prefer_web_leads"}`.
`null` for tasks `t1` and `t2`.

**reward** `float`

Top-level convenience mirror of `observation.reward`. Always `0.0` after reset.

**done** `boolean`

Top-level convenience mirror of `observation.done`. Always `false` after reset.

## Extracting the Episode UUID

The episode UUID embedded in `last_action_feedback` is the key you pass to `/grader/{episode_id}`. Parse it out immediately:

```python theme={null}
import requests, re

response = requests.post("http://localhost:8080/reset", json={})
feedback = response.json()["observation"]["last_action_feedback"]
episode_id = re.search(r"Episode UUID: ([^\s]+)", feedback).group(1)
print(episode_id)
# → "3f8a1b2c-d4e5-6f7a-8b9c-0d1e2f3a4b5c"
```

You can also read it from `GET /state` at any point during the episode:

```python theme={null}
state = requests.get("http://localhost:8080/state").json()
episode_id = state["episode_id"]
```

> [!WARNING]
>
> Each call to `POST /reset` creates a completely new episode and a new UUID.
> Calling `/reset` mid-episode discards all progress and all in-memory
> DataFrames accumulated from prior `/step` calls. The old episode's ground
> truth snapshot is retained in server memory under the old UUID, but the
> active environment context is overwritten and the old UUID can no longer
> be used for new `/step` actions.


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