published fresh until

Pydantic AI 2.63: stop duplicate chat history

Summary An app that stores its chat history should pass adapter-produced messages back with manage_message_history="server"; client ownership remains the default in Pydantic AI 2.63.0. Use manage_message_history="server"

Not for Pydantic AI 1→2 agent/provider migration (see pydantic-ai-1-to-2-provider-agent-graph-migration), or repairing missing tool results.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Set manage_message_history='server' when your Pydantic UI endpoint already loads the conversation from server storage.

What changed

The 2.63.0 release adds history ownership to UI adapters. PyPI lists the package uploaded October 28, 2026, MIT, Python >=3.11; checked 2026-10-28.

Do first: python -m pip show pydantic-ai

1. Check your installed package with python -m pip show pydantic-ai. This recipe targets 2.63.0. 2. Trace where your endpoint loads old messages. If it already restores the full conversation, select server ownership. 3. Save result.all_messages() from the adapter's completion callback. Pass that saved history into the next adapter request. The existing request, agent, stored_history and save_history below are your endpoint's objects:

from pydantic_ai.ui.vercel_ai import VercelAIAdapter

response = await VercelAIAdapter.dispatch_request(
    request,
    agent=agent,
    message_history=stored_history,
    manage_message_history='server',
    on_complete=save_history,
)

4. Try a three-turn chat, then edit and regenerate a turn. Inspect the model input and require one copy of each intended prior turn. In an AI SDK client, exercise regenerate() and sendMessage({ messageId }) for the regeneration and edit checks. Check a cancelled run separately. To retain a cancelled run, save RunCancelled.all_messages() in on_cancel; a client disconnect invokes neither callback. Keep conversation lookup tied to the authenticated user. If an errored or stopped turn was never stored, resend its user message as a new turn with sendMessage instead of regenerating it.

The official UI guide supplies the full persistence example and cautions about histories ending with an unanswered request after cancellation. The code above is an integration fragment, not a complete server.

Pick the ownership setting

SettingWhat it is for; when it winsWhen it loses; limit checked 2026-10-28Pick this if
serverYour stored conversation is authoritativeEdit/regenerate matching needs UI message IDs retained in adapter-produced historyYou already persist complete adapter results
clientThe browser supplies history; optional server context is prependedAlso passing the same full conversation duplicates turns; this is the defaultYour server adds only distinct context

These behaviors are documented in the UI adapter reference. No savings amount is promised: compare actual request contents and provider usage before and after.

Recommendation by constraint

For a solo prototype without persistence, keep client ownership. For a small team adding persistence, choose server ownership and test edits before rollout. For an enterprise endpoint, choose server ownership and include ownership checks and cancelled-turn recovery in the acceptance review. These are implementation recommendations, not separate product tiers.

Evidence

PR #11431, DouweM, October 26, 2026, describes the prior behavior: “sends every earlier turn to the model twice.” It merged October 27. This is maintainer implementation evidence. The PR reports production AG-UI testing by rscholz98 that exposed a tool-result edge case.

Prompt for your agent

Locate the UI adapter endpoint and identify who owns history. Preserve adapter message IDs, enable server ownership only if the complete history is stored, and demonstrate send, edit, regenerate and cancellation without duplicated turns.

Mistakes

Do not combine complete client and server histories under client ownership. Do not rebuild saved messages in a way that drops UI IDs and then expect regeneration matching to work.

Limits

No application was run. The history setting does not replace endpoint authorization. This is a feature setup recipe for 2.63.0, not a complete migration guide from an earlier major; review the official upgrade guide separately before changing a production dependency.

Started from a post by @DouweM, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Pydantic AI 2.63: stop duplicate chat history
Summary: An app that stores its chat history should pass adapter-produced messages back with manage_message_history="server"; client ownership remains the default in Pydantic AI 2.63.0. Use manage_message_history="server"
Copy for agent
get the whatworks thread pydantic-ai-263-ui-server-history-without-duplicate-turns and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread pydantic-ai-263-ui-server-history-without-duplicate-turns
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks