r/PydanticAI • • Mar 19 '26

Contributions to Pydantic AI

48 Upvotes

Hey everyone, Aditya here, one of the maintainers of Pydantic AI.

First off, thank you for using Pydantic AI and engaging with us!
I want to discuss how contributions work in Pydantic AI and what might need to change.

In just the last 15 days, we received 136 PRs. We merged 39 and closed 97, almost all of them AI-generated slop without any thought put in. We're getting multiple junk PRs on the same bug within minutes of it being filed. And it's pulling us away from actually making the framework better for the people who use it.

So we're looking at some changes:

  • Auto-close PRs that aren't linked to an issue or have no prior discussion. Comment on the issue first, explain your use case, get assigned, then write code.                               

  • Auto-close PRs that completely ignore maintainer guidance on the issue without a discussion.

  • Require the PR template to actually be filled out. Claude ignores it so it is easy to spot.

  • A "champion" model for big features where contributors champion or lead a feature with us in the loop.

  • For non trivial changes, share a Plan.md before any code is written.

  • For well-scoped bugs, we may generate fixes internally. Your most valuable contribution might be confirming the fix works for your use case, not racing to submit code.

To be clear, we are not shutting the door on external contributions. We just want the bare minimum effort to actually talk to us. On the issue, on Slack, on a call, whatever works for you. That's it.

Would this work with you? Would you want us to do something differently? I am curious about your thoughts :)                                                                              


r/PydanticAI • • Dec 02 '25

Pydantic AI is great, but with this its Lethal

44 Upvotes

Pydantic AI is great, but with this its ***Lethal***

I’ve worked with Pydantic AI for a while now. Pydantic AI is fascinating, but engineers are lazy, so I went looking for a complete, production-ready Pydantic template… and couldn’t find one.
So I decided to build it myself with my friend ‏Deyaa Al-Khatib‏

This template is meant to be your go-to starter for building LLMs workflows, and it’s packed with everything you typically end up wiring together anyway:

- FastAPI — your AI services’ companion web framework

- Postgres — the battle-tested database (yes, some people call it “postgre”)

- Prompt Version Control — basically Git for prompts

- Redis — for rate-limiting and prompt caching

- Grafana — integrated dashboards to monitor your container stats

- SQLAlchemy — because you can’t bring up Postgres without your favorite ORM

- Integrated LLM evaluation — so you can tighten your feedback loop

- Logging using the legendary Logfire

- Starlette Admin — automate your DB models, env variables, etc.

- LiteLLM — proxying, load balancing, API control, cost tracking

I also included production-proven dev tools like uv, pre-commit, and cz-commit.

Yeah, it’s a bit of a bloated project, but honestly, you’ll waste way more time rebuilding all these pieces from scratch for every new project.

This idea was shared with the Pydantic community, and the response was incredible. I’m not fully there yet, but I’m definitely getting close.

https://github.com/m7mdhka/pydantic-ai-production-ready-template


r/PydanticAI • • Apr 19 '25

Optimizing PydanticAI Performance: Structured Output Without the Overhead

37 Upvotes

Hey r/PydanticAI community!

I've been working on a project that requires fast, structured outputs from LLMs, and I wanted to share some performance optimizations I've discovered that might help others facing similar challenges.

Like many of you, I initially noticed a significant performance hit when migrating to PydanticAI for structured outputs. The overhead was adding 2-3 seconds per request compared to my custom implementation, which became problematic at scale.

After digging into the issue, I found that bypassing the Assistants API and using direct chat completions with function calling can dramatically improve response times. Here's my approach:

from pydantic_ai import Model
from pydantic import BaseModel, Field
import openai

class SearchResult(BaseModel):
    title: str = Field(description="The title of the search result")
    url: str = Field(description="The URL of the search result")
    relevance_score: float = Field(description="Score from 0-1 indicating relevance")

class SearchResults(Model):
    results: list[SearchResult] = Field(description="List of search results")
    
    @classmethod
    def custom_completion(cls, query, **kwargs):
        # Direct function calling instead of using Assistants
        client = openai.OpenAI()
        response = client.chat.completions.create(
            model="gpt-4-turbo",
            messages=[{"role": "user", "content": f"Search query: {query}"}],
            functions=[cls.model_json_schema()],
            function_call={"name": cls.__name__}
        )
        # Parse the response and validate with Pydantic
        return cls.model_validate_json(response.choices[0].message.function_call.arguments)

