# Agent Can T Parse Prefect Flow Run Sta B7c94b87f55897f3

> Fixes agent parsers breaking on Prefect flow run states: the state model, terminal versus non-terminal, and defensive parsing. Use when state parsing fails. Not for runs stuck in a state.

- Skill: `vectle/agent-can-t-parse-prefect-flow-run-sta-b7c94b87f55897f3` (Agent Skill)
- Install (CLI): `npx get-skill add vectle/agent-can-t-parse-prefect-flow-run-sta-b7c94b87f55897f3`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vectle/agent-can-t-parse-prefect-flow-run-sta-b7c94b87f55897f3/raw
- Safety review: pending (external: skill-scanner PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: Vectle (https://skillmd.com/u/vectle)
- Updated: 2026-11-19
- Page: https://skillmd.com/skills/vectle/agent-can-t-parse-prefect-flow-run-sta-b7c94b87f55897f3

---


## TL;DR
Prefect's state model has more states than agents expect: Scheduled, Pending, Running, plus Crashed, Cancelled, and Paused variants. Parse states against the full enum and classify terminal versus non-terminal explicitly. A parser with a hardcoded short list breaks on the first state it did not anticipate.

```text
agent can't parse prefect flow run states, parser failed
```

## Use this when
- An agent's parser fails on a Prefect flow run state.
- A new state appears that the parser did not know.
- Terminal versus non-terminal classification is wrong.

## Not for this skill when
- The run is stuck in a state. That is a run problem.
- States parse but the agent misjudges them. That is logic, not parsing.

## Steps
1. Capture the unparsable state value verbatim. Note the value. Verify: the gap is named
2. Read Prefect's state enum for the full list in your version. Note the complete set. Verify: the enum is on the table
3. Rewrite the parser to accept the full enum and classify terminal states explicitly. Note the new logic. Verify: the parser is complete
4. Add every state as a regression case. Note the tests. Verify: the enum is pinned
5. Verify against a live run history with varied states. Note the clean parse. Verify: the fix is verified

## Variant phrasings
### prefect flow run states list
The enum-shaped search.
### prefect terminal states
The classification phrasing.

Compatibility: Prefect 2.x state model. New states can appear in minor versions; parse defensively.

## Why it happens
Prefect models run lifecycle richly: the difference between Crashed and Failed matters, and Paused, Suspended, and Cancelling exist for real workflows. Agents written against a mental model of pending, running, done break on the richer reality. Worse, misclassifying a non-terminal state as terminal makes the agent stop watching a run that is still alive. Parsing the full enum and classifying explicitly turns the state model from a trap into a tool.

## Edge cases / pitfalls
- Prefect 2.x added states across minor versions. A parser pinned to one version's enum rots; fetch or vendor the current enum.
- State names are strings in the API. Compare case-sensitively against the enum; do not lowercase and hope.
- Subflow and task runs share the state model but transition differently. The same parser works; the expectations differ.
- A state the parser has never seen should raise loudly, not default to something. Unknown is a bug signal.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_j53ZoUFPn2ThosqpX6NIOA


---

Source: [Vectle](https://vectle.com/skills/skl_jWr_BnfsppcDj8XbpGAp4g). Version: `skv_Ga7OIps_SiPsLtfIRuLb8A`. Original contributor attribution is preserved in the frontmatter. Content remains subject to [Vectle’s terms](https://vectle.com/terms) and its contributors’ rights; this mirror does not grant a new content license.

