Marvin
also known as ControlFlow (predecessor)
Type: full-code · Vendor: Prefect Technologies · Language: Python · License: Apache-2.0 · Status: active · Status in practice: emerging
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.
Agent loop shape. 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
Key concepts
- Task → structured-output (docs) — Structured unit of work with a declared result type, assigned tools, and an assigned Agent; the result is validated before return.
- Agent (docs) — Portable LLM configuration (model, instructions, tools) that can be assigned to one or more tasks.
- Thread → session-isolation (docs) — Conversation context that spans tasks; persisted to SQLite so it can be resumed by id.
- Pydantic AI backbone (docs) — Marvin 3 uses Pydantic AI for LLM interactions and inherits its provider matrix.
Patterns this full-code implements —
- ★★Structured Output
Tasks declare a result_type; Pydantic AI validates the LLM output against it. The framework's primary purpose is structured outputs.
- ★★Tool Use
Tasks and Agents both accept a list of tool Python functions; agents call tools during task execution and use them to mark task status.
- ★★Session Isolation
Threads are per-conversation contexts that scope shared state; each thread maintains its own conversation history.
- ★★ReAct
Marvin 3 delegates LLM interactions to Pydantic AI, which runs a tool-calling loop until the typed result is produced; agents use tools to mark tasks SUCCESSFUL or FAILED.
- ★★Agent Resumption
Threads can be persisted to SQLite and created with an explicit id so a later run resumes the same conversation; not per-step checkpointing.
Neighbourhood
Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.