|
1 | | -from typing import Generic, Optional, List, Any |
| 1 | +from typing import AsyncGenerator, Generic, Optional, List, Any |
2 | 2 | from contextvars import ContextVar |
3 | 3 | from contextlib import asynccontextmanager |
4 | 4 | from collections.abc import Sequence |
|
17 | 17 | HistoryProcessor, |
18 | 18 | EventStreamHandler, |
19 | 19 | InstrumentationSettings, |
| 20 | + AgentRunResult, |
20 | 21 | ) |
21 | 22 | from pydantic_ai.agent.abstract import RunOutputDataT |
22 | 23 | from pydantic_ai import messages as _messages |
@@ -185,7 +186,7 @@ async def run( |
185 | 186 | thread_id: Optional[str] = None, |
186 | 187 | metrics: Optional[List[BaseMetric]] = None, |
187 | 188 | metric_collection: Optional[str] = None, |
188 | | - ): |
| 189 | + ) -> AgentRunResult[Any]: |
189 | 190 | input = user_prompt |
190 | 191 |
|
191 | 192 | agent_name = super().name if super().name is not None else "Agent" |
@@ -271,8 +272,7 @@ def run_sync( |
271 | 272 | user_id: Optional[str] = None, |
272 | 273 | metric_collection: Optional[str] = None, |
273 | 274 | metrics: Optional[List[BaseMetric]] = None, |
274 | | - **kwargs |
275 | | - ): |
| 275 | + ) -> AgentRunResult[Any]: |
276 | 276 | input = user_prompt |
277 | 277 |
|
278 | 278 | token = _IS_RUN_SYNC.set(True) |
@@ -364,7 +364,7 @@ async def run_stream( |
364 | 364 | user_id: Optional[str] = None, |
365 | 365 | metric_collection: Optional[str] = None, |
366 | 366 | metrics: Optional[List[BaseMetric]] = None, |
367 | | - ): |
| 367 | + ) -> AsyncGenerator[AgentRunResult[Any], None]: |
368 | 368 | input = user_prompt |
369 | 369 |
|
370 | 370 | agent_name = super().name if super().name is not None else "Agent" |
@@ -464,7 +464,7 @@ def tool( |
464 | 464 |
|
465 | 465 | metrics: Optional[List[BaseMetric]] = None, |
466 | 466 | metric_collection: Optional[str] = None, |
467 | | - ): |
| 467 | + ) -> Any: |
468 | 468 | # Direct decoration: @agent.tool |
469 | 469 | if func is not None and callable(func): |
470 | 470 | patched_func = create_patched_tool(func, metrics, metric_collection) |
|
0 commit comments