Skip to content

Framework Update: Pydantic AI v2.70.0

Nov 19, 20265 min
TL;DRThe headline in Pydantic AI v2.70.0 is two high-severity security advisories: both the ANSI-stripping logic in ToolOutputLimits and the jwt pattern in secret redaction have ReDoS bugs that let an attacker stall the event loop for tens of seconds to minutes through tool output content. Upgrade pydantic-ai-harness to 0.70.0 right away.

Look up & save

Loading dictionary…

中文版

Release Info

ItemValue
FrameworkPydantic AI
Versionv2.70.0
Previous versionv2.69.0
Release date2026-11-17
Release Notesv2.70.0
GitHubpydantic/pydantic-ai
Stars21.3k

Why this release matters

The headline here isn't a feature — it's two advisories the project itself labeled high severity. Both the "strip ANSI escape sequences" and the "find JWTs to redact" logic in pydantic-ai-harness use patterns whose runtime is quadratic in the length of the input. Whenever an attacker can influence what a tool returns — a shell command, a file read, a fetched page, an MCP server — a few hundred kilobytes of crafted text is enough to stall the event loop for tens of seconds to minutes, and every other request and agent run sharing that process stalls with it. For any team that wires an agent up to a tool whose output an attacker can influence, this isn't an optional upgrade — it's an incident waiting to happen. On the feature side, the release continues last version's direction: giving agents inside the harness more ways to manage each other's output and failures.

Key changes

  • ReDoS in ToolOutputLimits' ANSI stripping (GHSA-m4cr-m4qc-9hh3, high): when strip_ansi=True, the pattern used to strip ANSI escape sequences runs in quadratic time → a few hundred kilobytes of tool output packed with unterminated escape sequences can stall the event loop for tens of seconds to minutes, affecting any app that sets strip_ansi to True (formerly named OverflowingToolOutput) on tool output an attacker can influence
  • ReDoS in secret redaction's jwt pattern (GHSA-5m5q-5qj4-gx9h, high): the jwt pattern enabled by default in redact_secrets / secret_data() backtracks in quadratic time → because this guard runs synchronously on the event loop, a few hundred kilobytes of crafted text (a user prompt or tool-returned content) is enough to stall the whole process
  • ToolSearch: a new tool selector that defers loading tool definitions until they're actually needed (pre-search deferral) → you don't have to stuff every tool's schema into context up front when there are many tools
  • PruneToolResults: lets the model replace a tool result it just received with its own summary → old tool output in a long conversation doesn't have to keep occupying context
  • StreamGuardrail: screens streamed text, thinking, and tool-call parts before the caller sees them → a guardrail doesn't have to wait for the whole response to finish before it can step in
  • SubAgent(on_model_error=): lets a sub-agent choose to retry or return separately when it hits a model error, independent of on_failure → a sub-agent's error handling no longer has to be tied to the overall failure logic

The diagram below shows the attack chain: a string hidden in tool output triggers the quadratic-time scan, and other agent runs' requests get stalled along with it.

The ReDoS attack chain in pydantic-ai-harness
The ReDoS attack chain in pydantic-ai-harnessAn attacker plants a crafted string in tool output; the harness scans it with a quadratic-time regex and stalls the event loop, dragging down other agent runs' requests along with it. crafted input tool output quadratic scan new request times out delayed response Attacker Tool Harness Other agent
  1. The attacker sends input with an unterminated escape sequence or a JWT-like string to a tool
  2. The tool passes this content straight back to the harness
  3. The harness scans it with a quadratic-time regex; the event loop stalls
  4. Another agent run sends a new request at the same time
  5. That request times out without a response
  6. The original tool caller finally gets a response, tens of seconds later

Simplified illustration; the actual stall duration depends on input size and server load

Breaking Changes

There are no renames or signature changes this release, but a few compatibility notes make existing behavior stricter:

  • OpenAIChatModel now raises ModelRequestRejectedError outright if tool definitions are still sent while reasoning is on for GPT-6 models, instead of silently sending them and letting the model decide
    • Affected: code that still passes tools when calling GPT-6 reasoning models
  • GroqModel now raises UserError when NativeOutput is used together with function tools
    • Affected: code that mixes NativeOutput and function tools on Groq
  • OpenRouter's qwen/qwen3.8-flash now falls back to 'auto' or raises ModelRequestRejectedError when tool_choice is forced while reasoning is on (the model itself rejects forced tool choice while reasoning)
    • Affected: code that forces tool_choice for that model

Migration Guide

Upgrading from 2.69.x to 2.70.0

pip install --upgrade pydantic-ai==2.70.0 pydantic-ai-harness==0.70.0

Both advisories keep default behavior unchanged, but upgrading right away is strongly recommended:

# 1. If you set strip_ansi=True (formerly OverflowingToolOutput)
# Temporary mitigation before upgrading: leave it at the default, False
ToolOutputLimits(strip_ansi=False)

# 2. If you use redact_secrets() or secret_data() and rely on the default jwt pattern
# Temporary mitigation before upgrading: name the patterns you need explicitly, excluding jwt
secret_data(only=["aws_key", "api_key"])  # jwt not included

Both mitigations are only for before you upgrade. The real fix is upgrading pydantic-ai-harness to 0.70.0 or later. One more thing to note: the harness on Pydantic AI v1 is stuck at 0.4.0 and can't be upgraded further — you need to move to Pydantic AI v2 first to get this fix.

Compared to other frameworks

The same week, CrewAI 1.15.42 bumped its soupsieve dependency to fix CVE-2026-126190, while Pydantic AI's bug this release is in its own harness code. Put together, these point to a trend: agent framework security advisories are no longer just "a dependency has a hole" pass-through problems — more and more are bugs in the framework's own code for handling inherently untrusted input, like LLM and tool output. That echoes the observation in Agno v3.2.1 and last release's Pydantic AI v2.69.0 article: competition between frameworks has extended into the execution environment layer, and how secure that layer is has started to become one of the things worth watching.

Today's takeaway

I used to think of ReDoS as just a performance bug from a poorly written regex, one that at worst slows down a single request. Seeing the project issue two separate high-severity GHSA advisories for two string-processing functions — stripping ANSI, finding JWTs — made it clear: the content an agent harness processes is content an attacker can influence, and string-cleanup logic that looks harmless is itself part of the attack surface. And because it runs on the event loop, one trigger doesn't stall one request — it stalls every agent run sharing that process.

References