pydantic-ai-slim 1.0.15__py3-none-any.whl → 1.0.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pydantic_ai/_agent_graph.py +13 -12
- pydantic_ai/_cli.py +3 -3
- pydantic_ai/agent/__init__.py +33 -9
- pydantic_ai/agent/abstract.py +54 -26
- pydantic_ai/agent/wrapper.py +13 -4
- pydantic_ai/builtin_tools.py +4 -1
- pydantic_ai/direct.py +9 -9
- pydantic_ai/durable_exec/dbos/_agent.py +52 -20
- pydantic_ai/durable_exec/temporal/_agent.py +45 -16
- pydantic_ai/format_prompt.py +6 -4
- pydantic_ai/messages.py +71 -43
- pydantic_ai/models/anthropic.py +20 -19
- pydantic_ai/models/openai.py +9 -1
- pydantic_ai/result.py +5 -5
- pydantic_ai/usage.py +35 -1
- {pydantic_ai_slim-1.0.15.dist-info → pydantic_ai_slim-1.0.17.dist-info}/METADATA +4 -4
- {pydantic_ai_slim-1.0.15.dist-info → pydantic_ai_slim-1.0.17.dist-info}/RECORD +20 -20
- {pydantic_ai_slim-1.0.15.dist-info → pydantic_ai_slim-1.0.17.dist-info}/WHEEL +0 -0
- {pydantic_ai_slim-1.0.15.dist-info → pydantic_ai_slim-1.0.17.dist-info}/entry_points.txt +0 -0
- {pydantic_ai_slim-1.0.15.dist-info → pydantic_ai_slim-1.0.17.dist-info}/licenses/LICENSE +0 -0
pydantic_ai/_agent_graph.py
CHANGED
|
@@ -795,16 +795,14 @@ async def process_tool_calls( # noqa: C901
|
|
|
795
795
|
# Then, we handle function tool calls
|
|
796
796
|
calls_to_run: list[_messages.ToolCallPart] = []
|
|
797
797
|
if final_result and ctx.deps.end_strategy == 'early':
|
|
798
|
-
|
|
799
|
-
|
|
798
|
+
for call in tool_calls_by_kind['function']:
|
|
799
|
+
output_parts.append(
|
|
800
800
|
_messages.ToolReturnPart(
|
|
801
801
|
tool_name=call.tool_name,
|
|
802
802
|
content='Tool not executed - a final result was already processed.',
|
|
803
803
|
tool_call_id=call.tool_call_id,
|
|
804
804
|
)
|
|
805
|
-
|
|
806
|
-
]
|
|
807
|
-
)
|
|
805
|
+
)
|
|
808
806
|
else:
|
|
809
807
|
calls_to_run.extend(tool_calls_by_kind['function'])
|
|
810
808
|
|
|
@@ -850,14 +848,17 @@ async def process_tool_calls( # noqa: C901
|
|
|
850
848
|
if tool_call_results is None:
|
|
851
849
|
calls = [*tool_calls_by_kind['external'], *tool_calls_by_kind['unapproved']]
|
|
852
850
|
if final_result:
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
851
|
+
# If the run was already determined to end on deferred tool calls,
|
|
852
|
+
# we shouldn't insert return parts as the deferred tools will still get a real result.
|
|
853
|
+
if not isinstance(final_result.output, _output.DeferredToolRequests):
|
|
854
|
+
for call in calls:
|
|
855
|
+
output_parts.append(
|
|
856
|
+
_messages.ToolReturnPart(
|
|
857
|
+
tool_name=call.tool_name,
|
|
858
|
+
content='Tool not executed - a final result was already processed.',
|
|
859
|
+
tool_call_id=call.tool_call_id,
|
|
860
|
+
)
|
|
859
861
|
)
|
|
860
|
-
)
|
|
861
862
|
elif calls:
|
|
862
863
|
deferred_calls['external'].extend(tool_calls_by_kind['external'])
|
|
863
864
|
deferred_calls['unapproved'].extend(tool_calls_by_kind['unapproved'])
|
pydantic_ai/_cli.py
CHANGED
|
@@ -228,7 +228,7 @@ async def run_chat(
|
|
|
228
228
|
prog_name: str,
|
|
229
229
|
config_dir: Path | None = None,
|
|
230
230
|
deps: AgentDepsT = None,
|
|
231
|
-
message_history:
|
|
231
|
+
message_history: Sequence[ModelMessage] | None = None,
|
|
232
232
|
) -> int:
|
|
233
233
|
prompt_history_path = (config_dir or PYDANTIC_AI_HOME) / PROMPT_HISTORY_FILENAME
|
|
234
234
|
prompt_history_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -236,7 +236,7 @@ async def run_chat(
|
|
|
236
236
|
session: PromptSession[Any] = PromptSession(history=FileHistory(str(prompt_history_path)))
|
|
237
237
|
|
|
238
238
|
multiline = False
|
|
239
|
-
messages: list[ModelMessage] = message_history
|
|
239
|
+
messages: list[ModelMessage] = list(message_history) if message_history else []
|
|
240
240
|
|
|
241
241
|
while True:
|
|
242
242
|
try:
|
|
@@ -272,7 +272,7 @@ async def ask_agent(
|
|
|
272
272
|
console: Console,
|
|
273
273
|
code_theme: str,
|
|
274
274
|
deps: AgentDepsT = None,
|
|
275
|
-
messages:
|
|
275
|
+
messages: Sequence[ModelMessage] | None = None,
|
|
276
276
|
) -> list[ModelMessage]:
|
|
277
277
|
status = Status('[dim]Working on it…[/dim]', console=console)
|
|
278
278
|
|
pydantic_ai/agent/__init__.py
CHANGED
|
@@ -344,6 +344,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
344
344
|
|
|
345
345
|
self._event_stream_handler = event_stream_handler
|
|
346
346
|
|
|
347
|
+
self._override_name: ContextVar[_utils.Option[str]] = ContextVar('_override_name', default=None)
|
|
347
348
|
self._override_deps: ContextVar[_utils.Option[AgentDepsT]] = ContextVar('_override_deps', default=None)
|
|
348
349
|
self._override_model: ContextVar[_utils.Option[models.Model]] = ContextVar('_override_model', default=None)
|
|
349
350
|
self._override_toolsets: ContextVar[_utils.Option[Sequence[AbstractToolset[AgentDepsT]]]] = ContextVar(
|
|
@@ -384,7 +385,8 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
384
385
|
|
|
385
386
|
If `None`, we try to infer the agent name from the call frame when the agent is first run.
|
|
386
387
|
"""
|
|
387
|
-
|
|
388
|
+
name_ = self._override_name.get()
|
|
389
|
+
return name_.value if name_ else self._name
|
|
388
390
|
|
|
389
391
|
@name.setter
|
|
390
392
|
def name(self, value: str | None) -> None:
|
|
@@ -415,7 +417,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
415
417
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
416
418
|
*,
|
|
417
419
|
output_type: None = None,
|
|
418
|
-
message_history:
|
|
420
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
419
421
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
420
422
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
421
423
|
deps: AgentDepsT = None,
|
|
@@ -424,6 +426,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
424
426
|
usage: _usage.RunUsage | None = None,
|
|
425
427
|
infer_name: bool = True,
|
|
426
428
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
429
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
427
430
|
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, OutputDataT]]: ...
|
|
428
431
|
|
|
429
432
|
@overload
|
|
@@ -432,7 +435,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
432
435
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
433
436
|
*,
|
|
434
437
|
output_type: OutputSpec[RunOutputDataT],
|
|
435
|
-
message_history:
|
|
438
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
436
439
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
437
440
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
438
441
|
deps: AgentDepsT = None,
|
|
@@ -441,6 +444,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
441
444
|
usage: _usage.RunUsage | None = None,
|
|
442
445
|
infer_name: bool = True,
|
|
443
446
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
447
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
444
448
|
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, RunOutputDataT]]: ...
|
|
445
449
|
|
|
446
450
|
@asynccontextmanager
|
|
@@ -449,7 +453,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
449
453
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
450
454
|
*,
|
|
451
455
|
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
452
|
-
message_history:
|
|
456
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
453
457
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
454
458
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
455
459
|
deps: AgentDepsT = None,
|
|
@@ -458,6 +462,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
458
462
|
usage: _usage.RunUsage | None = None,
|
|
459
463
|
infer_name: bool = True,
|
|
460
464
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
465
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
461
466
|
) -> AsyncIterator[AgentRun[AgentDepsT, Any]]:
|
|
462
467
|
"""A contextmanager which can be used to iterate over the agent graph's nodes as they are executed.
|
|
463
468
|
|
|
@@ -530,6 +535,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
530
535
|
usage: Optional usage to start with, useful for resuming a conversation or agents used in tools.
|
|
531
536
|
infer_name: Whether to try to infer the agent name from the call frame if it's not set.
|
|
532
537
|
toolsets: Optional additional toolsets for this run.
|
|
538
|
+
builtin_tools: Optional additional builtin tools for this run.
|
|
533
539
|
|
|
534
540
|
Returns:
|
|
535
541
|
The result of the run.
|
|
@@ -566,7 +572,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
566
572
|
# Build the initial state
|
|
567
573
|
usage = usage or _usage.RunUsage()
|
|
568
574
|
state = _agent_graph.GraphAgentState(
|
|
569
|
-
message_history=message_history
|
|
575
|
+
message_history=list(message_history) if message_history else [],
|
|
570
576
|
usage=usage,
|
|
571
577
|
retries=0,
|
|
572
578
|
run_step=0,
|
|
@@ -601,7 +607,16 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
601
607
|
else:
|
|
602
608
|
instrumentation_settings = None
|
|
603
609
|
tracer = NoOpTracer()
|
|
604
|
-
|
|
610
|
+
if builtin_tools:
|
|
611
|
+
# Deduplicate builtin tools passed to the agent and the run based on type
|
|
612
|
+
builtin_tools = list(
|
|
613
|
+
{
|
|
614
|
+
**({type(tool): tool for tool in self._builtin_tools or []}),
|
|
615
|
+
**({type(tool): tool for tool in builtin_tools}),
|
|
616
|
+
}.values()
|
|
617
|
+
)
|
|
618
|
+
else:
|
|
619
|
+
builtin_tools = list(self._builtin_tools)
|
|
605
620
|
graph_deps = _agent_graph.GraphAgentDeps[AgentDepsT, RunOutputDataT](
|
|
606
621
|
user_deps=deps,
|
|
607
622
|
prompt=user_prompt,
|
|
@@ -614,7 +629,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
614
629
|
output_schema=output_schema,
|
|
615
630
|
output_validators=output_validators,
|
|
616
631
|
history_processors=self.history_processors,
|
|
617
|
-
builtin_tools=
|
|
632
|
+
builtin_tools=builtin_tools,
|
|
618
633
|
tool_manager=tool_manager,
|
|
619
634
|
tracer=tracer,
|
|
620
635
|
get_instructions=get_instructions,
|
|
@@ -690,7 +705,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
690
705
|
}
|
|
691
706
|
else:
|
|
692
707
|
attrs = {
|
|
693
|
-
'pydantic_ai.all_messages': json.dumps(settings.messages_to_otel_messages(state.message_history)),
|
|
708
|
+
'pydantic_ai.all_messages': json.dumps(settings.messages_to_otel_messages(list(state.message_history))),
|
|
694
709
|
**settings.system_instructions_attributes(literal_instructions),
|
|
695
710
|
}
|
|
696
711
|
|
|
@@ -712,24 +727,31 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
712
727
|
def override(
|
|
713
728
|
self,
|
|
714
729
|
*,
|
|
730
|
+
name: str | _utils.Unset = _utils.UNSET,
|
|
715
731
|
deps: AgentDepsT | _utils.Unset = _utils.UNSET,
|
|
716
732
|
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
|
|
717
733
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
|
|
718
734
|
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
|
|
719
735
|
instructions: Instructions[AgentDepsT] | _utils.Unset = _utils.UNSET,
|
|
720
736
|
) -> Iterator[None]:
|
|
721
|
-
"""Context manager to temporarily override agent dependencies, model, toolsets, tools, or instructions.
|
|
737
|
+
"""Context manager to temporarily override agent name, dependencies, model, toolsets, tools, or instructions.
|
|
722
738
|
|
|
723
739
|
This is particularly useful when testing.
|
|
724
740
|
You can find an example of this [here](../testing.md#overriding-model-via-pytest-fixtures).
|
|
725
741
|
|
|
726
742
|
Args:
|
|
743
|
+
name: The name to use instead of the name passed to the agent constructor and agent run.
|
|
727
744
|
deps: The dependencies to use instead of the dependencies passed to the agent run.
|
|
728
745
|
model: The model to use instead of the model passed to the agent run.
|
|
729
746
|
toolsets: The toolsets to use instead of the toolsets passed to the agent constructor and agent run.
|
|
730
747
|
tools: The tools to use instead of the tools registered with the agent.
|
|
731
748
|
instructions: The instructions to use instead of the instructions registered with the agent.
|
|
732
749
|
"""
|
|
750
|
+
if _utils.is_set(name):
|
|
751
|
+
name_token = self._override_name.set(_utils.Some(name))
|
|
752
|
+
else:
|
|
753
|
+
name_token = None
|
|
754
|
+
|
|
733
755
|
if _utils.is_set(deps):
|
|
734
756
|
deps_token = self._override_deps.set(_utils.Some(deps))
|
|
735
757
|
else:
|
|
@@ -759,6 +781,8 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
759
781
|
try:
|
|
760
782
|
yield
|
|
761
783
|
finally:
|
|
784
|
+
if name_token is not None:
|
|
785
|
+
self._override_name.reset(name_token)
|
|
762
786
|
if deps_token is not None:
|
|
763
787
|
self._override_deps.reset(deps_token)
|
|
764
788
|
if model_token is not None:
|
pydantic_ai/agent/abstract.py
CHANGED
|
@@ -25,6 +25,7 @@ from .. import (
|
|
|
25
25
|
usage as _usage,
|
|
26
26
|
)
|
|
27
27
|
from .._tool_manager import ToolManager
|
|
28
|
+
from ..builtin_tools import AbstractBuiltinTool
|
|
28
29
|
from ..output import OutputDataT, OutputSpec
|
|
29
30
|
from ..result import AgentStream, FinalResult, StreamedRunResult
|
|
30
31
|
from ..run import AgentRun, AgentRunResult, AgentRunResultEvent
|
|
@@ -128,7 +129,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
128
129
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
129
130
|
*,
|
|
130
131
|
output_type: None = None,
|
|
131
|
-
message_history:
|
|
132
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
132
133
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
133
134
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
134
135
|
deps: AgentDepsT = None,
|
|
@@ -137,6 +138,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
137
138
|
usage: _usage.RunUsage | None = None,
|
|
138
139
|
infer_name: bool = True,
|
|
139
140
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
141
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
140
142
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
141
143
|
) -> AgentRunResult[OutputDataT]: ...
|
|
142
144
|
|
|
@@ -146,7 +148,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
146
148
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
147
149
|
*,
|
|
148
150
|
output_type: OutputSpec[RunOutputDataT],
|
|
149
|
-
message_history:
|
|
151
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
150
152
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
151
153
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
152
154
|
deps: AgentDepsT = None,
|
|
@@ -155,6 +157,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
155
157
|
usage: _usage.RunUsage | None = None,
|
|
156
158
|
infer_name: bool = True,
|
|
157
159
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
160
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
158
161
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
159
162
|
) -> AgentRunResult[RunOutputDataT]: ...
|
|
160
163
|
|
|
@@ -163,7 +166,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
163
166
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
164
167
|
*,
|
|
165
168
|
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
166
|
-
message_history:
|
|
169
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
167
170
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
168
171
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
169
172
|
deps: AgentDepsT = None,
|
|
@@ -172,6 +175,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
172
175
|
usage: _usage.RunUsage | None = None,
|
|
173
176
|
infer_name: bool = True,
|
|
174
177
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
178
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
175
179
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
176
180
|
) -> AgentRunResult[Any]:
|
|
177
181
|
"""Run the agent with a user prompt in async mode.
|
|
@@ -205,6 +209,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
205
209
|
infer_name: Whether to try to infer the agent name from the call frame if it's not set.
|
|
206
210
|
toolsets: Optional additional toolsets for this run.
|
|
207
211
|
event_stream_handler: Optional handler for events from the model's streaming response and the agent's execution of tools to use for this run.
|
|
212
|
+
builtin_tools: Optional additional builtin tools for this run.
|
|
208
213
|
|
|
209
214
|
Returns:
|
|
210
215
|
The result of the run.
|
|
@@ -225,6 +230,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
225
230
|
usage_limits=usage_limits,
|
|
226
231
|
usage=usage,
|
|
227
232
|
toolsets=toolsets,
|
|
233
|
+
builtin_tools=builtin_tools,
|
|
228
234
|
) as agent_run:
|
|
229
235
|
async for node in agent_run:
|
|
230
236
|
if event_stream_handler is not None and (
|
|
@@ -242,7 +248,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
242
248
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
243
249
|
*,
|
|
244
250
|
output_type: None = None,
|
|
245
|
-
message_history:
|
|
251
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
246
252
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
247
253
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
248
254
|
deps: AgentDepsT = None,
|
|
@@ -251,6 +257,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
251
257
|
usage: _usage.RunUsage | None = None,
|
|
252
258
|
infer_name: bool = True,
|
|
253
259
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
260
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
254
261
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
255
262
|
) -> AgentRunResult[OutputDataT]: ...
|
|
256
263
|
|
|
@@ -260,7 +267,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
260
267
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
261
268
|
*,
|
|
262
269
|
output_type: OutputSpec[RunOutputDataT],
|
|
263
|
-
message_history:
|
|
270
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
264
271
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
265
272
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
266
273
|
deps: AgentDepsT = None,
|
|
@@ -269,6 +276,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
269
276
|
usage: _usage.RunUsage | None = None,
|
|
270
277
|
infer_name: bool = True,
|
|
271
278
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
279
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
272
280
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
273
281
|
) -> AgentRunResult[RunOutputDataT]: ...
|
|
274
282
|
|
|
@@ -277,7 +285,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
277
285
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
278
286
|
*,
|
|
279
287
|
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
280
|
-
message_history:
|
|
288
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
281
289
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
282
290
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
283
291
|
deps: AgentDepsT = None,
|
|
@@ -286,6 +294,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
286
294
|
usage: _usage.RunUsage | None = None,
|
|
287
295
|
infer_name: bool = True,
|
|
288
296
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
297
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
289
298
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
290
299
|
) -> AgentRunResult[Any]:
|
|
291
300
|
"""Synchronously run the agent with a user prompt.
|
|
@@ -318,6 +327,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
318
327
|
infer_name: Whether to try to infer the agent name from the call frame if it's not set.
|
|
319
328
|
toolsets: Optional additional toolsets for this run.
|
|
320
329
|
event_stream_handler: Optional handler for events from the model's streaming response and the agent's execution of tools to use for this run.
|
|
330
|
+
builtin_tools: Optional additional builtin tools for this run.
|
|
321
331
|
|
|
322
332
|
Returns:
|
|
323
333
|
The result of the run.
|
|
@@ -338,6 +348,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
338
348
|
usage=usage,
|
|
339
349
|
infer_name=False,
|
|
340
350
|
toolsets=toolsets,
|
|
351
|
+
builtin_tools=builtin_tools,
|
|
341
352
|
event_stream_handler=event_stream_handler,
|
|
342
353
|
)
|
|
343
354
|
)
|
|
@@ -348,7 +359,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
348
359
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
349
360
|
*,
|
|
350
361
|
output_type: None = None,
|
|
351
|
-
message_history:
|
|
362
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
352
363
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
353
364
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
354
365
|
deps: AgentDepsT = None,
|
|
@@ -357,6 +368,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
357
368
|
usage: _usage.RunUsage | None = None,
|
|
358
369
|
infer_name: bool = True,
|
|
359
370
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
371
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
360
372
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
361
373
|
) -> AbstractAsyncContextManager[result.StreamedRunResult[AgentDepsT, OutputDataT]]: ...
|
|
362
374
|
|
|
@@ -366,7 +378,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
366
378
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
367
379
|
*,
|
|
368
380
|
output_type: OutputSpec[RunOutputDataT],
|
|
369
|
-
message_history:
|
|
381
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
370
382
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
371
383
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
372
384
|
deps: AgentDepsT = None,
|
|
@@ -375,6 +387,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
375
387
|
usage: _usage.RunUsage | None = None,
|
|
376
388
|
infer_name: bool = True,
|
|
377
389
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
390
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
378
391
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
379
392
|
) -> AbstractAsyncContextManager[result.StreamedRunResult[AgentDepsT, RunOutputDataT]]: ...
|
|
380
393
|
|
|
@@ -384,7 +397,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
384
397
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
385
398
|
*,
|
|
386
399
|
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
387
|
-
message_history:
|
|
400
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
388
401
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
389
402
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
390
403
|
deps: AgentDepsT = None,
|
|
@@ -393,6 +406,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
393
406
|
usage: _usage.RunUsage | None = None,
|
|
394
407
|
infer_name: bool = True,
|
|
395
408
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
409
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
396
410
|
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
397
411
|
) -> AsyncIterator[result.StreamedRunResult[AgentDepsT, Any]]:
|
|
398
412
|
"""Run the agent with a user prompt in async streaming mode.
|
|
@@ -432,6 +446,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
432
446
|
usage: Optional usage to start with, useful for resuming a conversation or agents used in tools.
|
|
433
447
|
infer_name: Whether to try to infer the agent name from the call frame if it's not set.
|
|
434
448
|
toolsets: Optional additional toolsets for this run.
|
|
449
|
+
builtin_tools: Optional additional builtin tools for this run.
|
|
435
450
|
event_stream_handler: Optional handler for events from the model's streaming response and the agent's execution of tools to use for this run.
|
|
436
451
|
It will receive all the events up until the final result is found, which you can then read or stream from inside the context manager.
|
|
437
452
|
Note that it does _not_ receive any events after the final result is found.
|
|
@@ -459,6 +474,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
459
474
|
usage=usage,
|
|
460
475
|
infer_name=False,
|
|
461
476
|
toolsets=toolsets,
|
|
477
|
+
builtin_tools=builtin_tools,
|
|
462
478
|
) as agent_run:
|
|
463
479
|
first_node = agent_run.next_node # start with the first node
|
|
464
480
|
assert isinstance(first_node, _agent_graph.UserPromptNode) # the first node should be a user prompt node
|
|
@@ -489,7 +505,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
489
505
|
|
|
490
506
|
if final_result_event is not None:
|
|
491
507
|
final_result = FinalResult(
|
|
492
|
-
|
|
508
|
+
None, final_result_event.tool_name, final_result_event.tool_call_id
|
|
493
509
|
)
|
|
494
510
|
if yielded:
|
|
495
511
|
raise exceptions.AgentRunError('Agent run produced final results') # pragma: no cover
|
|
@@ -503,16 +519,15 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
503
519
|
The model response will have been added to messages by now
|
|
504
520
|
by `StreamedRunResult._marked_completed`.
|
|
505
521
|
"""
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
]
|
|
522
|
+
nonlocal final_result
|
|
523
|
+
final_result = FinalResult(
|
|
524
|
+
await stream.get_output(), final_result.tool_name, final_result.tool_call_id
|
|
525
|
+
)
|
|
511
526
|
|
|
512
527
|
parts: list[_messages.ModelRequestPart] = []
|
|
513
528
|
async for _event in _agent_graph.process_tool_calls(
|
|
514
529
|
tool_manager=graph_ctx.deps.tool_manager,
|
|
515
|
-
tool_calls=tool_calls,
|
|
530
|
+
tool_calls=stream.response.tool_calls,
|
|
516
531
|
tool_call_results=None,
|
|
517
532
|
final_result=final_result,
|
|
518
533
|
ctx=graph_ctx,
|
|
@@ -560,7 +575,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
560
575
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
561
576
|
*,
|
|
562
577
|
output_type: None = None,
|
|
563
|
-
message_history:
|
|
578
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
564
579
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
565
580
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
566
581
|
deps: AgentDepsT = None,
|
|
@@ -569,6 +584,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
569
584
|
usage: _usage.RunUsage | None = None,
|
|
570
585
|
infer_name: bool = True,
|
|
571
586
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
587
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
572
588
|
) -> AsyncIterator[_messages.AgentStreamEvent | AgentRunResultEvent[OutputDataT]]: ...
|
|
573
589
|
|
|
574
590
|
@overload
|
|
@@ -577,7 +593,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
577
593
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
578
594
|
*,
|
|
579
595
|
output_type: OutputSpec[RunOutputDataT],
|
|
580
|
-
message_history:
|
|
596
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
581
597
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
582
598
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
583
599
|
deps: AgentDepsT = None,
|
|
@@ -586,6 +602,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
586
602
|
usage: _usage.RunUsage | None = None,
|
|
587
603
|
infer_name: bool = True,
|
|
588
604
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
605
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
589
606
|
) -> AsyncIterator[_messages.AgentStreamEvent | AgentRunResultEvent[RunOutputDataT]]: ...
|
|
590
607
|
|
|
591
608
|
def run_stream_events(
|
|
@@ -593,7 +610,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
593
610
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
594
611
|
*,
|
|
595
612
|
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
596
|
-
message_history:
|
|
613
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
597
614
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
598
615
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
599
616
|
deps: AgentDepsT = None,
|
|
@@ -602,6 +619,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
602
619
|
usage: _usage.RunUsage | None = None,
|
|
603
620
|
infer_name: bool = True,
|
|
604
621
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
622
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
605
623
|
) -> AsyncIterator[_messages.AgentStreamEvent | AgentRunResultEvent[Any]]:
|
|
606
624
|
"""Run the agent with a user prompt in async mode and stream events from the run.
|
|
607
625
|
|
|
@@ -647,6 +665,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
647
665
|
usage: Optional usage to start with, useful for resuming a conversation or agents used in tools.
|
|
648
666
|
infer_name: Whether to try to infer the agent name from the call frame if it's not set.
|
|
649
667
|
toolsets: Optional additional toolsets for this run.
|
|
668
|
+
builtin_tools: Optional additional builtin tools for this run.
|
|
650
669
|
|
|
651
670
|
Returns:
|
|
652
671
|
An async iterable of stream events `AgentStreamEvent` and finally a `AgentRunResultEvent` with the final
|
|
@@ -667,6 +686,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
667
686
|
usage=usage,
|
|
668
687
|
infer_name=infer_name,
|
|
669
688
|
toolsets=toolsets,
|
|
689
|
+
builtin_tools=builtin_tools,
|
|
670
690
|
)
|
|
671
691
|
|
|
672
692
|
async def _run_stream_events(
|
|
@@ -674,7 +694,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
674
694
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
675
695
|
*,
|
|
676
696
|
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
677
|
-
message_history:
|
|
697
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
678
698
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
679
699
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
680
700
|
deps: AgentDepsT = None,
|
|
@@ -683,6 +703,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
683
703
|
usage: _usage.RunUsage | None = None,
|
|
684
704
|
infer_name: bool = True,
|
|
685
705
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
706
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
686
707
|
) -> AsyncIterator[_messages.AgentStreamEvent | AgentRunResultEvent[Any]]:
|
|
687
708
|
send_stream, receive_stream = anyio.create_memory_object_stream[
|
|
688
709
|
_messages.AgentStreamEvent | AgentRunResultEvent[Any]
|
|
@@ -708,6 +729,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
708
729
|
usage=usage,
|
|
709
730
|
infer_name=infer_name,
|
|
710
731
|
toolsets=toolsets,
|
|
732
|
+
builtin_tools=builtin_tools,
|
|
711
733
|
event_stream_handler=event_stream_handler,
|
|
712
734
|
)
|
|
713
735
|
|
|
@@ -726,7 +748,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
726
748
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
727
749
|
*,
|
|
728
750
|
output_type: None = None,
|
|
729
|
-
message_history:
|
|
751
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
730
752
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
731
753
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
732
754
|
deps: AgentDepsT = None,
|
|
@@ -735,6 +757,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
735
757
|
usage: _usage.RunUsage | None = None,
|
|
736
758
|
infer_name: bool = True,
|
|
737
759
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
760
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
738
761
|
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, OutputDataT]]: ...
|
|
739
762
|
|
|
740
763
|
@overload
|
|
@@ -743,7 +766,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
743
766
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
744
767
|
*,
|
|
745
768
|
output_type: OutputSpec[RunOutputDataT],
|
|
746
|
-
message_history:
|
|
769
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
747
770
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
748
771
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
749
772
|
deps: AgentDepsT = None,
|
|
@@ -752,6 +775,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
752
775
|
usage: _usage.RunUsage | None = None,
|
|
753
776
|
infer_name: bool = True,
|
|
754
777
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
778
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
755
779
|
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, RunOutputDataT]]: ...
|
|
756
780
|
|
|
757
781
|
@asynccontextmanager
|
|
@@ -761,7 +785,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
761
785
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
762
786
|
*,
|
|
763
787
|
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
764
|
-
message_history:
|
|
788
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
765
789
|
deferred_tool_results: DeferredToolResults | None = None,
|
|
766
790
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
767
791
|
deps: AgentDepsT = None,
|
|
@@ -770,6 +794,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
770
794
|
usage: _usage.RunUsage | None = None,
|
|
771
795
|
infer_name: bool = True,
|
|
772
796
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
797
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
773
798
|
) -> AsyncIterator[AgentRun[AgentDepsT, Any]]:
|
|
774
799
|
"""A contextmanager which can be used to iterate over the agent graph's nodes as they are executed.
|
|
775
800
|
|
|
@@ -842,6 +867,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
842
867
|
usage: Optional usage to start with, useful for resuming a conversation or agents used in tools.
|
|
843
868
|
infer_name: Whether to try to infer the agent name from the call frame if it's not set.
|
|
844
869
|
toolsets: Optional additional toolsets for this run.
|
|
870
|
+
builtin_tools: Optional additional builtin tools for this run.
|
|
845
871
|
|
|
846
872
|
Returns:
|
|
847
873
|
The result of the run.
|
|
@@ -854,18 +880,20 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
854
880
|
def override(
|
|
855
881
|
self,
|
|
856
882
|
*,
|
|
883
|
+
name: str | _utils.Unset = _utils.UNSET,
|
|
857
884
|
deps: AgentDepsT | _utils.Unset = _utils.UNSET,
|
|
858
885
|
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
|
|
859
886
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
|
|
860
887
|
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
|
|
861
888
|
instructions: Instructions[AgentDepsT] | _utils.Unset = _utils.UNSET,
|
|
862
889
|
) -> Iterator[None]:
|
|
863
|
-
"""Context manager to temporarily override agent dependencies, model, toolsets, tools, or instructions.
|
|
890
|
+
"""Context manager to temporarily override agent name, dependencies, model, toolsets, tools, or instructions.
|
|
864
891
|
|
|
865
892
|
This is particularly useful when testing.
|
|
866
893
|
You can find an example of this [here](../testing.md#overriding-model-via-pytest-fixtures).
|
|
867
894
|
|
|
868
895
|
Args:
|
|
896
|
+
name: The name to use instead of the name passed to the agent constructor and agent run.
|
|
869
897
|
deps: The dependencies to use instead of the dependencies passed to the agent run.
|
|
870
898
|
model: The model to use instead of the model passed to the agent run.
|
|
871
899
|
toolsets: The toolsets to use instead of the toolsets passed to the agent constructor and agent run.
|
|
@@ -1112,7 +1140,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
1112
1140
|
self: Self,
|
|
1113
1141
|
deps: AgentDepsT = None,
|
|
1114
1142
|
prog_name: str = 'pydantic-ai',
|
|
1115
|
-
message_history:
|
|
1143
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
1116
1144
|
) -> None:
|
|
1117
1145
|
"""Run the agent in a CLI chat interface.
|
|
1118
1146
|
|
|
@@ -1149,7 +1177,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
1149
1177
|
self: Self,
|
|
1150
1178
|
deps: AgentDepsT = None,
|
|
1151
1179
|
prog_name: str = 'pydantic-ai',
|
|
1152
|
-
message_history:
|
|
1180
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
1153
1181
|
) -> None:
|
|
1154
1182
|
"""Run the agent in a CLI chat interface with the non-async interface.
|
|
1155
1183
|
|