> ## 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.

# GET /state — Retrieve Current Episode State Metadata

> GET /state returns the current CRMPipelineState including the episode UUID, step count, and active task ID for tracking agent progress.

`GET /state` is a lightweight, read-only endpoint that returns the current `CRMPipelineState` object without mutating any data. It exposes the episode UUID, the number of steps executed so far, and the active task identifier. No request body is needed. Use it to monitor agent progress, enforce step thresholds before submitting, or debug episode isolation across concurrent runs.

## Request

```bash theme={null}
curl http://localhost:8080/state
```

No `Content-Type` header or request body is required.

## Response

```json theme={null}
{
  "episode_id": "3f8a1b2c-d4e5-6f7a-8b9c-0d1e2f3a4b5c",
  "step_count": 7,
  "task_id": "t1"
}
```

### Before any `/reset` call

If `/reset` has never been called since server startup, `episode_id` will be `null` and `step_count` will be `0`:

```json theme={null}
{
  "episode_id": null,
  "step_count": 0,
  "task_id": "t1"
}
```

## Response Fields

**episode\_id** `string | null`

The UUID that uniquely identifies the current active episode. This is the
same value embedded in `last_action_feedback` after a `/reset` call, and
the path parameter you supply to `/grader/{episode_id}`.

Returns `null` if no episode has been initialized yet (i.e., `/reset` has
not been called). Once `/reset` is called, this value is stable for the
lifetime of the episode and changes only when `/reset` is called again.

**step\_count** `integer`

The total number of `POST /step` calls executed in the current episode.
This counter increments on **every** `/step` call regardless of whether
the action succeeded or failed — even `-0.05` penalty actions increment it.

The minimum step threshold before `SUBMIT_PIPELINE` is accepted is **3**.
Check this field if you need to programmatically verify that the submission
guard has been cleared.

**task\_id** `string`

The task identifier active for the current episode. Possible values are
`"t1"`, `"t2"`, and `"t3"`, corresponding to the Easy, Medium, and Hard
difficulty tiers respectively. This value is set from the `TASK_ID`
environment variable on the server at the time `/reset` is called.

## Use Cases

### Checking the minimum-step guard

The `SUBMIT_PIPELINE` action is blocked with `reward = -0.15` if `step_count < 3`. Query `/state` before submitting to avoid the penalty:

```python theme={null}
import requests

state = requests.get("http://localhost:8080/state").json()
MIN_STEPS = 3

if state["step_count"] >= MIN_STEPS:
    resp = requests.post("http://localhost:8080/step", json={
        "action_type": "SUBMIT_PIPELINE",
        "final_source": "web_forms"
    })
else:
    print(f"Need {MIN_STEPS - state['step_count']} more steps before submitting.")
```

### Recovering the episode UUID mid-run

If you lost the UUID from the reset response's `last_action_feedback`, retrieve it from `/state` at any time during the episode:

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

# Use it to call the grader
grader_resp = requests.post(
    f"http://localhost:8080/grader/{episode_id}",
    params={"final_source": "web_forms", "task_id": state["task_id"]}
)
```

### Verifying task identity

When running automated evaluation harnesses across multiple tasks, confirm the active task before sending task-specific actions:

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

if state["task_id"] == "t3":
    # Three-way merge workflow
    action = {
        "action_type": "MERGE_SOURCES",
        "source": "salesforce",
        "source2": "web_leads",
        "join_key": "customer_id",
        "conflict_rule": "PREFER_S1"
    }
else:
    # Single-source standardization workflow
    action = {
        "action_type": "STANDARDIZE_COLUMN",
        "source": "web_forms",
        "column": "email",
        "standardization_strategy": "LOWERCASE_STRIP"
    }

requests.post("http://localhost:8080/step", json=action)
```

### Debugging episode isolation

Each call to `/reset` creates a new `episode_id`. If `episode_id` is unexpectedly `null` or `step_count` has reset to `0`, your agent called `/reset` without your knowledge (or the server restarted). The state endpoint makes this immediately visible:

```bash theme={null}
# Before reset
curl http://localhost:8080/state
# → {"episode_id": null, "step_count": 0, "task_id": "t1"}

# After reset
curl -X POST http://localhost:8080/reset -H "Content-Type: application/json" -d '{}'
curl http://localhost:8080/state
# → {"episode_id": "3f8a1b2c-...", "step_count": 0, "task_id": "t1"}

# After 3 steps
curl http://localhost:8080/state
# → {"episode_id": "3f8a1b2c-...", "step_count": 3, "task_id": "t1"}
```

> [!NOTE]
>
> `GET /state` never mutates server state. It is safe to call at any frequency
> — for example, after every `/step` call in a polling loop — without affecting
> rewards or episode progression.


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