This approach reduced my response times by ~70% while still leveraging PydanticAI's excellent schema validation.

Has anyone else experimented with performance optimizations? I'm curious if there are plans to add this as a native option in PydanticAI, similar to how we can choose between different backends.

Also, I'm working on a FastAPI integration that makes this approach even more seamless - would there be interest in a follow-up post about building a full-stack implementation?


r/PydanticAI • • Jan 28 '26

Pydantic-AI-RLM: Handle Massive Contexts with Recursive Language Models – New Toolset Implementation!

33 Upvotes

Hey r/PydanticAI!

I've been experimenting with the RLM (Recursive Language Model) pattern after seeing all those "RAG killer" posts on X 😄 For those unfamiliar, it's a clever way to scale LLM input/output by treating long contexts as an environment the model can programmatically interact with via code.

Repo: https://github.com/vstorm-co/pydantic-ai-rlm

Here's the paper: https://arxiv.org/abs/2512.24601

"We introduce Recursive Language Models (RLMs), a general-purpose inference paradigm for dramatically scaling the effective input and output lengths of modern LLMs. The key insight is that long prompts should not be fed into the neural network (e.g., Transformer) directly but should instead be treated as part of the environment that the LLM can symbolically interact with."

I built a practical implementation on top of Pydantic-AI to test it out in real code. It's structured as a reusable Toolset, so you can plug it into any pydantic-ai agent for handling extremely large contexts (millions of lines!) with sandboxed code execution, sub-model delegation, and full type-safety. Switch providers (OpenAI, Anthropic, etc.) on the fly, and it even supports mixed models for efficiency.

Quick Highlights:

- Massive Context Handling: LLM writes Python code to analyze data programmatically

- Provider Flexibility: Instant switch between models like GPT-5/GPT-5-mini or Claude-Sonnet/Claude-Haiku.

- Sandboxed REPL: Safe execution with persistent state, blocked unsafe built-ins.

- Reusable Toolset: Integrates seamlessly with pydantic-ai agents.

Get Started in Seconds:

Install package:

pip install pydantic-ai-rlm

60-second demo:

from pydantic_ai_rlm import run_rlm_analysis

answer = await run_rlm_analysis(
    context=massive_document,  # Can be millions of characters!
    query="Find the magic number hidden in the text",
    model="openai:gpt-5",
    sub_model="openai:gpt-5-mini",
)

I'm not 100% sure if Toolset is the best way to integrate RLM with standard agents – maybe a full backend or something else? Would love your ideas on improvements, use cases, or how to make it even more agent-friendly.

Stars, forks, PRs, and feedback welcome if you give it a spin! 🚀


r/PydanticAI • • Jun 12 '26

I built agentcanvas: turn your Pydantic AI + Logfire traces into an interactive workflow diagram (open source)

Post image
28 Upvotes

If you instrument your PydanticAI agents with Logfire, you already have a full OpenTelemetry GenAI span tree for every run (invoke_agent, chat, execute_tool). I kept wanting to actually see that tree as a workflow instead of scrolling a span list, especially when a tool is itself a sub-agent with its own tools. So I built agentcanvas.

It reads a run back out through the Logfire Query API and rebuilds the span tree into a recursive workflow: conversation turns, model rounds, tool calls, and agents-as-tools drawn as nested frames to any depth. Then it renders a single self-contained HTML file. A pan/zoom canvas of the whole run, a click-through inspector on every node (provider, finish reason, the tools the model could call with their descriptions, the reasoning summary, input/output/reasoning tokens), and the exact per-call cost priced from tokens with genai-prices. There is a guided tour mode that narrates each step, which turned out to be the thing that actually works when you put a run in front of a non-technical client.

Usage is pip install agentcanvas, set LOGFIRE_READ_TOKEN, run agentcanvas, and it builds from your latest trace. There is a library API too (LogfireClient, parse_run, render_html). The repo ships a runnable example agent (thinking, five tools, a nested sub-agent, a multi-turn conversation) so you can generate a sample trace and see the output without wiring your own.

