agno 2.2.9__py3-none-any.whl → 2.2.10__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.
- agno/agent/agent.py +14 -4
- agno/os/app.py +15 -15
- agno/team/team.py +7 -2
- agno/workflow/agent.py +2 -2
- agno/workflow/condition.py +26 -4
- agno/workflow/loop.py +9 -0
- agno/workflow/parallel.py +39 -16
- agno/workflow/router.py +25 -4
- agno/workflow/step.py +162 -91
- agno/workflow/steps.py +9 -0
- agno/workflow/workflow.py +26 -22
- {agno-2.2.9.dist-info → agno-2.2.10.dist-info}/METADATA +1 -1
- {agno-2.2.9.dist-info → agno-2.2.10.dist-info}/RECORD +16 -16
- {agno-2.2.9.dist-info → agno-2.2.10.dist-info}/WHEEL +0 -0
- {agno-2.2.9.dist-info → agno-2.2.10.dist-info}/licenses/LICENSE +0 -0
- {agno-2.2.9.dist-info → agno-2.2.10.dist-info}/top_level.txt +0 -0
agno/agent/agent.py
CHANGED
|
@@ -1454,6 +1454,7 @@ class Agent:
|
|
|
1454
1454
|
user_id: Optional[str] = None,
|
|
1455
1455
|
session_id: Optional[str] = None,
|
|
1456
1456
|
session_state: Optional[Dict[str, Any]] = None,
|
|
1457
|
+
run_context: Optional[RunContext] = None,
|
|
1457
1458
|
audio: Optional[Sequence[Audio]] = None,
|
|
1458
1459
|
images: Optional[Sequence[Image]] = None,
|
|
1459
1460
|
videos: Optional[Sequence[Video]] = None,
|
|
@@ -1480,6 +1481,7 @@ class Agent:
|
|
|
1480
1481
|
user_id: Optional[str] = None,
|
|
1481
1482
|
session_id: Optional[str] = None,
|
|
1482
1483
|
session_state: Optional[Dict[str, Any]] = None,
|
|
1484
|
+
run_context: Optional[RunContext] = None,
|
|
1483
1485
|
audio: Optional[Sequence[Audio]] = None,
|
|
1484
1486
|
images: Optional[Sequence[Image]] = None,
|
|
1485
1487
|
videos: Optional[Sequence[Video]] = None,
|
|
@@ -1507,6 +1509,7 @@ class Agent:
|
|
|
1507
1509
|
user_id: Optional[str] = None,
|
|
1508
1510
|
session_id: Optional[str] = None,
|
|
1509
1511
|
session_state: Optional[Dict[str, Any]] = None,
|
|
1512
|
+
run_context: Optional[RunContext] = None,
|
|
1510
1513
|
audio: Optional[Sequence[Audio]] = None,
|
|
1511
1514
|
images: Optional[Sequence[Image]] = None,
|
|
1512
1515
|
videos: Optional[Sequence[Video]] = None,
|
|
@@ -1581,7 +1584,7 @@ class Agent:
|
|
|
1581
1584
|
dependencies = dependencies if dependencies is not None else self.dependencies
|
|
1582
1585
|
|
|
1583
1586
|
# Initialize run context
|
|
1584
|
-
run_context = RunContext(
|
|
1587
|
+
run_context = run_context or RunContext(
|
|
1585
1588
|
run_id=run_id,
|
|
1586
1589
|
session_id=session_id,
|
|
1587
1590
|
user_id=user_id,
|
|
@@ -2374,6 +2377,7 @@ class Agent:
|
|
|
2374
2377
|
user_id: Optional[str] = None,
|
|
2375
2378
|
session_id: Optional[str] = None,
|
|
2376
2379
|
session_state: Optional[Dict[str, Any]] = None,
|
|
2380
|
+
run_context: Optional[RunContext] = None,
|
|
2377
2381
|
audio: Optional[Sequence[Audio]] = None,
|
|
2378
2382
|
images: Optional[Sequence[Image]] = None,
|
|
2379
2383
|
videos: Optional[Sequence[Video]] = None,
|
|
@@ -2399,6 +2403,7 @@ class Agent:
|
|
|
2399
2403
|
stream: Literal[True] = True,
|
|
2400
2404
|
user_id: Optional[str] = None,
|
|
2401
2405
|
session_id: Optional[str] = None,
|
|
2406
|
+
run_context: Optional[RunContext] = None,
|
|
2402
2407
|
audio: Optional[Sequence[Audio]] = None,
|
|
2403
2408
|
images: Optional[Sequence[Image]] = None,
|
|
2404
2409
|
videos: Optional[Sequence[Video]] = None,
|
|
@@ -2426,6 +2431,7 @@ class Agent:
|
|
|
2426
2431
|
user_id: Optional[str] = None,
|
|
2427
2432
|
session_id: Optional[str] = None,
|
|
2428
2433
|
session_state: Optional[Dict[str, Any]] = None,
|
|
2434
|
+
run_context: Optional[RunContext] = None,
|
|
2429
2435
|
audio: Optional[Sequence[Audio]] = None,
|
|
2430
2436
|
images: Optional[Sequence[Image]] = None,
|
|
2431
2437
|
videos: Optional[Sequence[Video]] = None,
|
|
@@ -2530,7 +2536,7 @@ class Agent:
|
|
|
2530
2536
|
merge_dictionaries(metadata, self.metadata)
|
|
2531
2537
|
|
|
2532
2538
|
# Initialize run context
|
|
2533
|
-
run_context = RunContext(
|
|
2539
|
+
run_context = run_context or RunContext(
|
|
2534
2540
|
run_id=run_id,
|
|
2535
2541
|
session_id=session_id,
|
|
2536
2542
|
user_id=user_id,
|
|
@@ -2692,6 +2698,7 @@ class Agent:
|
|
|
2692
2698
|
stream_intermediate_steps: Optional[bool] = None,
|
|
2693
2699
|
user_id: Optional[str] = None,
|
|
2694
2700
|
session_id: Optional[str] = None,
|
|
2701
|
+
run_context: Optional[RunContext] = None,
|
|
2695
2702
|
retries: Optional[int] = None,
|
|
2696
2703
|
knowledge_filters: Optional[Dict[str, Any]] = None,
|
|
2697
2704
|
dependencies: Optional[Dict[str, Any]] = None,
|
|
@@ -2709,6 +2716,7 @@ class Agent:
|
|
|
2709
2716
|
stream_events: Whether to stream all events.
|
|
2710
2717
|
user_id: The user id to continue the run for.
|
|
2711
2718
|
session_id: The session id to continue the run for.
|
|
2719
|
+
run_context: The run context to use for the run.
|
|
2712
2720
|
retries: The number of retries to continue the run for.
|
|
2713
2721
|
knowledge_filters: The knowledge filters to use for the run.
|
|
2714
2722
|
dependencies: The dependencies to use for the run.
|
|
@@ -2749,7 +2757,7 @@ class Agent:
|
|
|
2749
2757
|
dependencies = dependencies if dependencies is not None else self.dependencies
|
|
2750
2758
|
|
|
2751
2759
|
# Initialize run context
|
|
2752
|
-
run_context = RunContext(
|
|
2760
|
+
run_context = run_context or RunContext(
|
|
2753
2761
|
run_id=run_id, # type: ignore
|
|
2754
2762
|
session_id=session_id,
|
|
2755
2763
|
user_id=user_id,
|
|
@@ -3251,6 +3259,7 @@ class Agent:
|
|
|
3251
3259
|
stream_intermediate_steps: Optional[bool] = None,
|
|
3252
3260
|
user_id: Optional[str] = None,
|
|
3253
3261
|
session_id: Optional[str] = None,
|
|
3262
|
+
run_context: Optional[RunContext] = None,
|
|
3254
3263
|
retries: Optional[int] = None,
|
|
3255
3264
|
knowledge_filters: Optional[Dict[str, Any]] = None,
|
|
3256
3265
|
dependencies: Optional[Dict[str, Any]] = None,
|
|
@@ -3269,6 +3278,7 @@ class Agent:
|
|
|
3269
3278
|
stream_events: Whether to stream all events.
|
|
3270
3279
|
user_id: The user id to continue the run for.
|
|
3271
3280
|
session_id: The session id to continue the run for.
|
|
3281
|
+
run_context: The run context to use for the run.
|
|
3272
3282
|
retries: The number of retries to continue the run for.
|
|
3273
3283
|
knowledge_filters: The knowledge filters to use for the run.
|
|
3274
3284
|
dependencies: The dependencies to use for continuing the run.
|
|
@@ -3335,7 +3345,7 @@ class Agent:
|
|
|
3335
3345
|
self.model = cast(Model, self.model)
|
|
3336
3346
|
|
|
3337
3347
|
# Initialize run context
|
|
3338
|
-
run_context = RunContext(
|
|
3348
|
+
run_context = run_context or RunContext(
|
|
3339
3349
|
run_id=run_id, # type: ignore
|
|
3340
3350
|
session_id=session_id,
|
|
3341
3351
|
user_id=user_id,
|
agno/os/app.py
CHANGED
|
@@ -238,28 +238,35 @@ class AgentOS:
|
|
|
238
238
|
"""Re-provision all routes for the AgentOS."""
|
|
239
239
|
updated_routers = [
|
|
240
240
|
get_session_router(dbs=self.dbs),
|
|
241
|
-
get_memory_router(dbs=self.dbs),
|
|
242
|
-
get_eval_router(dbs=self.dbs, agents=self.agents, teams=self.teams),
|
|
243
241
|
get_metrics_router(dbs=self.dbs),
|
|
244
242
|
get_knowledge_router(knowledge_instances=self.knowledge_instances),
|
|
243
|
+
get_memory_router(dbs=self.dbs),
|
|
244
|
+
get_eval_router(dbs=self.dbs, agents=self.agents, teams=self.teams),
|
|
245
245
|
]
|
|
246
246
|
|
|
247
247
|
# Clear all previously existing routes
|
|
248
|
-
app.router.routes = [
|
|
248
|
+
app.router.routes = [
|
|
249
|
+
route
|
|
250
|
+
for route in app.router.routes
|
|
251
|
+
if hasattr(route, "path") and route.path in ["/docs", "/redoc", "/openapi.json", "/docs/oauth2-redirect"] # type: ignore
|
|
252
|
+
]
|
|
253
|
+
|
|
254
|
+
# Add the built-in routes
|
|
255
|
+
self._add_built_in_routes(app=app)
|
|
249
256
|
|
|
250
257
|
# Add the updated routes
|
|
251
258
|
for router in updated_routers:
|
|
252
259
|
self._add_router(app, router)
|
|
253
260
|
|
|
254
|
-
# Add the built-in routes
|
|
255
|
-
self._add_built_in_routes(app=app)
|
|
256
|
-
|
|
257
261
|
def _add_built_in_routes(self, app: FastAPI) -> None:
|
|
258
262
|
"""Add all AgentOSbuilt-in routes to the given app."""
|
|
263
|
+
# Add the home router if MCP server is not enabled
|
|
264
|
+
if not self.enable_mcp_server:
|
|
265
|
+
self._add_router(app, get_home_router(self))
|
|
266
|
+
|
|
267
|
+
self._add_router(app, get_health_router())
|
|
259
268
|
self._add_router(app, get_base_router(self, settings=self.settings))
|
|
260
269
|
self._add_router(app, get_websocket_router(self, settings=self.settings))
|
|
261
|
-
self._add_router(app, get_health_router())
|
|
262
|
-
self._add_router(app, get_home_router(self))
|
|
263
270
|
|
|
264
271
|
# Add A2A interface if relevant
|
|
265
272
|
has_a2a_interface = False
|
|
@@ -275,10 +282,6 @@ class AgentOS:
|
|
|
275
282
|
self.interfaces.append(a2a_interface)
|
|
276
283
|
self._add_router(app, a2a_interface.get_router())
|
|
277
284
|
|
|
278
|
-
# Add the home router if MCP server is not enabled
|
|
279
|
-
if not self.enable_mcp_server:
|
|
280
|
-
self._add_router(app, get_home_router(self))
|
|
281
|
-
|
|
282
285
|
def _make_app(self, lifespan: Optional[Any] = None) -> FastAPI:
|
|
283
286
|
# Adjust the FastAPI app lifespan to handle MCP connections if relevant
|
|
284
287
|
app_lifespan = lifespan
|
|
@@ -447,9 +450,6 @@ class AgentOS:
|
|
|
447
450
|
# Mount MCP if needed
|
|
448
451
|
if self.enable_mcp_server and self._mcp_app:
|
|
449
452
|
fastapi_app.mount("/", self._mcp_app)
|
|
450
|
-
else:
|
|
451
|
-
# Add the home router
|
|
452
|
-
self._add_router(fastapi_app, get_home_router(self))
|
|
453
453
|
|
|
454
454
|
if not self._app_set:
|
|
455
455
|
|
agno/team/team.py
CHANGED
|
@@ -1762,6 +1762,7 @@ class Team:
|
|
|
1762
1762
|
stream_intermediate_steps: Optional[bool] = None,
|
|
1763
1763
|
session_id: Optional[str] = None,
|
|
1764
1764
|
session_state: Optional[Dict[str, Any]] = None,
|
|
1765
|
+
run_context: Optional[RunContext] = None,
|
|
1765
1766
|
user_id: Optional[str] = None,
|
|
1766
1767
|
retries: Optional[int] = None,
|
|
1767
1768
|
audio: Optional[Sequence[Audio]] = None,
|
|
@@ -1789,6 +1790,7 @@ class Team:
|
|
|
1789
1790
|
stream_intermediate_steps: Optional[bool] = None,
|
|
1790
1791
|
session_id: Optional[str] = None,
|
|
1791
1792
|
session_state: Optional[Dict[str, Any]] = None,
|
|
1793
|
+
run_context: Optional[RunContext] = None,
|
|
1792
1794
|
user_id: Optional[str] = None,
|
|
1793
1795
|
retries: Optional[int] = None,
|
|
1794
1796
|
audio: Optional[Sequence[Audio]] = None,
|
|
@@ -1862,7 +1864,7 @@ class Team:
|
|
|
1862
1864
|
dependencies = dependencies if dependencies is not None else self.dependencies
|
|
1863
1865
|
|
|
1864
1866
|
# Initialize run context
|
|
1865
|
-
run_context = RunContext(
|
|
1867
|
+
run_context = run_context or RunContext(
|
|
1866
1868
|
run_id=run_id,
|
|
1867
1869
|
session_id=session_id,
|
|
1868
1870
|
user_id=user_id,
|
|
@@ -2593,6 +2595,7 @@ class Team:
|
|
|
2593
2595
|
stream_intermediate_steps: Optional[bool] = None,
|
|
2594
2596
|
session_id: Optional[str] = None,
|
|
2595
2597
|
session_state: Optional[Dict[str, Any]] = None,
|
|
2598
|
+
run_context: Optional[RunContext] = None,
|
|
2596
2599
|
user_id: Optional[str] = None,
|
|
2597
2600
|
retries: Optional[int] = None,
|
|
2598
2601
|
audio: Optional[Sequence[Audio]] = None,
|
|
@@ -2619,6 +2622,7 @@ class Team:
|
|
|
2619
2622
|
stream_intermediate_steps: Optional[bool] = None,
|
|
2620
2623
|
session_id: Optional[str] = None,
|
|
2621
2624
|
session_state: Optional[Dict[str, Any]] = None,
|
|
2625
|
+
run_context: Optional[RunContext] = None,
|
|
2622
2626
|
user_id: Optional[str] = None,
|
|
2623
2627
|
retries: Optional[int] = None,
|
|
2624
2628
|
audio: Optional[Sequence[Audio]] = None,
|
|
@@ -2646,6 +2650,7 @@ class Team:
|
|
|
2646
2650
|
stream_intermediate_steps: Optional[bool] = None,
|
|
2647
2651
|
session_id: Optional[str] = None,
|
|
2648
2652
|
session_state: Optional[Dict[str, Any]] = None,
|
|
2653
|
+
run_context: Optional[RunContext] = None,
|
|
2649
2654
|
user_id: Optional[str] = None,
|
|
2650
2655
|
retries: Optional[int] = None,
|
|
2651
2656
|
audio: Optional[Sequence[Audio]] = None,
|
|
@@ -2750,7 +2755,7 @@ class Team:
|
|
|
2750
2755
|
effective_filters = self._get_effective_filters(knowledge_filters)
|
|
2751
2756
|
|
|
2752
2757
|
# Initialize run context
|
|
2753
|
-
run_context = RunContext(
|
|
2758
|
+
run_context = run_context or RunContext(
|
|
2754
2759
|
run_id=run_id,
|
|
2755
2760
|
session_id=session_id,
|
|
2756
2761
|
user_id=user_id,
|
agno/workflow/agent.py
CHANGED
|
@@ -268,7 +268,7 @@ Guidelines:
|
|
|
268
268
|
user_id=session_from_db.user_id,
|
|
269
269
|
execution_input=workflow_execution_input,
|
|
270
270
|
workflow_run_response=workflow_run_response,
|
|
271
|
-
|
|
271
|
+
run_context=run_context,
|
|
272
272
|
stream_events=True,
|
|
273
273
|
websocket_handler=websocket_handler,
|
|
274
274
|
):
|
|
@@ -286,7 +286,7 @@ Guidelines:
|
|
|
286
286
|
user_id=session_from_db.user_id,
|
|
287
287
|
execution_input=workflow_execution_input,
|
|
288
288
|
workflow_run_response=workflow_run_response,
|
|
289
|
-
|
|
289
|
+
run_context=run_context,
|
|
290
290
|
)
|
|
291
291
|
|
|
292
292
|
if isinstance(result.content, str):
|
agno/workflow/condition.py
CHANGED
|
@@ -4,6 +4,7 @@ from typing import Any, AsyncIterator, Awaitable, Callable, Dict, Iterator, List
|
|
|
4
4
|
from uuid import uuid4
|
|
5
5
|
|
|
6
6
|
from agno.run.agent import RunOutputEvent
|
|
7
|
+
from agno.run.base import RunContext
|
|
7
8
|
from agno.run.team import TeamRunOutputEvent
|
|
8
9
|
from agno.run.workflow import (
|
|
9
10
|
ConditionExecutionCompletedEvent,
|
|
@@ -175,6 +176,7 @@ class Condition:
|
|
|
175
176
|
user_id: Optional[str] = None,
|
|
176
177
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
177
178
|
store_executor_outputs: bool = True,
|
|
179
|
+
run_context: Optional[RunContext] = None,
|
|
178
180
|
session_state: Optional[Dict[str, Any]] = None,
|
|
179
181
|
workflow_session: Optional[WorkflowSession] = None,
|
|
180
182
|
add_workflow_history_to_steps: Optional[bool] = False,
|
|
@@ -188,7 +190,11 @@ class Condition:
|
|
|
188
190
|
self._prepare_steps()
|
|
189
191
|
|
|
190
192
|
# Evaluate the condition
|
|
191
|
-
|
|
193
|
+
if run_context is not None and run_context.session_state is not None:
|
|
194
|
+
condition_result = self._evaluate_condition(step_input, session_state=run_context.session_state)
|
|
195
|
+
else:
|
|
196
|
+
condition_result = self._evaluate_condition(step_input, session_state=session_state)
|
|
197
|
+
|
|
192
198
|
log_debug(f"Condition {self.name} evaluated to: {condition_result}")
|
|
193
199
|
|
|
194
200
|
if not condition_result:
|
|
@@ -214,6 +220,7 @@ class Condition:
|
|
|
214
220
|
user_id=user_id,
|
|
215
221
|
workflow_run_response=workflow_run_response,
|
|
216
222
|
store_executor_outputs=store_executor_outputs,
|
|
223
|
+
run_context=run_context,
|
|
217
224
|
session_state=session_state,
|
|
218
225
|
workflow_session=workflow_session,
|
|
219
226
|
add_workflow_history_to_steps=add_workflow_history_to_steps,
|
|
@@ -284,6 +291,7 @@ class Condition:
|
|
|
284
291
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
285
292
|
step_index: Optional[Union[int, tuple]] = None,
|
|
286
293
|
store_executor_outputs: bool = True,
|
|
294
|
+
run_context: Optional[RunContext] = None,
|
|
287
295
|
session_state: Optional[Dict[str, Any]] = None,
|
|
288
296
|
parent_step_id: Optional[str] = None,
|
|
289
297
|
workflow_session: Optional[WorkflowSession] = None,
|
|
@@ -298,7 +306,10 @@ class Condition:
|
|
|
298
306
|
self._prepare_steps()
|
|
299
307
|
|
|
300
308
|
# Evaluate the condition
|
|
301
|
-
|
|
309
|
+
if run_context is not None and run_context.session_state is not None:
|
|
310
|
+
condition_result = self._evaluate_condition(step_input, session_state=run_context.session_state)
|
|
311
|
+
else:
|
|
312
|
+
condition_result = self._evaluate_condition(step_input, session_state=session_state)
|
|
302
313
|
log_debug(f"Condition {self.name} evaluated to: {condition_result}")
|
|
303
314
|
|
|
304
315
|
# Considering both stream_events and stream_intermediate_steps (deprecated)
|
|
@@ -363,6 +374,7 @@ class Condition:
|
|
|
363
374
|
workflow_run_response=workflow_run_response,
|
|
364
375
|
step_index=child_step_index,
|
|
365
376
|
store_executor_outputs=store_executor_outputs,
|
|
377
|
+
run_context=run_context,
|
|
366
378
|
session_state=session_state,
|
|
367
379
|
parent_step_id=conditional_step_id,
|
|
368
380
|
workflow_session=workflow_session,
|
|
@@ -447,6 +459,7 @@ class Condition:
|
|
|
447
459
|
user_id: Optional[str] = None,
|
|
448
460
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
449
461
|
store_executor_outputs: bool = True,
|
|
462
|
+
run_context: Optional[RunContext] = None,
|
|
450
463
|
session_state: Optional[Dict[str, Any]] = None,
|
|
451
464
|
workflow_session: Optional[WorkflowSession] = None,
|
|
452
465
|
add_workflow_history_to_steps: Optional[bool] = False,
|
|
@@ -460,7 +473,10 @@ class Condition:
|
|
|
460
473
|
self._prepare_steps()
|
|
461
474
|
|
|
462
475
|
# Evaluate the condition
|
|
463
|
-
|
|
476
|
+
if run_context is not None and run_context.session_state is not None:
|
|
477
|
+
condition_result = await self._aevaluate_condition(step_input, session_state=run_context.session_state)
|
|
478
|
+
else:
|
|
479
|
+
condition_result = await self._aevaluate_condition(step_input, session_state=session_state)
|
|
464
480
|
log_debug(f"Condition {self.name} evaluated to: {condition_result}")
|
|
465
481
|
|
|
466
482
|
if not condition_result:
|
|
@@ -488,6 +504,7 @@ class Condition:
|
|
|
488
504
|
user_id=user_id,
|
|
489
505
|
workflow_run_response=workflow_run_response,
|
|
490
506
|
store_executor_outputs=store_executor_outputs,
|
|
507
|
+
run_context=run_context,
|
|
491
508
|
session_state=session_state,
|
|
492
509
|
workflow_session=workflow_session,
|
|
493
510
|
add_workflow_history_to_steps=add_workflow_history_to_steps,
|
|
@@ -556,6 +573,7 @@ class Condition:
|
|
|
556
573
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
557
574
|
step_index: Optional[Union[int, tuple]] = None,
|
|
558
575
|
store_executor_outputs: bool = True,
|
|
576
|
+
run_context: Optional[RunContext] = None,
|
|
559
577
|
session_state: Optional[Dict[str, Any]] = None,
|
|
560
578
|
parent_step_id: Optional[str] = None,
|
|
561
579
|
workflow_session: Optional[WorkflowSession] = None,
|
|
@@ -570,7 +588,10 @@ class Condition:
|
|
|
570
588
|
self._prepare_steps()
|
|
571
589
|
|
|
572
590
|
# Evaluate the condition
|
|
573
|
-
|
|
591
|
+
if run_context is not None and run_context.session_state is not None:
|
|
592
|
+
condition_result = await self._aevaluate_condition(step_input, session_state=run_context.session_state)
|
|
593
|
+
else:
|
|
594
|
+
condition_result = await self._aevaluate_condition(step_input, session_state=session_state)
|
|
574
595
|
log_debug(f"Condition {self.name} evaluated to: {condition_result}")
|
|
575
596
|
|
|
576
597
|
# Considering both stream_events and stream_intermediate_steps (deprecated)
|
|
@@ -637,6 +658,7 @@ class Condition:
|
|
|
637
658
|
workflow_run_response=workflow_run_response,
|
|
638
659
|
step_index=child_step_index,
|
|
639
660
|
store_executor_outputs=store_executor_outputs,
|
|
661
|
+
run_context=run_context,
|
|
640
662
|
session_state=session_state,
|
|
641
663
|
parent_step_id=conditional_step_id,
|
|
642
664
|
workflow_session=workflow_session,
|
agno/workflow/loop.py
CHANGED
|
@@ -4,6 +4,7 @@ from typing import Any, AsyncIterator, Awaitable, Callable, Dict, Iterator, List
|
|
|
4
4
|
from uuid import uuid4
|
|
5
5
|
|
|
6
6
|
from agno.run.agent import RunOutputEvent
|
|
7
|
+
from agno.run.base import RunContext
|
|
7
8
|
from agno.run.team import TeamRunOutputEvent
|
|
8
9
|
from agno.run.workflow import (
|
|
9
10
|
LoopExecutionCompletedEvent,
|
|
@@ -132,6 +133,7 @@ class Loop:
|
|
|
132
133
|
user_id: Optional[str] = None,
|
|
133
134
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
134
135
|
store_executor_outputs: bool = True,
|
|
136
|
+
run_context: Optional[RunContext] = None,
|
|
135
137
|
session_state: Optional[Dict[str, Any]] = None,
|
|
136
138
|
workflow_session: Optional[WorkflowSession] = None,
|
|
137
139
|
add_workflow_history_to_steps: Optional[bool] = False,
|
|
@@ -160,6 +162,7 @@ class Loop:
|
|
|
160
162
|
user_id=user_id,
|
|
161
163
|
workflow_run_response=workflow_run_response,
|
|
162
164
|
store_executor_outputs=store_executor_outputs,
|
|
165
|
+
run_context=run_context,
|
|
163
166
|
session_state=session_state,
|
|
164
167
|
workflow_session=workflow_session,
|
|
165
168
|
add_workflow_history_to_steps=add_workflow_history_to_steps,
|
|
@@ -232,6 +235,7 @@ class Loop:
|
|
|
232
235
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
233
236
|
step_index: Optional[Union[int, tuple]] = None,
|
|
234
237
|
store_executor_outputs: bool = True,
|
|
238
|
+
run_context: Optional[RunContext] = None,
|
|
235
239
|
session_state: Optional[Dict[str, Any]] = None,
|
|
236
240
|
parent_step_id: Optional[str] = None,
|
|
237
241
|
workflow_session: Optional[WorkflowSession] = None,
|
|
@@ -311,6 +315,7 @@ class Loop:
|
|
|
311
315
|
workflow_run_response=workflow_run_response,
|
|
312
316
|
step_index=composite_step_index,
|
|
313
317
|
store_executor_outputs=store_executor_outputs,
|
|
318
|
+
run_context=run_context,
|
|
314
319
|
session_state=session_state,
|
|
315
320
|
parent_step_id=loop_step_id,
|
|
316
321
|
add_workflow_history_to_steps=add_workflow_history_to_steps,
|
|
@@ -428,6 +433,7 @@ class Loop:
|
|
|
428
433
|
user_id: Optional[str] = None,
|
|
429
434
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
430
435
|
store_executor_outputs: bool = True,
|
|
436
|
+
run_context: Optional[RunContext] = None,
|
|
431
437
|
session_state: Optional[Dict[str, Any]] = None,
|
|
432
438
|
workflow_session: Optional[WorkflowSession] = None,
|
|
433
439
|
add_workflow_history_to_steps: Optional[bool] = False,
|
|
@@ -458,6 +464,7 @@ class Loop:
|
|
|
458
464
|
user_id=user_id,
|
|
459
465
|
workflow_run_response=workflow_run_response,
|
|
460
466
|
store_executor_outputs=store_executor_outputs,
|
|
467
|
+
run_context=run_context,
|
|
461
468
|
session_state=session_state,
|
|
462
469
|
workflow_session=workflow_session,
|
|
463
470
|
add_workflow_history_to_steps=add_workflow_history_to_steps,
|
|
@@ -533,6 +540,7 @@ class Loop:
|
|
|
533
540
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
534
541
|
step_index: Optional[Union[int, tuple]] = None,
|
|
535
542
|
store_executor_outputs: bool = True,
|
|
543
|
+
run_context: Optional[RunContext] = None,
|
|
536
544
|
session_state: Optional[Dict[str, Any]] = None,
|
|
537
545
|
parent_step_id: Optional[str] = None,
|
|
538
546
|
workflow_session: Optional[WorkflowSession] = None,
|
|
@@ -612,6 +620,7 @@ class Loop:
|
|
|
612
620
|
workflow_run_response=workflow_run_response,
|
|
613
621
|
step_index=composite_step_index,
|
|
614
622
|
store_executor_outputs=store_executor_outputs,
|
|
623
|
+
run_context=run_context,
|
|
615
624
|
session_state=session_state,
|
|
616
625
|
parent_step_id=loop_step_id,
|
|
617
626
|
workflow_session=workflow_session,
|
agno/workflow/parallel.py
CHANGED
|
@@ -7,6 +7,7 @@ from uuid import uuid4
|
|
|
7
7
|
|
|
8
8
|
from agno.models.metrics import Metrics
|
|
9
9
|
from agno.run.agent import RunOutputEvent
|
|
10
|
+
from agno.run.base import RunContext
|
|
10
11
|
from agno.run.team import TeamRunOutputEvent
|
|
11
12
|
from agno.run.workflow import (
|
|
12
13
|
ParallelExecutionCompletedEvent,
|
|
@@ -200,6 +201,7 @@ class Parallel:
|
|
|
200
201
|
user_id: Optional[str] = None,
|
|
201
202
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
202
203
|
store_executor_outputs: bool = True,
|
|
204
|
+
run_context: Optional[RunContext] = None,
|
|
203
205
|
session_state: Optional[Dict[str, Any]] = None,
|
|
204
206
|
workflow_session: Optional[WorkflowSession] = None,
|
|
205
207
|
add_workflow_history_to_steps: Optional[bool] = False,
|
|
@@ -214,10 +216,14 @@ class Parallel:
|
|
|
214
216
|
# Create individual session_state copies for each step to prevent race conditions
|
|
215
217
|
session_state_copies = []
|
|
216
218
|
for _ in range(len(self.steps)):
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
# If using run context, no need to deepcopy the state. We want the direct reference.
|
|
220
|
+
if run_context is not None and run_context.session_state is not None:
|
|
221
|
+
session_state_copies.append(run_context.session_state)
|
|
219
222
|
else:
|
|
220
|
-
|
|
223
|
+
if session_state is not None:
|
|
224
|
+
session_state_copies.append(deepcopy(session_state))
|
|
225
|
+
else:
|
|
226
|
+
session_state_copies.append({})
|
|
221
227
|
|
|
222
228
|
def execute_step_with_index(step_with_index):
|
|
223
229
|
"""Execute a single step and preserve its original index"""
|
|
@@ -235,6 +241,7 @@ class Parallel:
|
|
|
235
241
|
workflow_session=workflow_session,
|
|
236
242
|
add_workflow_history_to_steps=add_workflow_history_to_steps,
|
|
237
243
|
num_history_runs=num_history_runs,
|
|
244
|
+
run_context=run_context,
|
|
238
245
|
session_state=step_session_state,
|
|
239
246
|
) # type: ignore[union-attr]
|
|
240
247
|
return idx, step_result, step_session_state
|
|
@@ -288,7 +295,7 @@ class Parallel:
|
|
|
288
295
|
)
|
|
289
296
|
)
|
|
290
297
|
|
|
291
|
-
if session_state is not None:
|
|
298
|
+
if run_context is None and session_state is not None:
|
|
292
299
|
merge_parallel_session_states(session_state, modified_session_states)
|
|
293
300
|
|
|
294
301
|
# Sort by original index to preserve order
|
|
@@ -322,6 +329,7 @@ class Parallel:
|
|
|
322
329
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
323
330
|
step_index: Optional[Union[int, tuple]] = None,
|
|
324
331
|
store_executor_outputs: bool = True,
|
|
332
|
+
run_context: Optional[RunContext] = None,
|
|
325
333
|
session_state: Optional[Dict[str, Any]] = None,
|
|
326
334
|
parent_step_id: Optional[str] = None,
|
|
327
335
|
workflow_session: Optional[WorkflowSession] = None,
|
|
@@ -338,10 +346,14 @@ class Parallel:
|
|
|
338
346
|
# Create individual session_state copies for each step to prevent race conditions
|
|
339
347
|
session_state_copies = []
|
|
340
348
|
for _ in range(len(self.steps)):
|
|
341
|
-
|
|
342
|
-
|
|
349
|
+
# If using run context, no need to deepcopy the state. We want the direct reference.
|
|
350
|
+
if run_context is not None and run_context.session_state is not None:
|
|
351
|
+
session_state_copies.append(run_context.session_state)
|
|
343
352
|
else:
|
|
344
|
-
|
|
353
|
+
if session_state is not None:
|
|
354
|
+
session_state_copies.append(deepcopy(session_state))
|
|
355
|
+
else:
|
|
356
|
+
session_state_copies.append({})
|
|
345
357
|
|
|
346
358
|
# Considering both stream_events and stream_intermediate_steps (deprecated)
|
|
347
359
|
stream_events = stream_events or stream_intermediate_steps
|
|
@@ -468,7 +480,7 @@ class Parallel:
|
|
|
468
480
|
logger.error(f"Future completion error: {e}")
|
|
469
481
|
|
|
470
482
|
# Merge all session_state changes back into the original session_state
|
|
471
|
-
if session_state is not None:
|
|
483
|
+
if run_context is None and session_state is not None:
|
|
472
484
|
merge_parallel_session_states(session_state, modified_session_states)
|
|
473
485
|
|
|
474
486
|
# Flatten step_results - handle steps that return List[StepOutput] (like Condition/Loop)
|
|
@@ -509,6 +521,7 @@ class Parallel:
|
|
|
509
521
|
user_id: Optional[str] = None,
|
|
510
522
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
511
523
|
store_executor_outputs: bool = True,
|
|
524
|
+
run_context: Optional[RunContext] = None,
|
|
512
525
|
session_state: Optional[Dict[str, Any]] = None,
|
|
513
526
|
workflow_session: Optional[WorkflowSession] = None,
|
|
514
527
|
add_workflow_history_to_steps: Optional[bool] = False,
|
|
@@ -523,10 +536,14 @@ class Parallel:
|
|
|
523
536
|
# Create individual session_state copies for each step to prevent race conditions
|
|
524
537
|
session_state_copies = []
|
|
525
538
|
for _ in range(len(self.steps)):
|
|
526
|
-
|
|
527
|
-
|
|
539
|
+
# If using run context, no need to deepcopy the state. We want the direct reference.
|
|
540
|
+
if run_context is not None and run_context.session_state is not None:
|
|
541
|
+
session_state_copies.append(run_context.session_state)
|
|
528
542
|
else:
|
|
529
|
-
|
|
543
|
+
if session_state is not None:
|
|
544
|
+
session_state_copies.append(deepcopy(session_state))
|
|
545
|
+
else:
|
|
546
|
+
session_state_copies.append({})
|
|
530
547
|
|
|
531
548
|
async def execute_step_async_with_index(step_with_index):
|
|
532
549
|
"""Execute a single step asynchronously and preserve its original index"""
|
|
@@ -598,7 +615,7 @@ class Parallel:
|
|
|
598
615
|
log_debug(f"Parallel step {step_name} completed")
|
|
599
616
|
|
|
600
617
|
# Smart merge all session_state changes back into the original session_state
|
|
601
|
-
if session_state is not None:
|
|
618
|
+
if run_context is None and session_state is not None:
|
|
602
619
|
merge_parallel_session_states(session_state, modified_session_states)
|
|
603
620
|
|
|
604
621
|
# Sort by original index to preserve order
|
|
@@ -632,6 +649,7 @@ class Parallel:
|
|
|
632
649
|
workflow_run_response: Optional[WorkflowRunOutput] = None,
|
|
633
650
|
step_index: Optional[Union[int, tuple]] = None,
|
|
634
651
|
store_executor_outputs: bool = True,
|
|
652
|
+
run_context: Optional[RunContext] = None,
|
|
635
653
|
session_state: Optional[Dict[str, Any]] = None,
|
|
636
654
|
parent_step_id: Optional[str] = None,
|
|
637
655
|
workflow_session: Optional[WorkflowSession] = None,
|
|
@@ -648,10 +666,14 @@ class Parallel:
|
|
|
648
666
|
# Create individual session_state copies for each step to prevent race conditions
|
|
649
667
|
session_state_copies = []
|
|
650
668
|
for _ in range(len(self.steps)):
|
|
651
|
-
|
|
652
|
-
|
|
669
|
+
# If using run context, no need to deepcopy the state. We want the direct reference.
|
|
670
|
+
if run_context is not None and run_context.session_state is not None:
|
|
671
|
+
session_state_copies.append(run_context.session_state)
|
|
653
672
|
else:
|
|
654
|
-
|
|
673
|
+
if session_state is not None:
|
|
674
|
+
session_state_copies.append(deepcopy(session_state))
|
|
675
|
+
else:
|
|
676
|
+
session_state_copies.append({})
|
|
655
677
|
|
|
656
678
|
# Considering both stream_events and stream_intermediate_steps (deprecated)
|
|
657
679
|
stream_events = stream_events or stream_intermediate_steps
|
|
@@ -705,6 +727,7 @@ class Parallel:
|
|
|
705
727
|
step_index=sub_step_index,
|
|
706
728
|
store_executor_outputs=store_executor_outputs,
|
|
707
729
|
session_state=step_session_state,
|
|
730
|
+
run_context=run_context,
|
|
708
731
|
parent_step_id=parallel_step_id,
|
|
709
732
|
workflow_session=workflow_session,
|
|
710
733
|
add_workflow_history_to_steps=add_workflow_history_to_steps,
|
|
@@ -766,7 +789,7 @@ class Parallel:
|
|
|
766
789
|
await asyncio.gather(*tasks, return_exceptions=True)
|
|
767
790
|
|
|
768
791
|
# Merge all session_state changes back into the original session_state
|
|
769
|
-
if session_state is not None:
|
|
792
|
+
if run_context is None and session_state is not None:
|
|
770
793
|
merge_parallel_session_states(session_state, modified_session_states)
|
|
771
794
|
|
|
772
795
|
# Flatten step_results - handle steps that return List[StepOutput] (like Condition/Loop)
|