Framework · Orchestration Frameworks

Marvin

Express agentic AI work as a set of structured Tasks executed by portable Agents inside Threads, producing validated Pydantic outputs.

Description

Marvin is PrefectHQ's Python framework for structured AI outputs and task-based agentic workflows. Marvin 3.x merged the developer ergonomics of Marvin 2.x with the agentic engine of ControlFlow (and supersedes ControlFlow). The core abstractions are Task (a structured unit of work with a result type), Agent (a portable LLM configuration assigned to tasks), and Thread (a conversation context that maintains history and shared state across tasks). Internally Marvin uses Pydantic AI for LLM interactions and supports the LLM providers Pydantic AI supports. Threads persist in SQLite; structured outputs are validated against Pydantic types.

Solution

Task-centric agentic loop. Each Task names a result type, an agent, and optional tools; the agent runs Pydantic AI under the hood, calling tools until the result conforms to the declared type. Threads compose Tasks into customizable chains that share history; thread state is persisted to SQLite so a thread can be resumed by id.

Primary use cases

  • extracting and validating structured data from unstructured text
  • composing AI workflows from typed Tasks
  • sequencing tool-using agents within a Thread
  • casting/classifying/summarising with Pydantic-validated returns

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.