aip-agents-binary 0.5.25__py3-none-macosx_13_0_arm64.whl → 0.6.8__py3-none-macosx_13_0_arm64.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.
Files changed (109) hide show
  1. aip_agents/agent/__init__.py +44 -4
  2. aip_agents/agent/base_langgraph_agent.py +163 -74
  3. aip_agents/agent/base_langgraph_agent.pyi +3 -2
  4. aip_agents/agent/langgraph_memory_enhancer_agent.py +368 -34
  5. aip_agents/agent/langgraph_memory_enhancer_agent.pyi +3 -2
  6. aip_agents/agent/langgraph_react_agent.py +329 -22
  7. aip_agents/agent/langgraph_react_agent.pyi +41 -2
  8. aip_agents/examples/hello_world_ptc.py +49 -0
  9. aip_agents/examples/hello_world_ptc.pyi +5 -0
  10. aip_agents/examples/hello_world_ptc_custom_tools.py +83 -0
  11. aip_agents/examples/hello_world_ptc_custom_tools.pyi +7 -0
  12. aip_agents/examples/hello_world_tool_output_client.py +9 -0
  13. aip_agents/examples/tools/multiply_tool.py +43 -0
  14. aip_agents/examples/tools/multiply_tool.pyi +18 -0
  15. aip_agents/guardrails/engines/base.py +6 -6
  16. aip_agents/mcp/client/__init__.py +38 -2
  17. aip_agents/mcp/client/connection_manager.py +36 -1
  18. aip_agents/mcp/client/connection_manager.pyi +3 -0
  19. aip_agents/mcp/client/persistent_session.py +318 -68
  20. aip_agents/mcp/client/persistent_session.pyi +9 -0
  21. aip_agents/mcp/client/transports.py +37 -2
  22. aip_agents/mcp/client/transports.pyi +9 -0
  23. aip_agents/memory/adapters/base_adapter.py +98 -0
  24. aip_agents/memory/adapters/base_adapter.pyi +25 -0
  25. aip_agents/ptc/__init__.py +87 -0
  26. aip_agents/ptc/__init__.pyi +14 -0
  27. aip_agents/ptc/custom_tools.py +473 -0
  28. aip_agents/ptc/custom_tools.pyi +184 -0
  29. aip_agents/ptc/custom_tools_payload.py +400 -0
  30. aip_agents/ptc/custom_tools_payload.pyi +31 -0
  31. aip_agents/ptc/custom_tools_templates/__init__.py +1 -0
  32. aip_agents/ptc/custom_tools_templates/__init__.pyi +0 -0
  33. aip_agents/ptc/custom_tools_templates/custom_build_function.py.template +23 -0
  34. aip_agents/ptc/custom_tools_templates/custom_init.py.template +15 -0
  35. aip_agents/ptc/custom_tools_templates/custom_invoke.py.template +60 -0
  36. aip_agents/ptc/custom_tools_templates/custom_registry.py.template +87 -0
  37. aip_agents/ptc/custom_tools_templates/custom_sources_init.py.template +7 -0
  38. aip_agents/ptc/custom_tools_templates/custom_wrapper.py.template +19 -0
  39. aip_agents/ptc/doc_gen.py +122 -0
  40. aip_agents/ptc/doc_gen.pyi +40 -0
  41. aip_agents/ptc/exceptions.py +57 -0
  42. aip_agents/ptc/exceptions.pyi +37 -0
  43. aip_agents/ptc/executor.py +261 -0
  44. aip_agents/ptc/executor.pyi +99 -0
  45. aip_agents/ptc/mcp/__init__.py +45 -0
  46. aip_agents/ptc/mcp/__init__.pyi +7 -0
  47. aip_agents/ptc/mcp/sandbox_bridge.py +668 -0
  48. aip_agents/ptc/mcp/sandbox_bridge.pyi +47 -0
  49. aip_agents/ptc/mcp/templates/__init__.py +1 -0
  50. aip_agents/ptc/mcp/templates/__init__.pyi +0 -0
  51. aip_agents/ptc/mcp/templates/mcp_client.py.template +239 -0
  52. aip_agents/ptc/naming.py +196 -0
  53. aip_agents/ptc/naming.pyi +85 -0
  54. aip_agents/ptc/payload.py +26 -0
  55. aip_agents/ptc/payload.pyi +15 -0
  56. aip_agents/ptc/prompt_builder.py +673 -0
  57. aip_agents/ptc/prompt_builder.pyi +59 -0
  58. aip_agents/ptc/ptc_helper.py +16 -0
  59. aip_agents/ptc/ptc_helper.pyi +1 -0
  60. aip_agents/ptc/sandbox_bridge.py +256 -0
  61. aip_agents/ptc/sandbox_bridge.pyi +38 -0
  62. aip_agents/ptc/template_utils.py +33 -0
  63. aip_agents/ptc/template_utils.pyi +13 -0
  64. aip_agents/ptc/templates/__init__.py +1 -0
  65. aip_agents/ptc/templates/__init__.pyi +0 -0
  66. aip_agents/ptc/templates/ptc_helper.py.template +134 -0
  67. aip_agents/ptc/tool_def_helpers.py +101 -0
  68. aip_agents/ptc/tool_def_helpers.pyi +38 -0
  69. aip_agents/ptc/tool_enrichment.py +163 -0
  70. aip_agents/ptc/tool_enrichment.pyi +60 -0
  71. aip_agents/sandbox/__init__.py +43 -0
  72. aip_agents/sandbox/__init__.pyi +5 -0
  73. aip_agents/sandbox/defaults.py +205 -0
  74. aip_agents/sandbox/defaults.pyi +30 -0
  75. aip_agents/sandbox/e2b_runtime.py +295 -0
  76. aip_agents/sandbox/e2b_runtime.pyi +57 -0
  77. aip_agents/sandbox/template_builder.py +131 -0
  78. aip_agents/sandbox/template_builder.pyi +36 -0
  79. aip_agents/sandbox/types.py +24 -0
  80. aip_agents/sandbox/types.pyi +14 -0
  81. aip_agents/sandbox/validation.py +50 -0
  82. aip_agents/sandbox/validation.pyi +20 -0
  83. aip_agents/sentry/sentry.py +29 -8
  84. aip_agents/sentry/sentry.pyi +3 -2
  85. aip_agents/tools/__init__.py +13 -2
  86. aip_agents/tools/__init__.pyi +3 -1
  87. aip_agents/tools/browser_use/browser_use_tool.py +8 -0
  88. aip_agents/tools/browser_use/streaming.py +2 -0
  89. aip_agents/tools/date_range_tool.py +554 -0
  90. aip_agents/tools/date_range_tool.pyi +21 -0
  91. aip_agents/tools/execute_ptc_code.py +357 -0
  92. aip_agents/tools/execute_ptc_code.pyi +90 -0
  93. aip_agents/tools/memory_search/__init__.py +8 -1
  94. aip_agents/tools/memory_search/__init__.pyi +3 -3
  95. aip_agents/tools/memory_search/mem0.py +114 -1
  96. aip_agents/tools/memory_search/mem0.pyi +11 -1
  97. aip_agents/tools/memory_search/schema.py +33 -0
  98. aip_agents/tools/memory_search/schema.pyi +10 -0
  99. aip_agents/tools/memory_search_tool.py +8 -0
  100. aip_agents/tools/memory_search_tool.pyi +2 -2
  101. aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.py +26 -1
  102. aip_agents/utils/langgraph/tool_output_management.py +80 -0
  103. aip_agents/utils/langgraph/tool_output_management.pyi +37 -0
  104. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/METADATA +9 -19
  105. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/RECORD +107 -41
  106. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/WHEEL +1 -1
  107. aip_agents/examples/demo_memory_recall.py +0 -401
  108. aip_agents/examples/demo_memory_recall.pyi +0 -58
  109. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/top_level.txt +0 -0
