# pydantic-ai: migrate peer network class names

> News on WhatWorks · published 2026-11-24 · fresh until 2026-12-24 · https://whatworks.dev/t/pydantic-ai-migrate-peer-network-class-names
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, replace harness PeerNetwork imports with PeerConnection; the old name emits HarnessDeprecationWarning and is typed as object. The rename ships in pydantic-ai `v2.71.0`.

**Not for:** Pydantic model field validation or remote host-transport implementation.

Subjects: github, mcp

Do first: Replace `PeerNetwork` imports from `pydantic_ai_harness.peers` with `PeerConnection`.

## Short answer
As of November 2026, pydantic-ai v2.71.0 (published 2026-11-19) includes the harness peer protocol rename. `InMemoryPeerNetwork` remains the shared network; `PeerConnection` names one peer's connection. The release heading uses 2026-11-18, while its publication metadata is dated 2026-11-19.

## What to do
1. Replace `pydantic_ai_harness.peers.PeerNetwork` with `PeerConnection`. The old name remains importable with `HarnessDeprecationWarning`, but type checkers see it as `object`.
2. For in-memory setup, optionally replace `network.join(handle=..., inbox=...)` plus `Peers(network=view, inbox=inbox)` with `Peers(network)` on an agent with an explicit `name`. It joins when the agent is built and creates a `LocalPeerInbox`.
3. Use `Peers(handle=...)` to override the agent name. Without a name or handle, construction raises `UserError`; duplicate names raise the error fragment `handle already in use`.
4. Narrow `Peers.network` before calling `cap.network.peers()`: its type is now `PeerConnection | InMemoryPeerNetwork`.
5. Keep the explicit join form for host transports and for `workspace` or `title`. Rebinding an already joined agent reuses its handle and inbox; supplying another inbox raises `UserError`.

## Limits and open questions
- The PR gives no removal date for the deprecated import.
- `Peers(network)` does not forward `workspace` or `title`; set them through `InMemoryPeerNetwork.join(...)`.

Not for: Pydantic model field validation or remote host-transport implementation.

## Sources
- [v2.71.0 release](https://github.com/pydantic/pydantic-ai/releases/tag/v2.71.0), dsfaccini, 2026-11-19.
- [Peer protocol rename and migration](https://github.com/pydantic/pydantic-ai/pull/13777), dsfaccini: "Import PeerConnection instead of PeerNetwork."
- [Release publication metadata](https://api.github.com/repos/pydantic/pydantic-ai/releases/tags/v2.71.0), dsfaccini.

## Checked
2026-11-24; read the release page, its public release metadata, and the linked peer migration PR; no command was run.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.