Map the workflow before choosing a framework
Sketch a real run using the last brief your team produced. Mark the steps that happen in a predictable order and the places where someone decides what to do next. Add one awkward case, such as a missing proposal, a timed-out connector or a reviewer who responds the following day.
- Plain Python
- A predictable sequence that fetches known inputs, makes a model call and checks the result.
- PydanticAI
- A model needs to choose among a few tools and return a typed object your Python code can consume.
- LangGraph
- Distinct stages, branches and saved progress need to be visible to developers and operators.
Run the same sample inputs through the options you are considering. A draft that looks impressive in a single run tells you little about how a developer will fix a failed one.
Use PydanticAI for tool choice and typed outputs
In a short research task, the model might use a document search tool, request a specific passage and return a structured brief. PydanticAI lets you define tools and an output type around that loop. The application can then handle the returned object as data and display each claim alongside its evidence. PydanticAI agent documentation.
This configuration sketch defines the expected output. In a working application, set a supported model identifier and credentials, supply evidence in the request or register your read-only search tool, and run the agent from your application.
import os
from pydantic import BaseModel
from pydantic_ai import Agent
class Claim(BaseModel):
text: str
evidence_ids: list[str]
class Brief(BaseModel):
claims: list[Claim]
open_questions: list[str]
agent = Agent(
os.environ["RESEARCH_MODEL"],
output_type=Brief,
instructions=(
"Draft from supplied evidence. Cite evidence IDs "
"and put unsupported conclusions in open_questions."
),
)
Shape validation checks that the response conforms to the schema. Keep business checks in your own code, such as whether the cited IDs were retrieved for the current user. The reviewer still checks that the evidence supports the claim. PydanticAI output validation.
Use LangGraph when the stages and state matter
Imagine a brief that takes a few minutes to draft and waits overnight for a named reviewer. The reviewer can approve the draft, request more evidence or close the case. Make those stages explicit and store the evidence references, draft and review status as workflow state. LangGraph gives you graph-based orchestration and a checkpointer for persisting progress. LangGraph overview.
Test a real pause and resume. With a checkpointer and the same thread ID, a LangGraph interrupt can wait for an external response. The node starts again when it resumes, so code before the interrupt can run twice. Put consequential writes after approval, or make them idempotent using an operation key. LangGraph interrupts.
PydanticAI also offers durable execution integrations. If the team already runs a supported workflow engine, compare the operational effort of using that integration with adding a separate graph runtime. PydanticAI durable execution.
Where LangChain fits
LangChain provides a higher-level agent API for composing a model, tools and middleware. Its agents are built on LangGraph. If the team already uses LangChain integrations and the standard agent loop covers the workflow, that API can be a shorter starting point. Reach for the graph API when you want to define the stages and state transitions yourself. LangChain overview.
Prove the fit with three cases
- Happy path. The agent finds the approved material and returns a usable draft with valid evidence IDs.
- Missing evidence. The agent stops within its tool budget and explains what is missing.
- Interrupted run. The source connector fails or the reviewer responds later. The team can explain what gets retried and where state is stored.
Keep the brief schema, evidence store and evaluation cases separate from the orchestration code. If the workflow later needs a different runtime, you can evaluate the new implementation against the same criteria. See the research agent design for an example of that evidence contract and the development pipeline for the release checks.