Daily Edition Sources +9

Pydantic Updates Agent Instructions Without Rewriting the Opening

An agent’s task state can change without changing the start of its next model request. Pydantic AI’s new append mode puts the update at the end of the conversation, preserving the earlier prefix for possible cache reuse.

repo pydantic/pydantic-ai evidence
9 source signals 1 repo commit cd04b05
Evidence: commit cd04b05 / October 21, 2026 / Daily Edition
Open Edition Evidence below

Pydantic AI is the Python framework between an application’s tools and its model calls. A change merged October 20 in pydantic/pydantic-ai gives it a new way to assemble those calls: keep an instruction’s original text in the opening, then send changed state later. A todo can become “done” without rewriting the “pending” text the model first received.

That matters because prompt caches recognize matching beginnings. Editing an early instruction can break reuse of the material after it. The new option moves the update; it does not freeze the task or erase the old state.

The update moves. The opening stays.

A tool has marked a task as done. Compare how Pydantic AI assembles the next request to the model. Read each strip from top to bottom.

The default rewrites the opening. Append mode keeps that opening and puts the new value after the conversation.

Rewrite the opening

The default for your instructions.

1 · Opening instructionsTodo: doneCurrent value replaces the earlier one here.
2 · ConversationMessages and tool resultsThe conversation follows the instructions.
3 · End of historyNo appended replacementThe instruction changed at the opening.

Append the update

Opt in on an identified instruction.

1 · Opening instructionsTodo: pendingLater update says this value is superseded.
2 · ConversationMessages and tool resultsThe same earlier history stays ahead of the update.
3 · End of historyTodo: doneIdentifies the replacement value.

Schematic of instruction placement, not a model run or a cache-hit measurement. “Pending” remains in the append-mode opening as historical text; the later replacement with the same identity tells the model to use the new value. Provider formatting is simplified here.

Keeping this prefix stable can preserve a condition for cache reuse. Other request changes, provider rules and expiry still matter. Each update also stays in history; a new baseline or compaction changes the comparison.

Inspect the source example and its limits.

The problem predates the patch

A small state change can disturb a long opening.

Developers had already encountered the tradeoff. An issue opened August 6 asked for cache-friendly dynamic instructions. In another report opened August 30, an application author described a todo update invalidating a much larger prompt prefix—and a workaround that put changing state later in the conversation.

The new contribution is a framework-owned contract for that technique. A named instruction can opt into on_change='append'. Its function still runs before each model request, including after a tool changes state. The initial value stays in place; a changed value becomes a typed history entry. An unchanged value adds nothing. Withdrawing the instruction produces a withdrawal rather than silently leaving the old value in force.

An update is not an eraser

The model sees the old state and its replacement.

Pydantic labels the instruction so later text can identify what it supersedes. Saved history retains the complete replacement; for a small edit to a long block, the request can carry a shorter diff. The framework also saves a baseline record so a fresh agent instance can reconstruct the earlier prefix. That bookkeeping record is not itself sent to the model.

The provider tests check both sides of the promise: unchanged earlier request content and a delivered update after a tool changes a todo from pending to done. Other cases change a warehouse destination, withdraw it and continue through serialized history. We inspected the tests and recorded provider cases; we did not run a live model trial or measure a bill.

Delivery also has a meaningful boundary. Models that support system messages within a conversation receive updates that way. Others receive system-tagged text inside a user message. The tags do not give that text identical instruction priority. Preserving the prefix and getting the model to follow the new state are separate things to verify.

The cache lasts longer. The prefix still has to match.

Retention and request construction solve different problems.

OpenAI’s October 20 API announcement adds a 12-hour prompt-cache option. Its guide prices those writes at 2.5 times ordinary input, compared with 1.25 times for 30 minutes; the read rate is the same for either lifetime. Longer retention can help a stable prefix reused hours later. It cannot make a changed prefix identical.

Pydantic’s work began before that announcement. It does not implement OpenAI’s retention setting, and neither source establishes savings for a particular application. The useful connection is a design choice: separate frequently changing task state from material worth keeping stable, then measure the complete workload.

Open the Diagram Punk poster
Two paper strips compare rewriting Todo: done at the opening with retaining Todo: pending and appending Todo: done after history.
Diagram Punkthe update changes position; the earlier state stays in the prompt. Cache reuse is not guaranteed.

Ask about this article

Pydantic Updates Agent Instructions Without Rewriting the Opening

Article link and summary included. Continue using your ChatGPT account; you may need to sign in.

If your question doesn’t appear in ChatGPT, copy it here and paste it there.

Your immediate reaction

How did this article land?

A thumb saves immediately. Notes stay private and are discussed with the editor before shaping future articles.

Evidence Trail

Receipts below the story

The article above is the public narrative. This section keeps the source trail and limits on the same page.

Edition
DateOctober 21, 2026
LaneDaily Edition
Confidence91%
Sources9
Repospydantic/pydantic-ai

Primary Evidence

Evidence Limits

  • Source and recorded tests were inspected; no live model trial, application benchmark or independent cost measurement was performed.
  • Latest inspected release v2.58.0 does not contain the merge. Development source does not establish installed-package availability.
  • Prefix stability applies between baseline resets with other inputs unchanged. Cache hits, latency and savings depend on provider rules and workload.
  • Appended text may have different message roles across providers. Model acceptance and state-following are not guaranteed by text placement.
  • Superseded values stay in trusted history. Compaction, lost baseline, rewritten blocks and changed policies can reset the opening; tools, model and expiry can separately defeat reuse.