agent-framework-core 1.19.0__tar.gz → 1.21.0__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 (112) hide show
  1. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/PKG-INFO +32 -31
  2. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/__init__.py +9 -1
  3. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/__init__.pyi +9 -1
  4. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_agent_hooks.py +62 -98
  5. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_agents.py +255 -65
  6. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_compaction.py +251 -38
  7. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_evaluation.py +16 -10
  8. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_feature_stage.py +1 -0
  9. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_agent.py +8 -0
  10. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_agent.pyi +1 -0
  11. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_file_access.py +370 -91
  12. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_file_memory.py +9 -9
  13. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_loop.py +52 -26
  14. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_mode.py +15 -3
  15. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_tool_approval.py +49 -2
  16. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_in_memory.py +8 -5
  17. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_mcp.py +51 -13
  18. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_middleware.py +312 -11
  19. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_sessions.py +124 -47
  20. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_settings.py +47 -15
  21. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_skills.py +372 -40
  22. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_telemetry.py +11 -1
  23. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_tools.py +790 -226
  24. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_types.py +977 -268
  25. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_vector_filters.py +30 -1
  26. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_vectors.py +175 -21
  27. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_agent.py +30 -4
  28. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_agent_executor.py +450 -53
  29. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_checkpoint.py +4 -4
  30. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_checkpoint_encoding.py +21 -11
  31. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_const.py +4 -0
  32. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_edge.py +6 -5
  33. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_edge_runner.py +26 -0
  34. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_functional.py +748 -92
  35. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_state.py +11 -0
  36. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_typing_utils.py +5 -0
  37. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_workflow.py +173 -66
  38. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_workflow_executor.py +130 -26
  39. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/exceptions.py +5 -5
  40. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/foundry/__init__.py +4 -0
  41. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/foundry/__init__.pyi +8 -0
  42. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/gemini/__init__.py +3 -1
  43. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/gemini/__init__.pyi +6 -2
  44. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/security.py +461 -82
  45. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/pyproject.toml +32 -31
  46. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/LICENSE +0 -0
  47. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/README.md +0 -0
  48. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_clients.py +0 -0
  49. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_docstrings.py +0 -0
  50. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_filesystem.py +0 -0
  51. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/__init__.py +0 -0
  52. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_background_agents.py +0 -0
  53. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_memory.py +0 -0
  54. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_harness/_todo.py +0 -0
  55. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_serialization.py +0 -0
  56. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/__init__.py +0 -0
  57. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_agent_utils.py +0 -0
  58. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_conversation_history.py +0 -0
  59. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_events.py +0 -0
  60. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_executor.py +0 -0
  61. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_function_executor.py +0 -0
  62. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_message_utils.py +0 -0
  63. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_model_utils.py +0 -0
  64. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_request_info_mixin.py +0 -0
  65. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_runner.py +0 -0
  66. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_runner_context.py +0 -0
  67. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_validation.py +0 -0
  68. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_viz.py +0 -0
  69. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_workflow_builder.py +0 -0
  70. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/_workflows/_workflow_context.py +0 -0
  71. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/a2a/__init__.py +0 -0
  72. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/a2a/__init__.pyi +0 -0
  73. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/ag_ui/__init__.py +0 -0
  74. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/ag_ui/__init__.pyi +0 -0
  75. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/amazon/__init__.py +0 -0
  76. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/amazon/__init__.pyi +0 -0
  77. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/anthropic/__init__.py +0 -0
  78. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/anthropic/__init__.pyi +0 -0
  79. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/azure/__init__.py +0 -0
  80. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/azure/__init__.pyi +0 -0
  81. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/chatkit/__init__.py +0 -0
  82. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/chatkit/__init__.pyi +0 -0
  83. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/declarative/__init__.py +0 -0
  84. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/declarative/__init__.pyi +0 -0
  85. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/devui/__init__.py +0 -0
  86. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/devui/__init__.pyi +0 -0
  87. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/github/__init__.py +0 -0
  88. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/github/__init__.pyi +0 -0
  89. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/google/__init__.py +0 -0
  90. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/google/__init__.pyi +0 -0
  91. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/hyperlight/__init__.py +0 -0
  92. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/lab/__init__.py +0 -0
  93. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/mem0/__init__.py +0 -0
  94. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/mem0/__init__.pyi +0 -0
  95. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/microsoft/__init__.py +0 -0
  96. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/microsoft/__init__.pyi +0 -0
  97. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/mistral/__init__.py +0 -0
  98. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/mistral/__init__.pyi +0 -0
  99. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/monty/__init__.py +0 -0
  100. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/monty/__init__.pyi +0 -0
  101. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/observability.py +0 -0
  102. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/ollama/__init__.py +0 -0
  103. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/ollama/__init__.pyi +0 -0
  104. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/openai/__init__.py +0 -0
  105. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/openai/__init__.pyi +0 -0
  106. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/orchestrations/__init__.py +0 -0
  107. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/orchestrations/__init__.pyi +0 -0
  108. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/py.typed +0 -0
  109. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/redis/__init__.py +0 -0
  110. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/redis/__init__.pyi +0 -0
  111. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/tools/__init__.py +0 -0
  112. {agent_framework_core-1.19.0 → agent_framework_core-1.21.0}/agent_framework/tools/__init__.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-framework-core
