> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# GET /v1/streams/{stage_id}/packs

```text
GET https://weights.fyi/run/v1/streams/{stage_id}/packs?lookahead_window=32
Authorization: Bearer <token>                    scope: read
```

**Available since:** 2026-10-28: included in this build; see [What is live](/run/docs/what-is-live.md) for deployment status.

**Answer time:** synchronous database read; no source download or materialization.

Reads a stream's backlog and the next lazy registrations to prepare. This is a lookahead snapshot, not a paginated listing of every pack. Use the plan's `stream_id` as `{stage_id}`, or supply the authored stage identifier with `?plan_id=...`.

The `deficit` is the number of pending packs needed to fill the requested window, bounded by the stream's admission limit after live leases are counted. Expired leases do not consume that limit. The returned `next_lazy_packs` are ordered by ordinal and contain at most `deficit` entries; several readers can receive the same entries because this call reserves nothing.

## Request

No body.

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | Bearer token with `read`. |
| `stage_id` | path | yes | Qualified stream identifier or authored stage identifier. |
| `plan_id` | query | no | Disambiguates an authored stage identifier. Must agree with a qualified identifier. |
| `lookahead_window` | query | no | Integer from `0` through `9223372036854775807`; default `32`. Zero returns no lazy candidates. |

## Return value

**200 OK**. Selected fields:

| Field | Meaning |
|---|---|
| `plan_id`, `stage_id`, `stream_id` | Plan identifier, authored stage identifier and qualified `plan_id~stage_id`. |
| `plan_state`, `stage_state`, `pickup_status` | Current progress; pickup can be `completed`, `draining`, `ready_for_pickup`, `queued_waiting_flush` or `waiting_primary_or_price`. |
| `stream_sealed` | Whether new pack identifiers are refused; existing lazy registrations can still be promoted. |
| `packs_total`, `packs_completed` | All registered packs and successfully completed packs. |
| `counts` | Counts by stored state, including `lazy`, `pending`, `completed`, `expired_incomplete` and, when present, `dead_lettered`; execution counts also have the dedicated fields below. |
| `leased_live`, `leased_expired` | Leases whose expiry is respectively after, or at/before, the current time. |
| `active_packs` | Pending plus live leased packs. |
| `lookahead_window` | The requested window. |
| `max_pending_packs`, `backpressured` | Configured limit, or null; true when active packs reach it. A per-registration override is not persisted here. |
| `deficit` | Without a limit: `max(0, lookahead_window - pending)`. With a limit: `max(0, min(lookahead_window, max_pending_packs - leased_live) - pending)`. Zero under backpressure. |
| `next_lazy_packs` | Normalized registrations in ordinal order. May be shorter than `deficit`; no `state` field is added to each registration. |
| `policy_signal` | Advisory; `pause_materialization` means no deficit or backpressure, and `materialize_next_lazy` suggests preparing candidates now. |
| `last_poll_at_ms` | Latest execution poll in Unix milliseconds, or null; a service-wide observation. |

## Errors

| Status | Code | Action |
|---|---|---|
| `400` | `invalid_compute_plan` | Use a nonnegative integer window and a stage that accepts packs. |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | Supply a valid token. |
| `403` | `scope_required`, `account_suspended` | Restore `read` scope or account access. |
| `404` | `compute_stage_not_found` | Check ownership and identifiers. |
| `409` | `ambiguous_compute_stage` | Supply `plan_id` or use `stream_id`. |

## Examples

```sh
curl -s 'https://weights.fyi/run/v1/streams/STAGE_ID/packs?plan_id=PLAN_ID&lookahead_window=2' \
  -H "Authorization: Bearer $WEIGHTS_API_KEY"
```

Selected response fields for one pending pack and one lazy pointer:

```json
{
  "plan_id": "PLAN_ID", "stage_id": "STAGE_ID", "stream_id": "PLAN_ID~STAGE_ID",
  "stream_sealed": false, "packs_total": 2, "packs_completed": 0,
  "lookahead_window": 2, "max_pending_packs": 4, "backpressured": false,
  "counts": {"lazy": 1, "pending": 1, "completed": 0, "expired_incomplete": 0},
  "leased_live": 0, "leased_expired": 0, "active_packs": 1, "deficit": 1,
  "next_lazy_packs": [{
    "plan_id": "PLAN_ID", "stage_id": "STAGE_ID", "pack_id": "p1", "ordinal": 1,
    "item_count": 100, "source_uri": "gs://corpus/part-1.jsonl", "source_shards": null,
    "r2_input_uri": null, "sha256": null, "prefix_hash": null,
    "compressed_bytes": null, "est_input_tokens": null, "est_output_tokens": null
  }]
}
```

## Patterns

Prepare the suggested lazy packs, then repost each with its identifier, ordinal, digest, size and `state: "pending"`. Registration may still return `429 stream_backpressure` if other work filled the window after this read. Poll again after active work drains.

## History

- 2026-10-28: documented lookahead, lazy candidates, admission counts and sealed streams.

## See also

- [POST /v1/streams/{stage_id}/packs](/run/docs/reference/streams-packs-create.md).
- [POST /v1/streams/{stage_id}/seal](/run/docs/reference/streams-seal.md).
- [GET /v1/compute/plans/{plan_id}](/run/docs/reference/compute-plans-get.md).
