deepagents 0.0.12rc1__tar.gz → 0.0.12rc3__tar.gz

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.
Files changed (35) hide show
  1. deepagents-0.0.12rc3/PKG-INFO +533 -0
  2. deepagents-0.0.12rc3/README.md +512 -0
  3. deepagents-0.0.12rc3/pyproject.toml +96 -0
  4. deepagents-0.0.12rc3/src/deepagents/__init__.py +7 -0
  5. deepagents-0.0.12rc3/src/deepagents/graph.py +143 -0
  6. deepagents-0.0.12rc3/src/deepagents/middleware/__init__.py +6 -0
  7. deepagents-0.0.12rc3/src/deepagents/middleware/filesystem.py +1118 -0
  8. deepagents-0.0.12rc3/src/deepagents/middleware/subagents.py +479 -0
  9. deepagents-0.0.12rc3/src/deepagents.egg-info/PKG-INFO +533 -0
  10. deepagents-0.0.12rc3/src/deepagents.egg-info/SOURCES.txt +14 -0
  11. deepagents-0.0.12rc3/src/deepagents.egg-info/requires.txt +12 -0
  12. {deepagents-0.0.12rc1 → deepagents-0.0.12rc3/src}/deepagents.egg-info/top_level.txt +0 -1
  13. deepagents-0.0.12rc3/tests/test_middleware.py +173 -0
  14. deepagents-0.0.12rc1/PKG-INFO +0 -454
  15. deepagents-0.0.12rc1/README.md +0 -434
  16. deepagents-0.0.12rc1/deepagents.egg-info/PKG-INFO +0 -454
  17. deepagents-0.0.12rc1/deepagents.egg-info/SOURCES.txt +0 -21
  18. deepagents-0.0.12rc1/deepagents.egg-info/requires.txt +0 -11
  19. deepagents-0.0.12rc1/pyproject.toml +0 -35
  20. deepagents-0.0.12rc1/src/deepagents/__init__.py +0 -5
  21. deepagents-0.0.12rc1/src/deepagents/graph.py +0 -160
  22. deepagents-0.0.12rc1/src/deepagents/middleware.py +0 -216
  23. deepagents-0.0.12rc1/src/deepagents/model.py +0 -5
  24. deepagents-0.0.12rc1/src/deepagents/prompts.py +0 -429
  25. deepagents-0.0.12rc1/src/deepagents/state.py +0 -33
  26. deepagents-0.0.12rc1/src/deepagents/tools.py +0 -313
  27. deepagents-0.0.12rc1/src/deepagents/types.py +0 -21
  28. deepagents-0.0.12rc1/tests/test_deepagents.py +0 -136
  29. deepagents-0.0.12rc1/tests/test_filesystem.py +0 -196
  30. deepagents-0.0.12rc1/tests/test_hitl.py +0 -51
  31. deepagents-0.0.12rc1/tests/test_middleware.py +0 -57
  32. deepagents-0.0.12rc1/tests/utils.py +0 -81
  33. {deepagents-0.0.12rc1 → deepagents-0.0.12rc3}/LICENSE +0 -0
  34. {deepagents-0.0.12rc1 → deepagents-0.0.12rc3}/setup.cfg +0 -0
  35. {deepagents-0.0.12rc1 → deepagents-0.0.12rc3/src}/deepagents.egg-info/dependency_links.txt +0 -0
