Skip to content

Commit fa70cc9

Browse files
zzstoatzzclaude
andauthored
fix: handle PartEndEvent from pydantic-ai 1.9.0+ (#1240)
PartEndEvent was added in pydantic-ai v1.9.0 (PR #2923) as part of the Vercel AI Data Stream Protocol support. This event signals when a part is complete during streaming. Changes: - Import PartEndEvent from pydantic_ai.messages - Add handler in _process_pydantic_event to acknowledge PartEndEvent without emitting a Marvin event (completion is handled via other events like FunctionToolCallEvent and FinalResultEvent) - Update pydantic-ai dependency from >=0.7.2 to >=1.9.0 to ensure PartEndEvent is available This fixes the "Unknown event type: PartEndEvent" warnings that started appearing after pydantic-ai was updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent f3b7c13 commit fa70cc9

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies = [
1010
"alembic>=1.12.0",
1111
"jinja2>=3.1.4",
1212
"partial-json-parser>=0.2.1.1.post5",
13-
"pydantic-ai>=0.7.2",
13+
"pydantic-ai>=1.9.0",
1414
"pydantic-settings>=2.6.1",
1515
"pydantic[email]>=2.10.6",
1616
"rich>=13.9.4",

src/marvin/engine/streaming.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
FunctionToolResultEvent,
1111
ModelResponsePart,
1212
PartDeltaEvent,
13+
PartEndEvent,
1314
PartStartEvent,
1415
RetryPromptPart,
1516
TextPartDelta,
@@ -236,6 +237,13 @@ def _get_snapshot(index: int) -> ModelResponsePart | None:
236237
tool_call_id=snapshot.tool_call_id if snapshot else None,
237238
tool=tools_map.get(event.part.tool_name),
238239
)
240+
# Handle Part End Events
241+
elif isinstance(event, PartEndEvent):
242+
# Part end events signal that a part is complete. We don't need to
243+
# emit a Marvin event for this since we handle completion via other
244+
# events (FunctionToolCallEvent, FinalResultEvent, etc.)
245+
return None
246+
239247
# Handle Part Delta Events
240248
elif isinstance(event, PartDeltaEvent):
241249
# Process a delta update to an existing part

uv.lock

Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)