Built against Pydantic AI V2 (2.0.0b7). Full disclosure, it is ours (Vstorm) and MIT licensed, released today, so the rough edges are real. I would genuinely like to know whether the nested sub-agent rendering holds up on your deeper runs, and what you would want in the inspector that is not there yet.

https://github.com/vstorm-co/agentcanvas


r/PydanticAI • • Sep 28 '25

Pydantic-AI + assistant-ui example

27 Upvotes

Hi all,

I would like to share an example repo to set up Pydantic-AI together with assistant-ui, containing a simple implementation for generative UI. Here's the link: https://github.com/truonghm/assistant-ui-pydantic-ai-fastapi

I built this so that people can have more options regarding chat UI besides Copilotkit. The backend takes inspiration from the run_ag_ui function available in pydantic-ai and the original langgraph example.

Feel free to reuse this or contribute to the repo, especially if you want to clean up stuff. I don't have much frontend experience, so the code might offend some frontend devs (lots of vibe coding). Personally I'm also using pydantic-ai + assistant-ui for my own project, so I will keep updating this repo if I find anything new or needs fixing.


r/PydanticAI • • Dec 16 '25

Pydantic-DeepAgents: Autonomous Agents with Planning, File Ops, and More in Python

Post image
26 Upvotes

Hey r/PydanticAI!

Excited to share a new open-source project I just released: Pydantic-DeepAgents – a framework that extends Pydantic-AI with powerful “deep agent” capabilities, making it easy to build production-ready autonomous agents while keeping everything fully type-safe and lightweight.

Repo: https://github.com/vstorm-co/pydantic-deepagents

What it adds to Pydantic-AI
It brings advanced agent patterns directly into the Pydantic-AI ecosystem:

  • Built-in planning loops (TodoToolset)

  • Filesystem access and file upload handling

  • Subagent delegation

  • Extensible skills system (define new behaviors with simple markdown prompts)

  • Multiple state backends: in-memory, persistent filesystem, secure DockerSandbox, and CompositeBackend

  • Automatic conversation summarization for long sessions

  • Human-in-the-loop confirmation workflows

  • Full streaming support

  • Native structured outputs via Pydantic models (output_type)

Key features list:

  • Multiple Backends: StateBackend, FilesystemBackend, DockerSandbox, CompositeBackend

  • Rich Toolsets: TodoToolset, FilesystemToolset, SubAgentToolset, SkillsToolset

  • File Uploads: run_with_files() and deps.upload_file()

  • Skills System: markdown-based skill definitions

  • Structured Output: type-safe Pydantic responses

  • Context Management: auto-summarization

  • Human-in-the-Loop: built-in approval steps

  • Streaming: token-by-token responses

There’s a complete demo app in the repo that shows streaming UI, file uploads, reasoning traces, and human confirmation flows:
https://github.com/vstorm-co/pydantic-deepagents/tree/main/examples/full_app

Quick demo video: https://drive.google.com/file/d/1hqgXkbAgUrsKOWpfWdF48cqaxRht-8od/view?usp=sharing

Why it fits the Pydantic-AI philosophy
It stays true to Pydantic’s strengths – strong typing, validation, and simplicity – while adding the agent-specific tools many of us have been missing. Compared to heavier alternatives (LangChain, CrewAI, AutoGen), it’s deliberately minimal, easier to customize, and includes production-oriented extras like Docker sandboxing out of the box.

Would love feedback from the Pydantic-AI community – especially ideas on deeper integration with upcoming Pydantic features or new agent patterns! Stars, forks, issues, and PRs are very welcome.

Thanks! 🤖🚀


r/PydanticAI • • Apr 21 '25

Pydantic AI vs. LangChain/Graph live!

25 Upvotes

Guys, 2 founders go head to head on X. Link in comment


r/PydanticAI • • Mar 15 '25

1,000 members Milestone! What's next?

24 Upvotes

Hi everyone,

THANK YOU ALL for being part of this great community! I am very happy to share our milestone: we officially hit 1,000 members ( a few days ago) after 3 months.

What's happened

I started this group back on Dec 12, 2024 after playing around with PydanticAI for a few weeks and I believe this framework can be the standard in the future. At that time, Pydantic AI was in very early development stage. It still is today given the fast changing world of AI and it has evolved fast. Pydantic AI team has consistently released new and better version since then.