3
- Version: 1.19.0
3
+ Version: 1.21.0
4
4
  Summary: Microsoft Agent Framework for building AI Agents with Python. This is the core package that has all the core abstractions and implementations.
5
5
  Author-email: Microsoft <af-support@microsoft.com>
6
6
  Requires-Python: >=3.10
@@ -16,42 +16,43 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
17
  Classifier: Typing :: Typed
18
18
  License-File: LICENSE
19
- Requires-Dist: msgspec>=0.20.0,<0.22
19
+ Requires-Dist: msgspec>=0.20.0,<0.23
20
20
  Requires-Dist: typing-extensions>=4.15.0,<5
21
21
  Requires-Dist: pydantic>=2,<3
22
22
  Requires-Dist: python-dotenv>=1,<2
23
23
  Requires-Dist: opentelemetry-api>=1.39.0,<2
24
24
  Requires-Dist: pyyaml>=6.0,<7.0
25
+ Requires-Dist: regex>=2024.11.6
25
26
  Requires-Dist: mcp>=1.24.0,<2 ; extra == "all"
26
- Requires-Dist: agent-framework-a2a ; extra == "all"
27
- Requires-Dist: agent-framework-ag-ui ; extra == "all"
28
- Requires-Dist: agent-framework-anthropic ; extra == "all"
29
- Requires-Dist: agent-framework-azure-ai-search ; extra == "all"
30
- Requires-Dist: agent-framework-azure-contentunderstanding ; extra == "all"
31
- Requires-Dist: agent-framework-azure-cosmos ; extra == "all"
32
- Requires-Dist: agent-framework-azurefunctions ; extra == "all"
33
- Requires-Dist: agent-framework-bedrock ; extra == "all"
34
- Requires-Dist: agent-framework-chatkit ; extra == "all"
35
- Requires-Dist: agent-framework-claude ; extra == "all"
36
- Requires-Dist: agent-framework-copilotstudio ; extra == "all"
37
- Requires-Dist: agent-framework-declarative ; extra == "all"
38
- Requires-Dist: agent-framework-devui ; extra == "all"
39
- Requires-Dist: agent-framework-durabletask ; extra == "all"
40
- Requires-Dist: agent-framework-foundry ; extra == "all"
41
- Requires-Dist: agent-framework-foundry-hosting ; extra == "all"
42
- Requires-Dist: agent-framework-foundry-local ; extra == "all"
43
- Requires-Dist: agent-framework-gemini ; extra == "all"
44
- Requires-Dist: agent-framework-github-copilot ; extra == "all" and ( python_version >= '3.11')
45
- Requires-Dist: agent-framework-hyperlight ; extra == "all" and ( python_version < '3.15' and ((sys_platform == 'linux' and platform_machine == 'x86_64') or (sys_platform == 'win32' and platform_machine == 'AMD64')))
46
- Requires-Dist: agent-framework-mem0 ; extra == "all"
47
- Requires-Dist: agent-framework-mistral ; extra == "all"
48
- Requires-Dist: agent-framework-monty ; extra == "all"
49
- Requires-Dist: agent-framework-ollama ; extra == "all"
50
- Requires-Dist: agent-framework-openai ; extra == "all"
51
- Requires-Dist: agent-framework-orchestrations ; extra == "all"
52
- Requires-Dist: agent-framework-purview ; extra == "all"
53
- Requires-Dist: agent-framework-redis ; extra == "all"
54
- Requires-Dist: agent-framework-tools ; extra == "all"
27
+ Requires-Dist: agent-framework-a2a>=1.0.0b261002,<2 ; extra == "all"
28
+ Requires-Dist: agent-framework-ag-ui>=1.5.1,<2 ; extra == "all"
29
+ Requires-Dist: agent-framework-anthropic>=1.0.0b261008,<2 ; extra == "all"
30
+ Requires-Dist: agent-framework-azure-ai-search>=1.0.0b261002,<2 ; extra == "all"
31
+ Requires-Dist: agent-framework-azure-contentunderstanding>=1.0.0b261008,<2 ; extra == "all"
32
+ Requires-Dist: agent-framework-azure-cosmos>=1.0.0b261002,<2 ; extra == "all"
33
+ Requires-Dist: agent-framework-azurefunctions>=1.0.0b260922,<2 ; extra == "all"
34
+ Requires-Dist: agent-framework-bedrock>=1.0.0b261008,<2 ; extra == "all"
35
+ Requires-Dist: agent-framework-chatkit>=1.0.0b261002,<2 ; extra == "all"
36
+ Requires-Dist: agent-framework-claude>=1.0.0b261002,<2 ; extra == "all"
37
+ Requires-Dist: agent-framework-copilotstudio>=1.0.0b261002,<2 ; extra == "all"
38
+ Requires-Dist: agent-framework-declarative>=1.2.1,<2 ; extra == "all"
39
+ Requires-Dist: agent-framework-devui>=1.0.0b261008,<2 ; extra == "all"
40
+ Requires-Dist: agent-framework-durabletask>=1.0.0b260922,<2 ; extra == "all"
41
+ Requires-Dist: agent-framework-foundry>=1.14.1,<2 ; extra == "all"
42
+ Requires-Dist: agent-framework-foundry-hosting>=1.0.0b261008,<2 ; extra == "all"
43
+ Requires-Dist: agent-framework-foundry-local>=1.0.0b260730,<2 ; extra == "all"
44
+ Requires-Dist: agent-framework-gemini>=1.0.0b261008,<2 ; extra == "all"
45
+ Requires-Dist: agent-framework-github-copilot>=2.0.2,<3 ; extra == "all" and ( python_version >= '3.11')
46
+ Requires-Dist: agent-framework-hyperlight>=1.0.0b261008,<2 ; extra == "all" and ( python_version < '3.15' and ((sys_platform == 'linux' and platform_machine == 'x86_64') or (sys_platform == 'win32' and platform_machine == 'AMD64')))
47
+ Requires-Dist: agent-framework-mem0>=1.0.0b261002,<2 ; extra == "all"
48
+ Requires-Dist: agent-framework-mistral>=1.0.0b260918,<2 ; extra == "all"
49
+ Requires-Dist: agent-framework-monty>=1.0.0b261008,<2 ; extra == "all"
50
+ Requires-Dist: agent-framework-ollama>=1.0.0b261008,<2 ; extra == "all"
51
+ Requires-Dist: agent-framework-openai>=1.16.0,<2 ; extra == "all"
52
+ Requires-Dist: agent-framework-orchestrations>=1.3.1,<2 ; extra == "all"
53
+ Requires-Dist: agent-framework-purview>=1.0.0b261008,<2 ; extra == "all"
54
+ Requires-Dist: agent-framework-redis>=1.0.0b261002,<2 ; extra == "all" and ( python_version < '3.15')
55
+ Requires-Dist: agent-framework-tools>=1.0.0b261008,<2 ; extra == "all"
55
56
  Project-URL: homepage, https://aka.ms/agent-framework
