aip-agents-binary 0.6.3__py3-none-manylinux_2_31_x86_64.whl → 0.6.5__py3-none-manylinux_2_31_x86_64.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.
Potentially problematic release.
This version of aip-agents-binary might be problematic. Click here for more details.
- aip_agents/agent/__init__.py +44 -4
- aip_agents/agent/base_langgraph_agent.py +26 -6
- aip_agents/agent/langgraph_memory_enhancer_agent.py +368 -34
- aip_agents/agent/langgraph_react_agent.py +30 -6
- aip_agents/mcp/client/__init__.py +38 -2
- aip_agents/mcp/client/transports.py +5 -1
- aip_agents/memory/adapters/base_adapter.py +94 -0
- aip_agents/sentry/sentry.py +29 -8
- aip_agents/tools/memory_search/__init__.py +8 -1
- aip_agents/tools/memory_search/mem0.py +108 -1
- aip_agents/tools/memory_search/schema.py +33 -0
- aip_agents/tools/memory_search_tool.py +8 -0
- {aip_agents_binary-0.6.3.dist-info → aip_agents_binary-0.6.5.dist-info}/METADATA +4 -16
- {aip_agents_binary-0.6.3.dist-info → aip_agents_binary-0.6.5.dist-info}/RECORD +16 -17
- aip_agents/examples/demo_memory_recall.py +0 -401
- {aip_agents_binary-0.6.3.dist-info → aip_agents_binary-0.6.5.dist-info}/WHEEL +0 -0
- {aip_agents_binary-0.6.3.dist-info → aip_agents_binary-0.6.5.dist-info}/top_level.txt +0 -0
aip_agents/agent/__init__.py
CHANGED
|
@@ -6,13 +6,25 @@ Author:
|
|
|
6
6
|
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import TYPE_CHECKING, Any
|
|
12
|
+
|
|
9
13
|
from aip_agents.agent.base_agent import BaseAgent
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from aip_agents.agent.google_adk_agent import GoogleADKAgent
|
|
17
|
+
from aip_agents.agent.langflow_agent import LangflowAgent
|
|
10
18
|
from aip_agents.agent.base_langgraph_agent import BaseLangGraphAgent
|
|
11
|
-
from aip_agents.agent.google_adk_agent import GoogleADKAgent
|
|
12
19
|
from aip_agents.agent.interface import AgentInterface
|
|
13
|
-
from aip_agents.agent.
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
from aip_agents.agent.langgraph_memory_enhancer_agent import (
|
|
21
|
+
LangGraphMemoryEnhancerAgent,
|
|
22
|
+
)
|
|
23
|
+
from aip_agents.agent.langgraph_react_agent import (
|
|
24
|
+
LangChainAgent,
|
|
25
|
+
LangGraphAgent,
|
|
26
|
+
LangGraphReactAgent,
|
|
27
|
+
)
|
|
16
28
|
|
|
17
29
|
__all__ = [
|
|
18
30
|
"AgentInterface",
|
|
@@ -25,3 +37,31 @@ __all__ = [
|
|
|
25
37
|
"LangflowAgent",
|
|
26
38
|
"LangGraphMemoryEnhancerAgent",
|
|
27
39
|
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def __getattr__(name: str) -> Any:
|
|
43
|
+
"""Lazy import of heavy agent implementations.
|
|
44
|
+
|
|
45
|
+
This avoids importing heavy dependencies (Google ADK, etc.)
|
|
46
|
+
when they are not needed.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
name: Attribute name to import.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
The requested class.
|
|
53
|
+
|
|
54
|
+
Raises:
|
|
55
|
+
AttributeError: If attribute is not found.
|
|
56
|
+
"""
|
|
57
|
+
if name == "GoogleADKAgent":
|
|
58
|
+
from aip_agents.agent.google_adk_agent import (
|
|
59
|
+
GoogleADKAgent as _GoogleADKAgent,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
return _GoogleADKAgent
|
|
63
|
+
elif name == "LangflowAgent":
|
|
64
|
+
from aip_agents.agent.langflow_agent import LangflowAgent as _LangflowAgent
|
|
65
|
+
|
|
66
|
+
return _LangflowAgent
|
|
67
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
|
@@ -455,6 +455,14 @@ class BaseLangGraphAgent(BaseAgent):
|
|
|
455
455
|
|
|
456
456
|
future.add_done_callback(_log_completion)
|
|
457
457
|
|
|
458
|
+
def _should_save_interaction(self, final_state: dict[str, Any] | None) -> bool:
|
|
459
|
+
"""Return True when interaction should be saved to memory.
|
|
460
|
+
|
|
461
|
+
Subclasses can override this to skip persistence for specific response types.
|
|
462
|
+
"""
|
|
463
|
+
del final_state
|
|
464
|
+
return True
|
|
465
|
+
|
|
458
466
|
def _resolve_and_validate_tools(self) -> list[BaseTool]:
|
|
459
467
|
"""Resolve and validate regular tools for LangGraph usage.
|
|
460
468
|
|
|
@@ -898,7 +906,12 @@ class BaseLangGraphAgent(BaseAgent):
|
|
|
898
906
|
formatted_output = self._format_graph_output(final_state_result)
|
|
899
907
|
|
|
900
908
|
try:
|
|
901
|
-
self.
|
|
909
|
+
if self._should_save_interaction(final_state_result):
|
|
910
|
+
self._memory_save_interaction(
|
|
911
|
+
user_text=query,
|
|
912
|
+
ai_text=formatted_output,
|
|
913
|
+
memory_user_id=memory_user_id,
|
|
914
|
+
)
|
|
902
915
|
except Exception:
|
|
903
916
|
pass
|
|
904
917
|
|
|
@@ -2442,7 +2455,7 @@ class BaseLangGraphAgent(BaseAgent):
|
|
|
2442
2455
|
and isinstance(context.last_final_content, str)
|
|
2443
2456
|
and context.last_final_content
|
|
2444
2457
|
)
|
|
2445
|
-
if should_save_early:
|
|
2458
|
+
if should_save_early and self._should_save_interaction(context.final_state):
|
|
2446
2459
|
try:
|
|
2447
2460
|
logger.info(
|
|
2448
2461
|
"Agent '%s': A2A persisting memory early (len=%d) for user_id='%s'",
|
|
@@ -2461,6 +2474,8 @@ class BaseLangGraphAgent(BaseAgent):
|
|
|
2461
2474
|
context.saved_memory = True
|
|
2462
2475
|
except Exception:
|
|
2463
2476
|
pass
|
|
2477
|
+
elif should_save_early:
|
|
2478
|
+
context.saved_memory = True
|
|
2464
2479
|
except Exception:
|
|
2465
2480
|
pass
|
|
2466
2481
|
|
|
@@ -2492,10 +2507,15 @@ class BaseLangGraphAgent(BaseAgent):
|
|
|
2492
2507
|
)
|
|
2493
2508
|
except Exception:
|
|
2494
2509
|
pass
|
|
2495
|
-
self.
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2510
|
+
if self._should_save_interaction(context.final_state):
|
|
2511
|
+
self._memory_save_interaction(
|
|
2512
|
+
user_text=context.original_query,
|
|
2513
|
+
ai_text=final_text,
|
|
2514
|
+
memory_user_id=context.memory_user_id,
|
|
2515
|
+
)
|
|
2516
|
+
context.saved_memory = True
|
|
2517
|
+
else:
|
|
2518
|
+
context.saved_memory = True
|
|
2499
2519
|
except Exception:
|
|
2500
2520
|
pass
|
|
2501
2521
|
|