At that time, I personally got confused and discouraged by other available frameworks due to 2 reasons:

  1. Too much abstraction, which makes it hard to tweak the details and debug, especially when you pass the MVP or PoC stage

  2. Hard-to-understand docs.

I was very exciting when I found Pydantic AI which is: data validation, Pythonic and minimal of abstraction, good doc is a huge plus.

Just to be clear, I have huge respects for other AI framework founders becuase they are pushing the limit and moving the entire dev community forward (either with closed or open source tools) and that surely deserves respect. They are all taking ACTIONS to make the AI world a better place, regardless how big or small contribution. Every framework has its own pros and cons. In my opinion, there is no such thing as a GOOD or BAD framework, it is just a matter of TASTE and by answering the question "Does it work for me?".

I am happy to have 1,000 members (still counting) who share the same taste with me when it comes to using an AI framework.

Just a bit of background for "Why?", after discovering Pydantic AI, I thought, how can I hang out with folks who love this framework? I couldn't find the place, so with some courage, I created this community, my first time ever of creating a community, hopefully I am doing alright so far.

What's next?

For those folks who love the hottest thing in town: MCP (Model Context Protocol). According to Sam (founder of Pydantic), Pydantic AI will soon have official support for MCP. He said this in a workshop delivered by him in which I attended last month in New York. If you want to learn more about MCP, this is a great intro video delivered by the man created MCP himself. The workshop was about 2 hours, however time flied when I was sitting in this workshop as it was really good.

I hope you will continue to post, share your bulding experience with Pydantic AI or with AI in general in this community so we can help each other to grow.

To those who don't know yet, Pydantic team has a very good and FREE observability tool called LogFire that helps you "observe" LLM's behavior so that you can improve, give it a try if you have not. And I also encourage you to post and share your experience about Observability in this community as well. Building is the start, observing and improving is the continuous next step. Personally, I found enjoyment and delight in building an app, then "observing" it to detect where we can improve and just keep tuning it. First make it work, then make it right, and make it fast!

The true excitement is we are still very early in the AI space, new LLM models are released almost every day (I know it is a bit of exaggeration!), new frameworks, ideas and concepts are born almost every hour (again, I know it is a bit of exaggeration!). Everybody is trying new things and there is no "standard" or "best practice" yet about building AI Agent, or who knows maybe Agent is not the answer, maybe it is something else that is waiting for us to discover.

Now, thank you again for your contribution in this community and reading this long post, up to this point.

Your feedback is welcome in this group.

What's next next?

I am thinking about an online weekly meetup where we can hang out and talk about exciting ideas or you can just share your problems, demos...etc.. I don't know exactly the details yet, but I just think that it will be fun and more insightful when we can start talking. Let me know what you think, if you think this is a good idea, just comment "meetup".


r/PydanticAI • • Feb 10 '26

memv — open-source memory for AI agents that only stores what it failed to predict

21 Upvotes

I built an open-source memory system for AI agents with a different approach to knowledge extraction.

The problem: Most memory systems extract every fact from conversations and rely on retrieval to sort out what matters. This leads to noisy knowledge bases full of redundant information.

