Skip to content

Commit a2b9287

Browse files
committed
fix(ag-ui): eliminate unnecessary mcp import
Eliminate the unnecessary import of mcp in ag_ui.py, which was causing issues when running the tests in CI as mcp is not always available.
1 parent d6a5130 commit a2b9287

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pydantic_ai_slim/pydantic_ai/ag_ui.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@
1212
from collections.abc import Iterable, Mapping, Sequence
1313
from dataclasses import dataclass, field
1414
from enum import Enum
15-
from typing import TYPE_CHECKING, Any, Callable, Final, Generic, Protocol, TypeVar, cast, runtime_checkable
15+
from typing import (
16+
TYPE_CHECKING,
17+
Any,
18+
Callable,
19+
Final,
20+
Generic,
21+
NoReturn,
22+
Protocol,
23+
TypeVar,
24+
cast,
25+
runtime_checkable,
26+
)
1627

1728
try:
1829
from ag_ui.core import (
@@ -67,7 +78,6 @@
6778
from ._output import OutputType
6879
from ._parts_manager import ModelResponsePartsManager
6980
from .agent import RunOutputDataT
70-
from .mcp import ToolResult
7181
from .messages import (
7282
AgentStreamEvent,
7383
FinalResultEvent,
@@ -644,7 +654,7 @@ def _tool_call(self, tool: ToolAGUI) -> Tool[AgentDepsT]:
644654
A PydanticAI `Tool` object that calls the AG-UI tool.
645655
"""
646656

647-
def _tool_stub(*args: Any, **kwargs: Any) -> ToolResult:
657+
def _tool_stub(*args: Any, **kwargs: Any) -> NoReturn:
648658
"""Stub function which is never called.
649659
650660
Returns:
@@ -655,7 +665,6 @@ def _tool_stub(*args: Any, **kwargs: Any) -> ToolResult:
655665
"""
656666
raise _UnexpectedToolCallError(tool_name=tool.name) # pragma: no cover
657667

658-
# TODO(steve): See it we can avoid the cast here.
659668
return cast(
660669
'Tool[AgentDepsT]',
661670
Tool.from_schema(

0 commit comments

Comments
 (0)