Skip to content

agents: preserve indexed Pydantic text replacements - #966

Draft
yisding wants to merge 1 commit into
mainfrom
agent/pydantic-text-part-replacement
Draft

agents: preserve indexed Pydantic text replacements#966
yisding wants to merge 1 commit into
mainfrom
agent/pydantic-text-part-replacement

Conversation

@yisding

@yisding yisding commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Problem

PR #961 restored initial PydanticAI TextPart content, but the bridge still
normalized every part start as an append-only text_delta and discarded
PartStartEvent.index. PydanticAI may emit another start for the same index as
a replacement, so consumers could retain stale text or append duplicate text.

What changed

  • extend AgentBridgeEvent with indexed text events and a text_replace kind
  • preserve PydanticAI part indexes for starts and deltas, including repeated
    same-index starts and graph-local index namespaces
  • use one canonical text-part accumulator across bridge, runner, stage, text,
    and voice consumers so transcripts and history preserve replacement semantics
  • expose replacement metadata through AgentDelta and journal records
  • define TTS behavior: repair replacements while text is buffered; once speech
    is admitted, cancel and clear stale playback and suppress further TTS for the
    turn while allowing the corrected transcript and history to complete
  • document the bridge contract and add regression coverage for same-index starts,
    buffering, playback cutoff, graph streams, and consumer history

Impact

Ordinary unindexed text_delta streams remain append-only. Indexed bridges must
use indexed deltas consistently within a turn. A divergent replacement after
TTS admission fails closed instead of replaying corrected text over speech the
caller may already have heard.

Verification

  • 368 passed across the focused bridge, PydanticAI, stage, session consumer,
    event, and lifecycle suites
  • just guard-contracts (218 passed)
  • .venv/bin/ruff check src tests
  • .venv/bin/ruff format --check src tests
  • .venv/bin/mypy src/easycat (289 source files)

Follow-up to #961.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 05c5f6f1-0b49-4319-9d8a-b641fd3240f5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant