# Writing the state

> What to send as the situation, and how long it can be.

Section: Concepts. Web page: https://www.launchables.ai/docs/state

The `state` is everything Myles needs to know to answer: the message, the record, the policy and the case. Send it as text, or as JSON, which is passed to the model as indented JSON.

## What to include

- **The thing being decided about.** The message, the application or the action an agent wants to take.
- **The rule, if there is one.** A refund policy, an eligibility rule or a routing guide. Put it in the state, not the question.
- **Only what matters.** Every token is read and, on the hosted API, paid for. Leave out signatures, footers and quoted history.

```json
{
  "state": {
    "policy": "Refunds within 30 days with proof of purchase.",
    "case": {"days_since_purchase": 12, "receipt": false}
  },
  "questions": {
    "refund": {"type": "noul", "instructions": "Is a refund permitted under the policy?"}
  }
}
```

## How long it can be

- A state longer than 20,000 characters (about 5,000 tokens) is cut to its beginning before the model reads it, so very long inputs are answered rather than refused. Put what matters first.
- A state over 200,000 characters is refused with `413`.
- The whole request body can be up to 32 MiB.
- The state and a question together must fit the model's context window (32,768 tokens on the hosted Myles-G 12B, 16,384 on the hosted Myles-G 31B); otherwise that request returns `422`.

## Images in the state

On Myles-G 12B and Myles-G 31B the state can include images. Send each image in `assets` under a reference, then write the reference where the image belongs. In a JSON state, put it in as a value; keys are not searched:

```json
{
  "state": {
    "policy": "Refunds within 30 days with proof of purchase.",
    "photo": "photo_1"
  },
  "questions": {
    "damaged": {"type": "noul", "instructions": "Does the item in the photo look damaged?"}
  },
  "assets": {
    "photo_1": {"format": "jpeg", "data_base64": "..."}
  }
}
```

An image in the state is billed once per request, however many questions read it, so the state is the best place for a picture several questions are about. A reference must fall within the first 20,000 characters of the state, the part the model reads (a JSON state counts as its indented JSON), so in a long state put image references early: one beyond that point is refused with `400` `image_reference_truncated` rather than answered without the image. See [Images](https://www.launchables.ai/docs/api/images) for formats, limits and billing.

## Writing the question

Write `instructions` as you would ask a careful colleague: one question, plain words, no answer hidden in it. Describe each option in `criteria` when the labels alone are ambiguous.