@@ -0,0 +1,533 @@
1
+ Metadata-Version: 2.4
2
+ Name: deepagents
3
+ Version: 0.0.12rc3
4
+ Summary: General purpose 'deep agent' with sub-agent spawning, todo list capabilities, and mock file system. Built on LangGraph.
5
+ License: MIT
6
+ Requires-Python: <4.0,>=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: langgraph==1.0.0a4
10
+ Requires-Dist: langchain-anthropic==1.0.0a5
11
+ Requires-Dist: langchain==1.0.0rc2
12
+ Requires-Dist: langgraph-prebuilt==0.7.0a2
13
+ Requires-Dist: langchain-core==1.0.0rc3
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == "dev"
16
+ Requires-Dist: pytest-cov; extra == "dev"
17
+ Requires-Dist: build; extra == "dev"
18
+ Requires-Dist: twine; extra == "dev"
19
+ Requires-Dist: langchain-openai; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # 🧠🤖Deep Agents
23
+
24
+ Using an LLM to call tools in a loop is the simplest form of an agent.
25
+ This architecture, however, can yield agents that are “shallow” and fail to plan and act over longer, more complex tasks.
26
+
27
+ Applications like “Deep Research”, "Manus", and “Claude Code” have gotten around this limitation by implementing a combination of four things:
28
+ a **planning tool**, **sub agents**, access to a **file system**, and a **detailed prompt**.
29
+
30
+ <img src="deep_agents.png" alt="deep agent" width="600"/>
31
+
32
+ `deepagents` is a Python package that implements these in a general purpose way so that you can easily create a Deep Agent for your application.
33
+
34
+ **Acknowledgements: This project was primarily inspired by Claude Code, and initially was largely an attempt to see what made Claude Code general purpose, and make it even more so.**
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ # pip
40
+ pip install deepagents
41
+
42
+ # uv
43
+ uv add deepagents
44
+
45
+ # poetry
46
+ poetry add deepagents
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ (To run the example below, you will need to `pip install tavily-python`).
52
+
53
+ Make sure to set `TAVILY_API_KEY` in your environment. You can generate one [here](https://www.tavily.com/).
54
+
55
+ ```python
56
+ import os
57
+ from typing import Literal
58
+ from tavily import TavilyClient
59
+ from deepagents import create_deep_agent
60
+
61
+ tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
62
+
63
+ # Web search tool
64
+ def internet_search(
65
+ query: str,
66
+ max_results: int = 5,
67
+ topic: Literal["general", "news", "finance"] = "general",
68
+ include_raw_content: bool = False,
69
+ ):
70
+ """Run a web search"""
71
+ return tavily_client.search(
72
+ query,
73
+ max_results=max_results,
74
+ include_raw_content=include_raw_content,
75
+ topic=topic,
76
+ )
77
+
78
+
79
+ # System prompt to steer the agent to be an expert researcher
80
+ research_instructions = """You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.
81
+
82
+ You have access to an internet search tool as your primary means of gathering information.
83
+
84
+ ## `internet_search`
85
+
86
+ Use this to run an internet search for a given query. You can specify the max number of results to return, the topic, and whether raw content should be included.
87
+ """
88
+
89
+ # Create the deep agent
90
+ agent = create_deep_agent(
91
+ tools=[internet_search],
92
+ system_prompt=research_instructions,
93
+ )
94
+
95
+ # Invoke the agent
96
+ result = agent.invoke({"messages": [{"role": "user", "content": "What is langgraph?"}]})
97
+ ```
98
+
99
+ See [examples/research/research_agent.py](examples/research/research_agent.py) for a more complex example.
100
+
101
+ The agent created with `create_deep_agent` is just a LangGraph graph - so you can interact with it (streaming, human-in-the-loop, memory, studio)
102
+ in the same way you would any LangGraph agent.
103
+
104
+ ## Core Capabilities
105
+ **Planning & Task Decomposition**
106
+
107
+ Deep Agents include a built-in `write_todos` tool that enables agents to break down complex tasks into discrete steps, track progress, and adapt plans as new information emerges.
108
+
109
+ **Context Management**
110
+
111
+ File system tools (`ls`, `read_file`, `write_file`, `edit_file`) allow agents to offload large context to memory, preventing context window overflow and enabling work with variable-length tool results.
112
+
113
+ **Subagent Spawning**
114
+
115
+ A built-in `task` tool enables agents to spawn specialized subagents for context isolation. This keeps the main agent’s context clean while still going deep on specific subtasks.
116
+
117
+ **Long-term Memory**
118
+
119
+ Extend agents with persistent memory across threads using LangGraph’s Store. Agents can save and retrieve information from previous conversations.
120
+
121
+ ## Customizing Deep Agents
122
+
123
+ There are several parameters you can pass to `create_deep_agent` to create your own custom deep agent.
124
+
125
+ ### `model`
126
+
127
+ By default, `deepagents` uses `"claude-sonnet-4-5-20250929"`. You can customize this by passing any [LangChain model object](https://python.langchain.com/docs/integrations/chat/).
128
+
129
+ ```python
130
+ from langchain.chat_models import init_chat_model
131
+ from deepagents import create_deep_agent
132
+
133
+ model = init_chat_model(
134
+ model="openai:gpt-5",
135
+ )
136
+ agent = create_deep_agent(
137
+ model=model,
138
+ )
139
+ ```
140
+
141
+ ### `system_prompt`
142
+ Deep Agents come with a built-in system prompt. This is relatively detailed prompt that is heavily based on and inspired by [attempts](https://github.com/kn1026/cc/blob/main/claudecode.md) to [replicate](https://github.com/asgeirtj/system_prompts_leaks/blob/main/Anthropic/claude-code.md)
143
+ Claude Code's system prompt. It was made more general purpose than Claude Code's system prompt. The default prompt contains detailed instructions for how to use the built-in planning tool, file system tools, and sub agents.
144
+
145
+ Each deep agent tailored to a use case should include a custom system prompt specific to that use case as well. The importance of prompting for creating a successful deep agent cannot be overstated.
146
+
147
+ ```python
148
+ from deepagents import create_deep_agent
149
+
150
+ research_instructions = """You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.
151
+ """
152
+
153
+ agent = create_deep_agent(
154
+ system_prompt=research_instructions,
155
+ )
156
+ ```
157
+
158
+ ### `tools`
159
+
160
+ Just like with tool-calling agents, you can provide a deep agent with a set of tools that it has access to.
161
+
162
+ ```python
163
+ import os
164
+ from typing import Literal
165
+ from tavily import TavilyClient
166
+ from deepagents import create_deep_agent
167
+
168
+ tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
169
+
170
+ def internet_search(
171
+ query: str,
172
+ max_results: int = 5,
173
+ topic: Literal["general", "news", "finance"] = "general",
174
+ include_raw_content: bool = False,
175
+ ):
176
+ """Run a web search"""
177
+ return tavily_client.search(
178
+ query,
179
+ max_results=max_results,
180
+ include_raw_content=include_raw_content,
181
+ topic=topic,
182
+ )
183
+
184
+ agent = create_deep_agent(
185
+ tools=[internet_search]
186
+ )
187
+ ```
188
+
189
+ ### `middleware`
190
+ `create_deep_agent` is implemented with middleware that can be customized. You can provide additional middleware to extend functionality, add tools, or implement custom hooks.
191
+
192
+ ```python
193
+ from langchain_core.tools import tool
194
+ from deepagents import create_deep_agent
195
+ from langchain.agents.middleware import AgentMiddleware
196
+
197
+ @tool
198
+ def get_weather(city: str) -> str:
199
+ """Get the weather in a city."""
200
+ return f"The weather in {city} is sunny."
201
+
202
+ @tool
203
+ def get_temperature(city: str) -> str:
204
+ """Get the temperature in a city."""
205
+ return f"The temperature in {city} is 70 degrees Fahrenheit."
206
+
207
+ class WeatherMiddleware(AgentMiddleware):
208
+ tools = [get_weather, get_temperature]
209
+
210
+ agent = create_deep_agent(
211
+ model="anthropic:claude-sonnet-4-20250514",
212
+ middleware=[WeatherMiddleware()]
213
+ )
214
+ ```
215
+
216
+ ### `subagents`
217
+
218
+ A main feature of Deep Agents is their ability to spawn subagents. You can specify custom subagents that your agent can hand off work to in the subagents parameter. Sub agents are useful for context quarantine (to help not pollute the overall context of the main agent) as well as custom instructions.
219
+
220
+ `subagents` should be a list of dictionaries, where each dictionary follow this schema:
221
+
222
+ ```python
223
+ class SubAgent(TypedDict):
224
+ name: str
225
+ description: str
226
+ prompt: str
227
+ tools: Sequence[BaseTool | Callable | dict[str, Any]]
228
+ model: NotRequired[str | BaseChatModel]
229
+ middleware: NotRequired[list[AgentMiddleware]]
230
+ interrupt_on: NotRequired[dict[str, bool | InterruptOnConfig]]
231
+
232
+ class CompiledSubAgent(TypedDict):
233
+ name: str
234
+ description: str
235
+ runnable: Runnable
236
+ ```
237
+
238
+ **SubAgent fields:**
239
+ - **name**: This is the name of the subagent, and how the main agent will call the subagent
240
+ - **description**: This is the description of the subagent that is shown to the main agent
241
+ - **prompt**: This is the prompt used for the subagent
242
+ - **tools**: This is the list of tools that the subagent has access to.
243
+ - **model**: Optional model name or model instance.
244
+ - **middleware** Additional middleware to attach to the subagent. See [here](https://docs.langchain.com/oss/python/langchain/middleware) for an introduction into middleware and how it works with create_agent.
245
+ - **interrupt_on** A custom interrupt config that specifies human-in-the-loop interactions for your tools.
246
+
247
+ **CompiledSubAgent fields:**
248
+ - **name**: This is the name of the subagent, and how the main agent will call the subagent
249
+ - **description**: This is the description of the subagent that is shown to the main agent
250
+ - **runnable**: A pre-built LangGraph graph/agent that will be used as the subagent
251
+
252
+ #### Using SubAgent
253
+
254
+ ```python
255
+ import os
256
+ from typing import Literal
257
+ from tavily import TavilyClient
258
+ from deepagents import create_deep_agent
259
+
260
+ tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
261
+
262
+ def internet_search(
263
+ query: str,
264
+ max_results: int = 5,
265
+ topic: Literal["general", "news", "finance"] = "general",
266
+ include_raw_content: bool = False,
267
+ ):
268
+ """Run a web search"""
269
+ return tavily_client.search(
270
+ query,
271
+ max_results=max_results,
272
+ include_raw_content=include_raw_content,
273
+ topic=topic,
274
+ )
275
+
276
+ research_subagent = {
277
+ "name": "research-agent",
278
+ "description": "Used to research more in depth questions",
279
+ "system_prompt": "You are a great researcher",
280
+ "tools": [internet_search],
281
+ "model": "openai:gpt-4o", # Optional override, defaults to main agent model
282
+ }
283
+ subagents = [research_subagent]
284
+
285
+ agent = create_deep_agent(
286
+ model="anthropic:claude-sonnet-4-20250514",
287
+ subagents=subagents
288
+ )
289
+ ```
290
+
291
+ #### Using CustomSubAgent
292
+
293
+ For more complex use cases, you can provide your own pre-built LangGraph graph as a subagent:
294
+
295
+ ```python
296
+ # Create a custom agent graph
297
+ custom_graph = create_agent(
298
+ model=your_model,
299
+ tools=specialized_tools,
300
+ prompt="You are a specialized agent for data analysis..."
301
+ )
302
+
303
+ # Use it as a custom subagent
304
+ custom_subagent = CompiledSubAgent(
305
+ name="data-analyzer",
306
+ description="Specialized agent for complex data analysis tasks",
307
+ runnable=custom_graph
308
+ )
309
+
310
+ subagents = [custom_subagent]
311
+
312
+ agent = create_deep_agent(
313
+ model="anthropic:claude-sonnet-4-20250514",
314
+ tools=[internet_search],
315
+ system_prompt=research_instructions,
316
+ subagents=subagents
317
+ )
318
+ ```
319
+
320
+ ### `use_longterm_memory`
321
+ Deep agents come with a local filesystem to offload memory to. This filesystem is stored in state, and is therefore transient to a single thread.
322
+
323
+ You can extend deep agents with long-term memory by providing a Store and setting use_longterm_memory=True.
324
+
325
+ ```python
326
+ from deepagents import create_deep_agent
327
+ from langgraph.store.memory import InMemoryStore
328
+
329
+ store = InMemoryStore() # Or any other Store object
330
+ agent = create_deep_agent(
331
+ store=store,
332
+ use_longterm_memory=True
333
+ )
334
+ ```
335
+
336
+ ### `interrupt_on`
337
+ A common reality for agents is that some tool operations may be sensitive and require human approval before execution. Deep Agents supports human-in-the-loop workflows through LangGraph’s interrupt capabilities. You can configure which tools require approval using a checkpointer.
338
+
339
+ These tool configs are passed to our prebuilt [HITL middleware](https://docs.langchain.com/oss/python/langchain/middleware#human-in-the-loop) so that the agent pauses execution and waits for feedback from the user before executing configured tools.
340
+
341
+ ```python
342
+ from langchain_core.tools import tool
343
+ from deepagents import create_deep_agent
344
+
345
+ @tool
346
+ def get_weather(city: str) -> str:
347
+ """Get the weather in a city."""
348
+ return f"The weather in {city} is sunny."
349
+
350
+ agent = create_deep_agent(
351
+ model="anthropic:claude-sonnet-4-20250514",
352
+ tools=[get_weather],
353
+ interrupt_on={
354
+ "get_weather": {
355
+ "allowed_decisions": ["approve", "edit", "reject"]
356
+ },
357
+ }
358
+ )
359
+
360
+ ```
361
+
362
+ ## Deep Agents Middleware
363
+
364
+ Deep Agents are built with a modular middleware architecture. As a reminder, Deep Agents have access to:
365
+ - A planning tool
366
+ - A filesystem for storing context and long-term memories
367
+ - The ability to spawn subagents
368
+
369
+ Each of these features is implemented as separate middleware. When you create a deep agent with `create_deep_agent`, we automatically attach **PlanningMiddleware**, **FilesystemMiddleware** and **SubAgentMiddleware** to your agent.
370
+
371
+ Middleware is a composable concept, and you can choose to add as many or as few middleware to an agent depending on your use case. That means that you can also use any of the aforementioned middleware independently!
372
+
373
+ ### TodoListMiddleware
374
+
375
+ Planning is integral to solving complex problems. If you’ve used claude code recently, you’ll notice how it writes out a To-Do list before tackling complex, multi-part tasks. You’ll also notice how it can adapt and update this To-Do list on the fly as more information comes in.
376
+
377
+ **TodoListMiddleware** provides your agent with a tool specifically for updating this To-Do list. Before, and while it executes a multi-part task, the agent is prompted to use the write_todos tool to keep track of what its doing, and what still needs to be done.
378
+
379
+ ```python
380
+ from langchain.agents import create_agent
381
+ from langchain.agents.middleware import TodoListMiddleware
382
+
383
+ # TodoListMiddleware is included by default in create_deep_agent
384
+ # You can customize it if building a custom agent
385
+ agent = create_agent(
386
+ model="anthropic:claude-sonnet-4-20250514",
387
+ # Custom planning instructions can be added via middleware
388
+ middleware=[
389
+ TodoListMiddleware(
390
+ system_prompt="Use the write_todos tool to..." # Optional: Custom addition to the system prompt
391
+ ),
392
+ ],
393
+ )
394
+ ```
395
+
396
+ ### FilesystemMiddleware
397
+
398
+ Context engineering is one of the main challenges in building effective agents. This can be particularly hard when using tools that can return variable length results (ex. web_search, rag), as long ToolResults can quickly fill up your context window.
399
+ **FilesystemMiddleware** provides four tools to your agent to interact with both short-term and long-term memory.
400
+ - **ls**: List the files in your filesystem
401
+ - **read_file**: Read an entire file, or a certain number of lines from a file
402
+ - **write_file**: Write a new file to your filesystem
403
+ - **edit_file**: Edit an existing file in your filesystem
404
+
405
+ ```python
406
+ from langchain.agents import create_agent
407
+ from deepagents.middleware.filesystem import FilesystemMiddleware
408
+
409
+ # FilesystemMiddleware is included by default in create_deep_agent
410
+ # You can customize it if building a custom agent
411
+ agent = create_agent(
412
+ model="anthropic:claude-sonnet-4-20250514",
413
+ middleware=[
414
+ FilesystemMiddleware(
415
+ long_term_memory=False, # Enables access to long-term memory, defaults to False. You must attach a store to use long-term memory.
416
+ system_prompt="Write to the filesystem when...", # Optional custom addition to the system prompt
417
+ custom_tool_descriptions={
418
+ "ls": "Use the ls tool when...",
419
+ "read_file": "Use the read_file tool to..."
420
+ } # Optional: Custom descriptions for filesystem tools
421
+ ),
422
+ ],
423
+ )
424
+ ```
425
+
426
+ ### SubAgentMiddleware
427
+
428
+ Handing off tasks to subagents is a great way to isolate context, keeping the context window of the main (supervisor) agent clean while still going deep on a task. The subagents middleware allows you supply subagents through a task tool.
429
+
430
+ A subagent is defined with a name, description, system prompt, and tools. You can also provide a subagent with a custom model, or with additional middleware. This can be particularly useful when you want to give the subagent an additional state key to share with the main agent.
431
+
432
+ ```python
433
+ from langchain_core.tools import tool
434
+ from langchain.agents import create_agent
435
+ from deepagents.middleware.subagents import SubAgentMiddleware
436
+
437
+
438
+ @tool
439
+ def get_weather(city: str) -> str:
440
+ """Get the weather in a city."""
441
+ return f"The weather in {city} is sunny."
442
+
443
+ agent = create_agent(
444
+ model="claude-sonnet-4-20250514",
445
+ middleware=[
446
+ SubAgentMiddleware(
447
+ default_model="claude-sonnet-4-20250514",
448
+ default_tools=[],
449
+ subagents=[
450
+ {
451
+ "name": "weather",
452
+ "description": "This subagent can get weather in cities.",
453
+ "system_prompt": "Use the get_weather tool to get the weather in a city.",
454
+ "tools": [get_weather],
455
+ "model": "gpt-4.1",
456
+ "middleware": [],
457
+ }
458
+ ],
459
+ )
460
+ ],
461
+ )
462
+ ```
463
+
464
+ For more complex use cases, you can also provide your own pre-built LangGraph graph as a subagent.
465
+
466
+ ```python
467
+ # Create a custom LangGraph graph
468
+ def create_weather_graph():
469
+ workflow = StateGraph(...)
470
+ # Build your custom graph
471
+ return workflow.compile()
472
+
473
+ weather_graph = create_weather_graph()
474
+
475
+ # Wrap it in a CompiledSubAgent
476
+ weather_subagent = CompiledSubAgent(
477
+ name="weather",
478
+ description="This subagent can get weather in cities.",
479
+ runnable=weather_graph
480
+ )
481
+
482
+ agent = create_agent(
483
+ model="anthropic:claude-sonnet-4-20250514",
484
+ middleware=[
485
+ SubAgentMiddleware(
486
+ default_model="claude-sonnet-4-20250514",
487
+ default_tools=[],
488
+ subagents=[weather_subagent],
489
+ )
490
+ ],
491
+ )
492
+ ```
493
+
494
+ ## Sync vs Async
495
+
496
+ Prior versions of deepagents separated sync and async agent factories.
497
+
498
+ `async_create_deep_agent` has been folded in to `create_deep_agent`.
499
+
500
+ **You should use `create_deep_agent` as the factory for both sync and async agents**
501
+
502
+
503
+ ## MCP
504
+
505
+ The `deepagents` library can be ran with MCP tools. This can be achieved by using the [Langchain MCP Adapter library](https://github.com/langchain-ai/langchain-mcp-adapters).
506
+
507
+ **NOTE:** You will want to use `from deepagents import async_create_deep_agent` to use the async version of `deepagents`, since MCP tools are async
508
+
509
+ (To run the example below, will need to `pip install langchain-mcp-adapters`)
510
+
511
+ ```python
512
+ import asyncio
513
+ from langchain_mcp_adapters.client import MultiServerMCPClient
514
+ from deepagents import create_deep_agent
515
+
516
+ async def main():
517
+ # Collect MCP tools
518
+ mcp_client = MultiServerMCPClient(...)
519
+ mcp_tools = await mcp_client.get_tools()
520
+
521
+ # Create agent
522
+ agent = create_deep_agent(tools=mcp_tools, ....)
523
+
524
+ # Stream the agent
525
+ async for chunk in agent.astream(
526
+ {"messages": [{"role": "user", "content": "what is langgraph?"}]},
527
+ stream_mode="values"
528
+ ):
529
+ if "messages" in chunk:
530
+ chunk["messages"][-1].pretty_print()
531
+
532
+ asyncio.run(main())
533
+ ```