Skip to content

Commit 2c49a4b

Browse files
Lint fixes
1 parent cc66d80 commit 2c49a4b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

pydantic_ai_slim/pydantic_ai/_agent_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,8 @@ async def _process_message_history(
11191119

11201120
if is_async_callable(processor):
11211121
if takes_ctx:
1122-
messages = await processor(run_context, messages)
1122+
async_processor_with_ctx = cast(_HistoryProcessorAsyncWithCtx[DepsT], processor)
1123+
messages = await async_processor_with_ctx(run_context, messages)
11231124
else:
11241125
async_processor = cast(_HistoryProcessorAsync, processor)
11251126
messages = await async_processor(messages)
@@ -1131,7 +1132,6 @@ async def _process_message_history(
11311132
sync_processor = cast(_HistoryProcessorSync, processor)
11321133
messages = await run_in_executor(sync_processor, messages)
11331134

1134-
messages = cast(list[_messages.ModelMessage], messages)
11351135
if len(messages) == 0:
11361136
raise exceptions.UserError('Processed history cannot be empty.')
11371137

pydantic_ai_slim/pydantic_ai/ag_ui.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from __future__ import annotations
88

9+
import asyncio
910
import json
1011
import uuid
1112
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Mapping, Sequence
@@ -24,7 +25,6 @@
2425

2526
from pydantic import BaseModel, ValidationError
2627

27-
from . import _utils
2828
from ._agent_graph import CallToolsNode, ModelRequestNode
2929
from .agent import AbstractAgent, AgentRun, AgentRunResult
3030
from .exceptions import UserError
@@ -378,11 +378,9 @@ async def run_ag_ui(
378378
yield encoder.encode(event)
379379

380380
if on_complete is not None and run.result is not None:
381-
if _utils.is_async_callable(on_complete):
382-
if on_complete is not None:
383-
await on_complete(run.result)
384-
else:
385-
await _utils.run_in_executor(on_complete, run.result)
381+
result = on_complete(run.result)
382+
if asyncio.iscoroutine(result):
383+
await result
386384
except _RunError as e:
387385
yield encoder.encode(
388386
RunErrorEvent(message=e.message, code=e.code),

0 commit comments

Comments
 (0)