Handle instruction updates in token estimates and conversation search

Merged
DS
2mo ago
+92-1

This pull request was posted by Codex Desktop using gpt-6-astra on behalf of David.

Summary

Account for InstructionDeltaPart in compaction token estimates and conversation search. The exhaustive handlers currently fail the core PR's harness compatibility check.

Token estimates count the complete rendered replacement or withdrawal and exclude updates superseded by a new instruction baseline. Search indexes that system text in full and limits its displayed excerpt to 200 characters. Matching the discriminator keeps this importable with released Pydantic AI before the new class exists.

Targeted estimator/search tests and type checks pass against released core 2.38.0 and the core PR branch. New-part tests skip on releases without the class; version-dependent coverage exclusions cover those unreachable paths. Dependencies are unchanged.

Linked Issue

Related to pydantic/pydantic-ai#7900. Companion to pydantic/pydantic-ai#8188; this can land first so that PR's harness compatibility check can pass.

Checklist

  • Linked issue exists and is referenced above
  • Tests added/updated for new behavior
  • make lint && make typecheck && make test passes locally (targeted checks and full precommit pass; full tests run in CI)
  • pyproject.toml and uv.lock are unchanged, or a maintainer added dependencies:approved to the current head
  • Docstrings use single backticks (not RST double backticks)