@@ -6,6 +6,7 @@ Authors:
6
6
 
7
7
  import inspect
8
8
  import os
9
+ from typing import Any
9
10
 
10
11
  from bosa_core.telemetry import (
11
12
  FastAPIConfig,
@@ -20,7 +21,7 @@ from bosa_core.telemetry.opentelemetry.instrument.functions import (
20
21
  from dotenv import load_dotenv
21
22
  from fastapi import FastAPI
22
23
 
23
- from aip_agents.agent import BaseAgent, GoogleADKAgent, LangChainAgent, LangGraphAgent
24
+ from aip_agents.agent import BaseAgent, LangChainAgent, LangGraphAgent
24
25
  from aip_agents.utils.logger import get_logger
25
26
 
26
27
  load_dotenv()
@@ -35,12 +36,32 @@ VERSION_NUMBER = os.getenv("VERSION_NUMBER", "0.0.0")
35
36
  BUILD_NUMBER = os.getenv("BUILD_NUMBER", "0")
36
37
  USE_OPENTELEMETRY = os.getenv("USE_OPENTELEMETRY", "true").lower() == "true"
37
38
 
38
- CLASSES_TO_INSTRUMENT = [
39
- BaseAgent,
40
- LangGraphAgent,
41
- LangChainAgent,
42
- GoogleADKAgent,
43
- ]
39
+ # Lazy import of GoogleADKAgent to avoid heavy dependencies when not needed.
40
+ # This is initialized lazily by _get_classes_to_instrument() and can be
41
+ # patched by tests for mocking purposes.
42
+ CLASSES_TO_INSTRUMENT: list[type[Any]] | None = None
43
+
44
+
45
+ def _get_classes_to_instrument() -> list[type[Any]]:
46
+ """Get the list of classes to instrument.
47
+
48
+ This lazily imports GoogleADKAgent only when telemetry is being set up,
49
+ avoiding the heavy Google ADK dependencies during module import.
50
+
51
+ Returns:
52
+ List of agent classes to instrument.
53
+ """
54
+ global CLASSES_TO_INSTRUMENT
55
+ if CLASSES_TO_INSTRUMENT is None:
56
+ from aip_agents.agent import GoogleADKAgent
57
+
58
+ CLASSES_TO_INSTRUMENT = [
59
+ BaseAgent,
60
+ LangGraphAgent,
61
+ LangChainAgent,
62
+ GoogleADKAgent,
63
+ ]
64
+ return CLASSES_TO_INSTRUMENT
44
65
 
45
66
 
46
67
  def get_all_methods(cls: type) -> list:
@@ -66,7 +87,7 @@ def instrument_gl_functions() -> None:
66
87
  if BOSAFunctionsInstrumentor is None:
67
88
  return
68
89
  agent_methods = []
69
- for cls in CLASSES_TO_INSTRUMENT:
90
+ for cls in _get_classes_to_instrument():
70
91
  agent_methods.extend(get_all_methods(cls))
71
92
  BOSAFunctionsInstrumentor().instrument(methods=agent_methods)
72
93
 
@@ -1,7 +1,8 @@
1
1
  from _typeshed import Incomplete
2
- from aip_agents.agent import BaseAgent as BaseAgent, GoogleADKAgent as GoogleADKAgent, LangChainAgent as LangChainAgent, LangGraphAgent as LangGraphAgent
2
+ from aip_agents.agent import BaseAgent as BaseAgent, LangChainAgent as LangChainAgent, LangGraphAgent as LangGraphAgent
3
3
  from aip_agents.utils.logger import get_logger as get_logger
4
4
  from fastapi import FastAPI
5
+ from typing import Any
5
6
 
6
7
  logger: Incomplete
7
8
  SENTRY_DSN: Incomplete
@@ -10,7 +11,7 @@ SENTRY_PROJECT: Incomplete
10
11
  VERSION_NUMBER: Incomplete
11
12
  BUILD_NUMBER: Incomplete
12
13
  USE_OPENTELEMETRY: Incomplete
13
- CLASSES_TO_INSTRUMENT: Incomplete
14
+ CLASSES_TO_INSTRUMENT: list[type[Any]] | None
14
15
 
15
16
  def get_all_methods(cls) -> list:
16
17
  """Get all methods from a class.
@@ -3,8 +3,12 @@
3
3
  from importlib import import_module
4
4
  from typing import TYPE_CHECKING
5
5
 
6
+ from aip_agents.tools.date_range_tool import DateRangeTool
6
7
  from aip_agents.tools.gl_connector import GLConnectorTool
7
- from aip_agents.tools.gl_connector_tools import BOSA_AUTOMATED_TOOLS, GL_CONNECTORS_AUTOMATED_TOOLS
8
+ from aip_agents.tools.gl_connector_tools import (
9
+ BOSA_AUTOMATED_TOOLS,
10
+ GL_CONNECTORS_AUTOMATED_TOOLS,
11
+ )
8
12
  from aip_agents.tools.time_tool import TimeTool
9
13
  from aip_agents.tools.web_search import GoogleSerperTool
10
14
  from aip_agents.utils.logger import get_logger
@@ -17,6 +21,7 @@ __all__ = [
17
21
  "GLConnectorTool",
18
22
  "GoogleSerperTool",
19
23
  "TimeTool",
24
+ "DateRangeTool",
20
25
  ]
21
26
 
22
27
 
@@ -46,8 +51,14 @@ _register_optional("aip_agents.tools.code_sandbox", "E2BCodeSandboxTool")
46
51
  _register_optional("aip_agents.tools.document_loader", "DocxReaderTool")
47
52
  _register_optional("aip_agents.tools.document_loader", "ExcelReaderTool")
48
53
  _register_optional("aip_agents.tools.document_loader", "PDFReaderTool")
54
+ _register_optional("aip_agents.tools.execute_ptc_code", "create_execute_ptc_code_tool")
49
55
 
50
56
  if TYPE_CHECKING:
51
57
  from aip_agents.tools.browser_use import BrowserUseTool
52
58
  from aip_agents.tools.code_sandbox import E2BCodeSandboxTool
53
- from aip_agents.tools.document_loader import DocxReaderTool, ExcelReaderTool, PDFReaderTool
59
+ from aip_agents.tools.document_loader import (
60
+ DocxReaderTool,
61
+ ExcelReaderTool,
62
+ PDFReaderTool,
63
+ )
64
+ from aip_agents.tools.execute_ptc_code import create_execute_ptc_code_tool
@@ -1,9 +1,11 @@
1
1
  from aip_agents.tools.browser_use import BrowserUseTool as BrowserUseTool
2
2
  from aip_agents.tools.code_sandbox import E2BCodeSandboxTool as E2BCodeSandboxTool
3
+ from aip_agents.tools.date_range_tool import DateRangeTool as DateRangeTool
3
4
  from aip_agents.tools.document_loader import DocxReaderTool as DocxReaderTool, ExcelReaderTool as ExcelReaderTool, PDFReaderTool as PDFReaderTool
5
+ from aip_agents.tools.execute_ptc_code import create_execute_ptc_code_tool as create_execute_ptc_code_tool
4
6
  from aip_agents.tools.gl_connector import GLConnectorTool as GLConnectorTool
5
7
  from aip_agents.tools.gl_connector_tools import BOSA_AUTOMATED_TOOLS as BOSA_AUTOMATED_TOOLS, GL_CONNECTORS_AUTOMATED_TOOLS as GL_CONNECTORS_AUTOMATED_TOOLS
6
8
  from aip_agents.tools.time_tool import TimeTool as TimeTool
7
9
  from aip_agents.tools.web_search import GoogleSerperTool as GoogleSerperTool
8
10
 
9
- __all__ = ['BOSA_AUTOMATED_TOOLS', 'GL_CONNECTORS_AUTOMATED_TOOLS', 'GLConnectorTool', 'GoogleSerperTool', 'TimeTool', 'BrowserUseTool', 'E2BCodeSandboxTool', 'DocxReaderTool', 'ExcelReaderTool', 'PDFReaderTool']
11
+ __all__ = ['BOSA_AUTOMATED_TOOLS', 'GL_CONNECTORS_AUTOMATED_TOOLS', 'GLConnectorTool', 'GoogleSerperTool', 'TimeTool', 'DateRangeTool', 'BrowserUseTool', 'E2BCodeSandboxTool', 'DocxReaderTool', 'ExcelReaderTool', 'PDFReaderTool', 'create_execute_ptc_code_tool']
@@ -93,6 +93,7 @@ References:
93
93
  """
94
94
 
95
95
  import asyncio
96
+ import copy
96
97
  import json
97
98
  from collections.abc import Callable
98
99
  from typing import Any, Literal
@@ -556,13 +557,20 @@ class BrowserUseTool(BaseTool):
556
557
  iframe_event = yield_iframe_activity(streaming_state.debug_url, "Receive streaming URL")
557
558
  self._log_stream_event("iframe_start", iframe_event)
558
559
  yield iframe_event
560
+ last_done_event: dict | None = None
559
561
  async for event in self._stream_agent_with_markers(agent, streaming_state, recorder):
560
562
  self._log_stream_event("agent_event", event)
563
+ tool_info = event.get("tool_info") if isinstance(event, dict) else None
564
+ tool_calls = tool_info.get("tool_calls", []) if isinstance(tool_info, dict) else []
565
+ if any(call.get("name") == "done" for call in tool_calls if isinstance(call, dict)):
566
+ last_done_event = event
561
567
  yield event
562
568
  recording_event = self._recording_event(streaming_state)
563
569
  if recording_event:
564
570
  self._log_stream_event("recording_event", recording_event)
565
571
  yield recording_event
572
+ if last_done_event:
573
+ yield copy.deepcopy(last_done_event)
566
574
  finally:
567
575
  await self._release_session(session, client)
568
576
 
@@ -223,6 +223,8 @@ def create_step_response(
223
223
  if is_done:
224
224
  final_tool = _get_done_tool_for_final_response(agent, tool_calls_dict)
225
225
  final_output = final_tool.get("output") or TASK_COMPLETED_MESSAGE
226
+ if not any(call.get("name") == "done" for call in tool_calls_dict):
227
+ tool_calls_dict.append(final_tool)
226
228
  tool_info = {
227
229
  "name": PRIMARY_TOOL_NAME,
228
230
  "args": final_tool.get("args", {}),