56
57
  Project-URL: issues, https://github.com/microsoft/agent-framework/issues
57
58
  Project-URL: release_notes, https://github.com/microsoft/agent-framework/releases?q=tag%3Apython-1&expanded=true
@@ -254,6 +254,7 @@ _LAZY_MODULE_EXPORTS: Final[Mapping[str, tuple[str, ...]]] = {
254
254
  "ChatOptions",
255
255
  "ChatResponse",
256
256
  "ChatResponseUpdate",
257
+ "ComputerSafetyCheck",
257
258
  "Content",
258
259
  "ContinuationToken",
259
260
  "Embedding",
@@ -322,7 +323,12 @@ _LAZY_MODULE_EXPORTS: Final[Mapping[str, tuple[str, ...]]] = {
322
323
  "vectorstoremodel",
323
324
  ),
324
325
  "._workflows._agent": ("WorkflowAgent",),
325
- "._workflows._agent_executor": ("AgentExecutor", "AgentExecutorRequest", "AgentExecutorResponse"),
326
+ "._workflows._agent_executor": (
327
+ "AgentExecutor",
328
+ "AgentExecutorCheckpointState",
329
+ "AgentExecutorRequest",
330
+ "AgentExecutorResponse",
331
+ ),
326
332
  "._workflows._agent_utils": ("resolve_agent_id",),
327
333
  "._workflows._checkpoint": (
328
334
  "CheckpointID",
@@ -429,6 +435,7 @@ __all__ = [
429
435
  "AgentContext",
430
436
  "AgentEvalConverter",
431
437
  "AgentExecutor",
438
+ "AgentExecutorCheckpointState",
432
439
  "AgentExecutorRequest",
433
440
  "AgentExecutorResponse",
434
441
  "AgentFileStore",
@@ -470,6 +477,7 @@ __all__ = [
470
477
  "ClassSkill",
471
478
  "CompactionProvider",
472
479
  "CompactionStrategy",
480
+ "ComputerSafetyCheck",
473
481
  "Content",
474
482
  "ContextProvider",
475
483
  "ContextWindowCompactionStrategy",
@@ -220,6 +220,7 @@ from ._types import (
220
220
  ChatOptions,
221
221
  ChatResponse,
222
222
  ChatResponseUpdate,
223
+ ComputerSafetyCheck,
223
224
  Content,
224
225
  ContinuationToken,
225
226
  Embedding,
@@ -278,7 +279,12 @@ from ._vectors import (
278
279
  vectorstoremodel,
279
280
  )
280
281
  from ._workflows._agent import WorkflowAgent
281
- from ._workflows._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse
282
+ from ._workflows._agent_executor import (
283
+ AgentExecutor,
284
+ AgentExecutorCheckpointState,
285
+ AgentExecutorRequest,
286
+ AgentExecutorResponse,
287
+ )
282
288
  from ._workflows._agent_utils import resolve_agent_id
283
289
  from ._workflows._checkpoint import (
284
290
  CheckpointID,
@@ -384,6 +390,7 @@ __all__ = [
384
390
  "AgentContext",
385
391
  "AgentEvalConverter",
386
392
  "AgentExecutor",
393
+ "AgentExecutorCheckpointState",
387
394
  "AgentExecutorRequest",
388
395
  "AgentExecutorResponse",
389
396
  "AgentFileStore",
@@ -425,6 +432,7 @@ __all__ = [
425
432
  "ClassSkill",
426
433
  "CompactionProvider",
427
434
  "CompactionStrategy",
435
+ "ComputerSafetyCheck",
428
436
  "Content",
429
437
  "ContextProvider",
430
438
  "ContextWindowCompactionStrategy",
@@ -69,9 +69,8 @@ Enforcement semantics (``mode="enforce"``):
69
69
  outside the tool seam falls back to deferring both — fail-closed, matching the
70
70
  pre-ownership behavior.
71
71
 
72
- Streaming is supported **fail-closed by buffering** via
73
- :meth:`ResponseStream.buffered_and_gated`: the model/agent stream is fully consumed
74
- internally, middleware stream hooks are applied to the buffered content, the
72
+ Streaming is supported **fail-closed by buffering**: the model/agent stream is fully
73
+ consumed internally, middleware stream hooks are applied to the buffered content, the
75
74
  ``post_model_call`` / ``output`` verdict is applied to the finalized result, and only
76
75
  then are the (possibly transformed) updates released to the consumer. No partial content
77
76
  ever egresses ahead of a verdict (spec §12.1/§12.1a ``buffered_output: true``
@@ -103,7 +102,7 @@ import contextlib
103
102
  import json
104
103
  import logging
105
104
  import uuid
106
- from collections.abc import Awaitable, Callable, Mapping, Sequence
105
+ from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping, Sequence
107
106
  from contextvars import ContextVar
108
107
  from dataclasses import dataclass
109
108
  from typing import TYPE_CHECKING, Any, NoReturn, cast
@@ -826,42 +825,6 @@ class _OutputCodec:
826
825
  # region Enforcement helpers
827
826
 
828
827
 
829
- def _chat_updates_from_response(response: ChatResponse[Any]) -> list[ChatResponseUpdate]:
830
- """Re-derive stream updates from a (transformed) assembled chat response."""
831
- updates = [
832
- ChatResponseUpdate(
833
- contents=list(message.contents),
834
- role=cast(Any, message.role),
835
- author_name=message.author_name,
836
- message_id=message.message_id,
837
- response_id=response.response_id,
838
- model=response.model,
839
- )
840
- for message in response.messages
841
- ]
842
- if not updates:
843
- updates = [ChatResponseUpdate(role="assistant", response_id=response.response_id)]
844
- updates[-1].finish_reason = response.finish_reason
845
- return updates
846
-
847
-
848
- def _agent_updates_from_response(response: AgentResponse[Any]) -> list[AgentResponseUpdate]:
849
- """Re-derive stream updates from a (transformed) assembled agent response."""
850
- updates = [
851
- AgentResponseUpdate(
852
- contents=list(message.contents),
853
- role=message.role,
854
- author_name=message.author_name,
855
- message_id=message.message_id,
856
- response_id=response.response_id,
857
- )
858
- for message in response.messages
859
- ]
860
- if not updates:
861
- updates = [AgentResponseUpdate(role="assistant", response_id=response.response_id)]
862
- return updates
863
-
864
-
865
828
  def _normalized_tools(tools: Any, *, point: str) -> list[Any]:
866
829
  """Normalize a tools value for projection; empty (with a warning) when it cannot be.
867
830
 
@@ -1231,7 +1194,10 @@ class _AgentHooksAgentMiddleware(_AgentHooksMiddlewareBase, AgentMiddleware):
1231
1194
  f"got {type(inner).__name__}."
1232
1195
  )
1233
1196
  context.result = self._gated_agent_stream(
1234
- state, cast("ResponseStream[AgentResponseUpdate, AgentResponse[Any]]", inner), gate_handle
1197
+ context,
1198
+ state,
1199
+ cast("ResponseStream[AgentResponseUpdate, AgentResponse[Any]]", inner),
1200
+ gate_handle,
1235
1201
  )
1236
1202
  # The gated stream now owns the shutdown emission.
1237
1203
  shutdown_reason = None
@@ -1255,6 +1221,7 @@ class _AgentHooksAgentMiddleware(_AgentHooksMiddlewareBase, AgentMiddleware):
1255
1221
 
1256
1222
  def _gated_agent_stream(
1257
1223
  self,
1224
+ context: AgentContext,
1258
1225
  state: _RunState,
1259
1226
  inner: ResponseStream[AgentResponseUpdate, AgentResponse[Any]],
1260
1227
  gate_handle: _RunPersistenceGate,
@@ -1262,18 +1229,19 @@ class _AgentHooksAgentMiddleware(_AgentHooksMiddlewareBase, AgentMiddleware):
1262
1229
  """Guard a streaming run with a fail-closed buffered gate.
1263
1230
 
1264
1231
  The run is fully consumed (with the run state and the persistence gate active),
1265
- middleware stream hooks are applied by the combinator before the verdict, the
1232
+ middleware stream hooks are applied by the buffered enforcement helper before the verdict, the
1266
1233
  ``output`` verdict is applied to the finalized response, and deferred
1267
- persistence is released only after the verdict permits. The combinator owns the
1234
+ persistence is released only after the verdict permits. The helper owns the
1268
1235
  no-divergence rule: a transformed output (or any applied stream hooks)
1269
1236
  re-derives the released updates from the verdicted response.
1270
1237
  """
1271
1238
 
1272
- async def _consume() -> tuple[Sequence[AgentResponseUpdate], AgentResponse[Any]]:
1239
+ @contextlib.asynccontextmanager
1240
+ async def _consumption_scope() -> AsyncGenerator[None]:
1273
1241
  run_token = _RUN_STATE.set(state)
1274
1242
  try:
1275
1243
  with gate_handle:
1276
- final = await inner.get_final_response()
1244
+ yield
1277
1245
  except asyncio.CancelledError:
1278
1246
  await self._emit_shutdown(state, "cancelled")
1279
1247
  raise
@@ -1290,40 +1258,32 @@ class _AgentHooksAgentMiddleware(_AgentHooksMiddlewareBase, AgentMiddleware):
1290
1258
  raise
1291
1259
  finally:
1292
1260
  _RUN_STATE.reset(run_token)
1293
- return list(inner.updates), final
1294
1261
 
1295
- async def _gate(
1296
- _updates: list[AgentResponseUpdate], final: AgentResponse[Any]
1297
- ) -> tuple[AgentResponse[Any], bool]:
1298
- from agent_hooks import InterceptionBlocked
1262
+ async def _transform(final: AgentResponse[Any]) -> AgentResponse[Any] | None:
1263
+ if not isinstance(final, AgentResponse):
1264
+ raise MiddlewareException(
1265
+ f"agent-hooks cannot guard a streamed run result of type {type(final).__name__}; "
1266
+ "the output interception point was not emitted."
1267
+ )
1268
+ transformed = await self._emit_output(state, final)
1269
+ return final if transformed else None
1299
1270
 
1300
- try:
1301
- if not isinstance(final, AgentResponse):
1302
- raise MiddlewareException(
1303
- f"agent-hooks cannot guard a streamed run result of type {type(final).__name__}; "
1304
- "the output interception point was not emitted."
1305
- )
1306
- transformed = await self._emit_output(state, final)
1307
- await gate_handle.flush()
1308
- await self._emit_shutdown(state, "completed")
1309
- return final, transformed
1310
- except InterceptionBlocked:
1311
- gate_handle.drop()
1312
- await self._emit_shutdown(state, "error")
1313
- raise
1314
- except asyncio.CancelledError:
1315
- await self._emit_shutdown(state, "cancelled")
1316
- raise
1317
- except BaseException:
1318
- await self._emit_shutdown(state, "error")
1319
- raise
1271
+ async def _release() -> None:
1272
+ await gate_handle.flush()
1273
+ await self._emit_shutdown(state, "completed")
1320
1274
 
1321
- return cast(
1322
- "ResponseStream[AgentResponseUpdate, AgentResponse[Any]]",
1323
- cast(Any, ResponseStream).buffered_and_gated(
1324
- consume=_consume, gate=_gate, rederive=_agent_updates_from_response
1325
- ),
1326
- )
1275
+ async def _release_error(exc: BaseException) -> None:
1276
+ gate_handle.drop()
1277
+ await self._emit_shutdown(state, "cancelled" if isinstance(exc, asyncio.CancelledError) else "error")
1278
+
1279
+ context._stream_terminal_result_transforms.append(_transform) # pyright: ignore[reportPrivateUsage]
1280
+ context._stream_terminal_result_to_updates = AgentResponse.to_updates # pyright: ignore[reportPrivateUsage]
1281
+ context._stream_terminal_result_is_authoritative = True # pyright: ignore[reportPrivateUsage]
1282
+ context._stream_release_hooks.append(_release) # pyright: ignore[reportPrivateUsage]
1283
+ context._stream_release_error_hooks.append(_release_error) # pyright: ignore[reportPrivateUsage]
1284
+ context.stream_buffer_updates = True
1285
+ context.stream_consumption_context_manager_factories.append(_consumption_scope)
1286
+ return inner
1327
1287
 
1328
1288
 
1329
1289
  class _AgentHooksChatMiddleware(_AgentHooksMiddlewareBase, ChatMiddleware):
@@ -1367,7 +1327,11 @@ class _AgentHooksChatMiddleware(_AgentHooksMiddlewareBase, ChatMiddleware):
1367
1327
  result = context.result
1368
1328
  if isinstance(result, ResponseStream):
1369
1329
  context.result = self._gated_chat_stream(
1370
- state, model_id, cast("ResponseStream[ChatResponseUpdate, ChatResponse[Any]]", result), gate
1330
+ context,
1331
+ state,
1332
+ model_id,
1333
+ cast("ResponseStream[ChatResponseUpdate, ChatResponse[Any]]", result),
1334
+ gate,
1371
1335
  )
1372
1336
  elif isinstance(result, ChatResponse):
1373
1337
  try:
@@ -1406,6 +1370,7 @@ class _AgentHooksChatMiddleware(_AgentHooksMiddlewareBase, ChatMiddleware):
1406
1370
 
1407
1371
  def _gated_chat_stream(
1408
1372
  self,
1373
+ context: ChatContext,
1409
1374
  state: _RunState,
1410
1375
  model_id: str,
1411
1376
  inner: ResponseStream[ChatResponseUpdate, ChatResponse[Any]],
@@ -1417,39 +1382,38 @@ class _AgentHooksChatMiddleware(_AgentHooksMiddlewareBase, ChatMiddleware):
1417
1382
  emitted, and nothing (updates or tool calls) is released beforehand. A deny
1418
1383
  raises before any update egresses, and per-service-call history persistence
1419
1384
  deferred by the run persistence gate is released only after the verdict
1420
- permits. The combinator owns the no-divergence rule: a transformed response
1385
+ permits. The buffered enforcement helper owns the no-divergence rule: a transformed response
1421
1386
  (or any applied stream hooks) re-derives the released updates from it.
1422
1387
  """
1423
1388
 
1424
- async def _consume() -> tuple[Sequence[ChatResponseUpdate], ChatResponse[Any]]:
1389
+ @contextlib.asynccontextmanager
1390
+ async def _consumption_scope() -> AsyncGenerator[None]:
1425
1391
  with gate_handle:
1426
- response = await inner.get_final_response()
1427
- return list(inner.updates), response
1428
-
1429
- async def _gate(_updates: list[ChatResponseUpdate], final: ChatResponse[Any]) -> tuple[ChatResponse[Any], bool]:
1430
- from agent_hooks import InterceptionBlocked
1392
+ yield
1431
1393
 
1394
+ async def _transform(final: ChatResponse[Any]) -> ChatResponse[Any] | None:
1432
1395
  if not isinstance(final, ChatResponse):
1433
1396
  raise MiddlewareException(
1434
1397
  f"agent-hooks cannot guard a streamed chat result of type {type(final).__name__}; "
1435
1398
  "the post_model_call interception point was not emitted."
1436
1399
  )
1437
- try:
1438
- changed = await self._emit_post_model_call(state, model_id, final)
1439
- except InterceptionBlocked:
1440
- # §6.1: the deferred per-service-call persistence for the denied
1441
- # response is dropped, never executed.
1442
- gate_handle.drop()
1443
- raise
1400
+ changed = await self._emit_post_model_call(state, model_id, final)
1401
+ return final if changed else None
1402
+
1403
+ async def _release() -> None:
1444
1404
  await gate_handle.flush()
1445
- return final, changed
1446
1405
 
1447
- return cast(
1448
- "ResponseStream[ChatResponseUpdate, ChatResponse[Any]]",
1449
- cast(Any, ResponseStream).buffered_and_gated(
1450
- consume=_consume, gate=_gate, rederive=_chat_updates_from_response
1451
- ),
1452
- )
1406
+ def _release_error(_: BaseException) -> None:
1407
+ gate_handle.drop()
1408
+
1409
+ context._stream_terminal_result_transforms.append(_transform) # pyright: ignore[reportPrivateUsage]
1410
+ context._stream_terminal_result_to_updates = ChatResponse.to_updates # pyright: ignore[reportPrivateUsage]
1411
+ context._stream_terminal_result_is_authoritative = True # pyright: ignore[reportPrivateUsage]
1412
+ context._stream_release_hooks.append(_release) # pyright: ignore[reportPrivateUsage]
1413
+ context._stream_release_error_hooks.append(_release_error) # pyright: ignore[reportPrivateUsage]
1414
+ context.stream_buffer_updates = True
1415
+ context.stream_consumption_context_manager_factories.append(_consumption_scope)
1416
+ return inner
1453
1417
 
1454
1418
 
1455
1419
  class _AgentHooksFunctionMiddleware(_AgentHooksMiddlewareBase, FunctionMiddleware):