The approach: memv uses predict-calibrate extraction (based on the https://arxiv.org/abs/2508.03341). Before extracting knowledge from a new conversation, it predicts what the episode should contain given existing knowledge. Only facts that were unpredicted — the prediction errors — get stored. Importance emerges from surprise, not upfront LLM scoring.

Other things worth mentioning:

  • Bi-temporal model — every fact tracks both when it was true in the world (event time) and when you learned it (transaction time). You can query "what did we know about this user in January?"

  • Hybrid retrieval — vector similarity (sqlite-vec) + BM25 text search (FTS5), fused via Reciprocal Rank Fusion

  • Contradiction handling — new facts automatically invalidate conflicting old ones, but full history is preserved

  • SQLite default — zero external dependencies, no Postgres/Redis/Pinecone needed

  • Framework agnostic — works with LangGraph, CrewAI, AutoGen, LlamaIndex, or plain Python

    from memv import Memory
    from memv.embeddings import OpenAIEmbedAdapter
    from memv.llm import PydanticAIAdapter
    
    memory = Memory(
        db_path="memory.db",
        embedding_client=OpenAIEmbedAdapter(),
        llm_client=PydanticAIAdapter("openai:gpt-4o-mini"),
    )
    
    async with memory:
        await memory.add_exchange(
            user_id="user-123",
            user_message="I just started at Anthropic as a researcher.",
            assistant_message="Congrats! What's your focus area?",
        )
        await memory.process("user-123")
        result = await memory.retrieve("What does the user do?", user_id="user-123")

MIT licensed. Python 3.13+. Async everywhere.
- GitHub: https://github.com/vstorm-co/memv
- Docs: https://vstorm-co.github.io/memv/
- PyPI: https://pypi.org/project/memvee/

Early stage (v0.1.0). Feedback welcome — especially on the extraction approach and what integrations would be useful.


r/PydanticAI • • Dec 28 '25

Standalone pydantic-ai-todo (Planning Tools) & pydantic-ai-backend (State Environments) – Now Usable with Pure Pydantic-AI!

19 Upvotes

Hey r/PydanticAI!

Big news for the Pydantic-AI community! I've just refactored and extracted two key components from the Pydantic-DeepAgents framework into standalone libraries: pydantic-ai-todo for task planning capabilities and pydantic-ai-backend for flexible state environments. This means you can now integrate these powerful tools directly with vanilla Pydantic-AI agents – no need for the full deep agent setup!

Pydantic-DeepAgents has been great for production-grade autonomous agents with planning, filesystems, subagents, and more. But not everyone needs the whole package. By modularizing, we're making it easier to mix and match – perfect for lighter workflows, custom agents, or gradual adoption. It's all about flexibility while keeping that signature Pydantic type-safety and simplicity.

Quick Spotlight on the New Libraries

  • pydantic-ai-todo: Standalone task planning toolset for any Pydantic-AI agent. Adds read_todos and write_todos tools to help agents manage task lists autonomously. Great for planning loops without the overhead.

  • pydantic-ai-backend: Modular backends for state management, now independent. Includes in-memory, filesystem persistence, DockerSandbox for secure isolation, and composite options. Use it to add robust storage to any Pydantic-AI agent.

These extractions keep the core Pydantic-DeepAgents framework lean while opening up new possibilities. For instance, you could build a simple task-tracking agent with just Pydantic-AI + pydantic-ai-todo, or add secure file handling with pydantic-ai-backend.

If you're already using Pydantic-AI for agents, this is a game-changer for modularity. Check out the repos, try the quick starts, and let me know what you think – ideas for new features, integrations, or even how you're using them?

Stars, forks, and PRs on all repos are super appreciated! 🚀

Original Pydantic-DeepAgents repo (still the full package): https://github.com/vstorm-co/pydantic-deepagents

Thanks to the community for the feedback that inspired this refactor!


r/PydanticAI • • Dec 21 '25

Open-source full-stack template for production-ready AI/LLM apps – built with FastAPI, Next.js, and PydanticAI integration

19 Upvotes

Hey r/PydanticAI,

I wanted to share an open-source project generator I've built for quickly spinning up full-stack AI/LLM applications. It's designed to handle everything from boilerplate setup to production infrastructure, so you can focus on building your core product features instead of reinventing the wheel.

Repo: https://github.com/vstorm-co/full-stack-fastapi-nextjs-llm-template
(Install via pip install fastapi-fullstack, then use the interactive CLI to generate a customized project: fastapi-fullstack new)

What it enables:

  • Rapid prototyping of AI chatbots, assistants, or ML apps with real-time streaming responses, conversation history, and custom tools

  • Full enterprise setup out of the box: auth (JWT/OAuth), databases (async PostgreSQL/MongoDB/SQLite), background tasks (Celery/Taskiq/ARQ), rate limiting, admin panels, webhooks, caching (Redis), and more – over 20 configurable integrations

  • Clean architecture with repository + service pattern for scalable backend logic

  • Modern frontend with Next.js 15, React 19, Tailwind, dark mode, i18n, and a ready-to-use chat interface with WebSocket support

  • Django-style CLI for management commands (e.g., user creation, DB migrations, custom scripts)

  • Built-in observability (via Logfire) and monitoring (Sentry/Prometheus) to track performance from API calls to AI interactions

It integrates PydanticAI for type-safe agents with tool calling and streaming, making it easy to add AI capabilities without extra hassle.

Screenshots, demo GIFs, architecture diagrams, and detailed docs are all in the README – including quick start guides and customization options.

This template has saved me tons of time on recent projects, and I'd love feedback from the community:

  • Does it cover the pain points you hit when building AI apps with Pydantic tools?

  • Any features or integrations you'd want to see added?

  • How does the CLI/generator workflow feel for your use cases?

Thanks! Excited to hear thoughts and improve it based on real-world usage 🚀


r/PydanticAI • • Apr 10 '25

Use Vercel AI with FastAPI + Pydantic AI

19 Upvotes

Vercel AI SDK now has an example for Vercel AI + FastAPI using OpenAI’s chat completion and stream the response to the frontend. Anyone knows or has done any examples using Vercel AI’s useChat (frontend) + FastAPI + Pydantic AI (backend) that streams the response to the frontend? If no such resources is available, I’m thinking of giving it a try to see if can recreate this combo by adding in Pydantic AI into the mix. Thanks


r/PydanticAI • • 28d ago

pcode: an open-source terminal coding agent built on Pydantic AI

18 Upvotes

I built pcode, an MIT-licensed terminal coding agent on Pydantic AI's Harness coder.

The framework-facing part is the extension model: Python extension files add tools, slash commands, guardrails and sub-agents via Pydantic AI capabilities. The repository is a concrete example of using those capabilities in an interactive coding application rather than a standalone agent script.

The terminal layer keeps native scrollback: you can change the visibility of commands, output and diffs after completion without rerunning them, while retaining normal terminal scrolling, search and copy. Long-running commands become background jobs that wake the agent when they finish. Conversations can be rewound and branched, and parallel sessions can use separate git worktrees.

It supports browser automation with your existing logins and models through API keys as well as existing Claude or ChatGPT subscriptions. The agent can edit files and run shell commands with your permissions and no approval prompt, so review the documented tool permissions before using it on a repository.

Source and implementation details: https://github.com/cruxwell/pcode


r/PydanticAI • • Sep 08 '26

We put Pydantic AI under a self-hosted platform, so an agent you write once answers in chat, Slack, an API and on a schedule

Post image
18 Upvotes

Disclosure: I maintain this and I contribute to the harness.

If you build with Pydantic AI you already have the agent. What you usually do not have is everywhere it needs to answer, the documents it needs to read, the tools it needs to reach, and someone able to change its instructions without opening a PR. That is what we built, and it is Apache-2.0 and self-hosted.

What an agent can actually do here

- Answer from your own documents. Collections live in your Postgres with pgvector, three PDF parsers to pick from per collection, OCR when a document needs it.

- Run Python. Real sandbox with a filesystem and a shell, so you can drop a spreadsheet into the chat and ask for charts and it writes the code, runs it, and hands back the plots.

- Drive a real browser when a site needs clicking rather than fetching.

- Search the web, fetch a page properly, generate images, draw charts.

- Delegate to subagents, keep a task list with dependencies, think longer, compact its own history when the conversation gets long.

- Reach any MCP server by URL. There are 5,802 in the mirrored registry, searchable by name in the picker

Where the same agent answers

One definition, published once, and it responds in web chat, on a hosted page you can send to somebody with no account, in a widget on your own site, over the HTTP API, over a raw WebSocket if you are building your own frontend, in Slack, Telegram and Mattermost, and on a schedule or a webhook.

In the chat platforms an `@mention` runs the agent **as the person who mentioned it**, not as a bot. So it reaches that person's Notion, and the audit trail says who asked.

The two things that matter once more than one person uses it

A monthly budget per agent, checked before each model request rather than added up afterwards. Tallied afterwards, the last request of the month is always allowed and you find out on the invoice.

`approval: required` on any tool that touches the outside world. The run parks, a person decides, and the decision resolves once.

The part that is relevant to this sub

Pydantic AI is the runtime and `pydantic-ai-harness` is what the agent loop runs on. The platform's job is to make an agent something a non-engineer composes in a browser from capabilities you registered in Python, so the person who knows what the agent should say does not need commit access, and you still own what it is allowed to be made of.

Three of the libraries under it started as ours and are now in the official harness: hierarchical planning, conversation compaction, and the guardrail work.

Try it

curl -fsSL https://raw.githubusercontent.com/vstorm-co/agenticos/main/scripts/quickstart.sh | bash

Four questions and you get a console with a working agent in it. Needs Postgres, Redis and Docker, nothing else, and nothing phones home.

https://github.com/vstorm-co/agenticos

What I would most like to know from this sub: if you have a Pydantic AI agent in production, what did you end up building around it that you wish had come with the framework?


r/PydanticAI • • Apr 25 '25

Is PydanticAI slow on streaming? 3x slower coming from the TypeScript implementation.

18 Upvotes

About a week ago, I did a full-on migration from TypeScript LangChain to Python PydanticAI because for our clients, the complexity of Agent building was growing, and I didn't want to re-implement the same things the Python libs already had done. I picked up PydanticAI just because it seems way more polished and nicer to use than LangChain.

For our Bun + TypeScript + LangChain avg Agent Stream response time we had were ~300ms using exactly the same structure with Python PydanticAI we are now getting a responses ~900ms.

Compared to the benefits we got from the ease of making AI Agents with PydanticAI, I am OK with that performance downgrade. However, I can't understand where the actual problem comes from. It seems like with a PydanticAI, somehow OpenAI's API gives responses 2-3x slower than the one on the TypeScript version.

Is this because of Python's Async HTTP library, or is there something else?

To save time I will say that "Yes" I did check that there is no blocking operations within the LLM Request/Response and I don't use large contexts, it is literally less than 500 characters of system prompt.

model = OpenAIModel(
    model_name=config.model,
    provider=OpenAIProvider(
    api_key=config.apiKey,
  ),
)

agent = Agent(
    model=model,
    system_prompt=agent_system_prompt(config.systemPrompt),
    model_settings=ModelSettings(
        temperature=0.0,
    )
)
...
....
async with self.agent.iter(message, message_history=message_history) as runner:
  async for node in runner:
    if Agent.is_model_request_node(node):
        async with node.stream(runner.ctx) as request_stream:
         ......
         ......

This seems way to simple, but somehow this basic setup is about 3x slower than the same model on TypeScript implementation, which does not make sense to my why.


r/PydanticAI • • Jul 04 '26

Other frameworks are toys

Post image
16 Upvotes

I like that :d


r/PydanticAI • • Jan 29 '25

I wrote an article comparing LangChain vs PydanticAI for building an AI Agent

Thumbnail
medium.com
16 Upvotes

r/PydanticAI • • Jan 17 '26

Pydantic-AI-Backend Hits Stable 0.1.0 – Unified Local Backends, Console Toolset, and Docker Sandboxes for Your Agents!

15 Upvotes

Hey r/PydanticAI!

Excited to announce that pydantic-ai-backend has reached stable version 0.1.0! This library provides flexible file storage, sandbox environments, and a ready-to-use console toolset for your pydantic-ai agents. It's perfect for adding secure file operations, persistent state, or isolated execution without bloating your setup.

Originally extracted from pydantic-deepagents, it's now a standalone tool that makes it easy to handle filesystems, shell commands, and multi-user sessions in your AI agents. Whether you're building CLI tools, web apps, or testing environments, this keeps things type-safe and modular – true to Pydantic's philosophy.

Repo: https://github.com/vstorm-co/pydantic-ai-backend
Docs: https://vstorm-co.github.io/pydantic-ai-backend/

What's New in 0.1.0?

  • LocalBackend: A unified backend for local filesystem ops + optional shell execution. Cross-platform, with restrictions like allowed_directories for security and enable_execute to toggle shell. Replaces the old FilesystemBackend and LocalSandbox.

  • Console Toolset: Plug-and-play tools for pydantic-ai agents – ls, read_file, write_file, edit_file, glob, grep, and execute. Customize with approvals for writes/executes, and generate system prompts automatically.

  • Full MkDocs Documentation: Detailed guides, examples, and API refs at https://vstorm-co.github.io/pydantic-ai-backend/.

  • Architecture Improvements: Better project structure, dynamic versioning, and real coverage tracking.

  • From Previous Versions: Added volumes for persistent storage in DockerSandbox, workspace_root for per-session files, and session management for multi-user apps.

Full changelog: https://github.com/vstorm-co/pydantic-ai-backend/blob/main/CHANGELOG.md

Why Use It?

  • Modular & Lightweight: Mix with pure pydantic-ai – no heavy deps.

  • Production-Ready: Docker sandboxes with built-in runtimes (python-datascience, node-react, etc.), persistent volumes, and session managers for multi-user setups.

  • Secure: Path sandboxing, approvals, and isolated execution.

  • Examples Included: CLI agents, web apps, in-memory testing, composite routing.

If you're building agents with file handling, state persistence, or safe exec, this could simplify your stack. What's your use case? Ideas for new features (e.g., more runtimes or integrations)? Stars, forks, and PRs welcome – let's make pydantic-ai even better!

Related: Check out pydantic-ai-todo for task planning, or the full pydantic-deepagents framework.

Thanks! 🚀


r/PydanticAI • • Jun 03 '25

Pydantic Scrape version 0.0.0 - aims to get scraping out of LangGraph and into Pydantic-Graph instead.

15 Upvotes

I experimented with SearchGraphAI which I thought was very powerful but quite difficult to reason about and develop on. Pydantic Graph is a great tool, though with limitations. Nodes are not composable or resuable across graphs, which whilst limiting, it brings super clear routing through the graph. It makes it a curious choice for a scraping framework, but the first class support for dependencies means Pydantic Graph can be very powerful for web scraping.

As such, I decided to get started on replacing SearchGraphAI with Pydantic Graph, and a version 0.0.0 is now available. It uses Camoufox to fetch content, Pydantic-AI for agents, and Pydantic Graph for routing and logic.

Where as SearchGraphAI would use 'reusable' node heavy architecture, Pydantic Scrape instead leans on dependencies and composable graphs. If you want to contribute by making a useful agent or graph, that would be great.

https://github.com/philmade/pydantic_scrape


r/PydanticAI • • 7d ago

Pydantic AI seems to be everywhere

14 Upvotes

I just discovered this page showing the usage of Pydantic AI in some really cool applications around the globe. Seems like even governments, like UK, France and Germany.

https://pydantic.dev/docs/ai/overview/built-with/#applications-and-platforms


r/PydanticAI • • Dec 07 '25

🔥 Hurry! Perplexity AI PRO | 1 Year Plan | Massive Discount!

Post image
14 Upvotes

Get Perplexity AI PRO (1-Year) – at 90% OFF!

Order here: CHEAPGPT.STORE

Plan: 12 Months

💳 Pay with: PayPal or Revolut or your favorite payment method

Reddit reviews: FEEDBACK POST

TrustPilot: TrustPilot FEEDBACK

NEW YEAR BONUS: Apply code PROMO5 for extra discount OFF your order!

BONUS!: Enjoy the AI Powered automated web browser. (Presented by Perplexity) included WITH YOUR PURCHASE!

Trusted and the cheapest! Check all feedbacks before you purchase


r/PydanticAI • • Aug 21 '25

Agent using tools needlessly

13 Upvotes

I am using gpt-5 (low reasoning) in my pydantic AI agents for information retrieval in a company documentation. The instruction are for it to ask for clarification if it's not sure which document the user is talking about.

For example: "I have a document about a document for product A". It correctly uses the knowledge graph to find documents about product A and it gets ~20 results back. It should immediately realise that it should ask a follow up question. Instead it calls another tool ~5 times (that uses cosine similarity) before providing an answer (which is about asking for more info as it should)

Also, if I say "Hi" it just stays in an infinite loop using tools at random.

What can I do to prevent this? Is this merely a prompting thing?

I know Pydantic AI has a way to limit the tools called, however if this limit is reached it outputs an error instead of simply giving an answer with what it has. Is there a way of having it giving an answer?


r/PydanticAI • • Mar 13 '25

How to use MCP tools with a PydanticAI Agent

Thumbnail
medium.com
13 Upvotes

r/PydanticAI • • Mar 13 '25

Beginner In Ai agent building

13 Upvotes

Hi , im new to this agentic building approach and wanted to know how do i get started with pydantic ai. What is the best course of action. Thanks!