aip-agents-binary 0.4.8__cp311-cp311-win_amd64.whl → 0.5.4__cp311-cp311-win_amd64.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.
- aip_agents/__init__.pyi +19 -0
- aip_agents/a2a/__init__.pyi +1 -1
- aip_agents/a2a/server/base_executor.pyi +6 -6
- aip_agents/a2a/server/google_adk_executor.pyi +11 -11
- aip_agents/a2a/server/langflow_executor.pyi +43 -0
- aip_agents/a2a/server/langgraph_executor.pyi +10 -11
- aip_agents/a2a/types.pyi +54 -47
- aip_agents/agent/__init__.pyi +3 -1
- aip_agents/agent/base_agent.pyi +24 -8
- aip_agents/agent/base_langgraph_agent.pyi +67 -25
- aip_agents/agent/google_adk_agent.pyi +34 -21
- aip_agents/agent/google_adk_constants.pyi +3 -0
- aip_agents/agent/hitl/__init__.pyi +6 -0
- aip_agents/agent/hitl/config.pyi +15 -0
- aip_agents/agent/hitl/langgraph_hitl_mixin.pyi +42 -0
- aip_agents/agent/hitl/manager.pyi +199 -0
- aip_agents/agent/hitl/models.pyi +3 -0
- aip_agents/agent/hitl/prompt/__init__.pyi +4 -0
- aip_agents/agent/hitl/prompt/base.pyi +24 -0
- aip_agents/agent/hitl/prompt/deferred.pyi +30 -0
- aip_agents/agent/interface.pyi +5 -5
- aip_agents/agent/interfaces.pyi +44 -0
- aip_agents/agent/langflow_agent.pyi +133 -0
- aip_agents/agent/langgraph_memory_enhancer_agent.pyi +49 -0
- aip_agents/agent/langgraph_react_agent.pyi +50 -57
- aip_agents/agent/system_instruction_context.pyi +13 -0
- aip_agents/clients/__init__.pyi +4 -0
- aip_agents/clients/langflow/__init__.pyi +4 -0
- aip_agents/clients/langflow/client.pyi +140 -0
- aip_agents/clients/langflow/types.pyi +7 -0
- aip_agents/constants.pyi +1 -0
- aip_agents/examples/compare_streaming_client.pyi +48 -0
- aip_agents/examples/compare_streaming_server.pyi +18 -0
- aip_agents/examples/demo_memory_recall.pyi +58 -0
- aip_agents/examples/hello_world_a2a_google_adk_client.pyi +2 -2
- aip_agents/examples/hello_world_a2a_google_adk_client_agent.pyi +2 -2
- aip_agents/examples/hello_world_a2a_google_adk_client_streaming.pyi +2 -2
- aip_agents/examples/hello_world_a2a_google_adk_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langchain_client.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_client_agent.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_client_lm_invoker.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_client_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_reference_client_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_reference_server.pyi +8 -3
- aip_agents/examples/hello_world_a2a_langchain_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langchain_server_lm_invoker.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langflow_client.pyi +9 -0
- aip_agents/examples/hello_world_a2a_langflow_server.pyi +14 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_artifact_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langgraph_client.pyi +2 -2
- aip_agents/examples/hello_world_a2a_langgraph_client_agent.pyi +2 -2
- aip_agents/examples/hello_world_a2a_langgraph_client_agent_lm_invoker.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming.pyi +3 -3
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_lm_invoker.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_tool_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langgraph_server_lm_invoker.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langgraph_server_tool_streaming.pyi +7 -2
- aip_agents/examples/hello_world_a2a_mcp_langgraph.pyi +1 -1
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_client.pyi +31 -6
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_server.pyi +33 -5
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_client.pyi +1 -1
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_server_lm_invoker.pyi +7 -2
- aip_agents/examples/hello_world_langchain_mcp_http_interactive.pyi +16 -0
- aip_agents/examples/hello_world_langchain_mcp_multi_server.pyi +18 -0
- aip_agents/examples/hello_world_langflow_agent.pyi +35 -0
- aip_agents/examples/hello_world_model_switch_cli.pyi +18 -3
- aip_agents/examples/hello_world_pii_logger.pyi +1 -1
- aip_agents/examples/hello_world_sentry.pyi +1 -1
- aip_agents/examples/hello_world_step_limits.pyi +17 -0
- aip_agents/examples/hello_world_stock_a2a_server.pyi +7 -2
- aip_agents/examples/hello_world_tool_output_client.pyi +1 -1
- aip_agents/examples/hello_world_tool_output_server.pyi +7 -2
- aip_agents/examples/hitl_demo.pyi +67 -0
- aip_agents/examples/pii_demo_langgraph_client.pyi +5 -0
- aip_agents/examples/pii_demo_langgraph_server.pyi +20 -0
- aip_agents/examples/pii_demo_multi_agent_client.pyi +5 -0
- aip_agents/examples/pii_demo_multi_agent_server.pyi +40 -0
- aip_agents/examples/todolist_planning_a2a_langchain_client.pyi +5 -0
- aip_agents/examples/todolist_planning_a2a_langgraph_server.pyi +19 -0
- aip_agents/examples/tools/__init__.pyi +3 -1
- aip_agents/examples/tools/adk_weather_tool.pyi +1 -1
- aip_agents/examples/tools/data_visualization_tool.pyi +2 -0
- aip_agents/examples/tools/image_artifact_tool.pyi +2 -0
- aip_agents/examples/tools/langchain_arithmetic_tools.pyi +7 -0
- aip_agents/examples/tools/langchain_currency_exchange_tool.pyi +0 -1
- aip_agents/examples/tools/langchain_graph_artifact_tool.pyi +2 -0
- aip_agents/examples/tools/langchain_weather_tool.pyi +1 -1
- aip_agents/examples/tools/langgraph_streaming_tool.pyi +1 -1
- aip_agents/examples/tools/mock_retrieval_tool.pyi +13 -0
- aip_agents/examples/tools/pii_demo_tools.pyi +54 -0
- aip_agents/examples/tools/random_chart_tool.pyi +20 -0
- aip_agents/examples/tools/stock_tools.pyi +18 -3
- aip_agents/mcp/client/__init__.pyi +4 -3
- aip_agents/mcp/client/base_mcp_client.pyi +148 -0
- aip_agents/mcp/client/connection_manager.pyi +48 -0
- aip_agents/mcp/client/google_adk/__init__.pyi +1 -1
- aip_agents/mcp/client/google_adk/client.pyi +50 -13
- aip_agents/mcp/client/langchain/__init__.pyi +1 -1
- aip_agents/mcp/client/langchain/client.pyi +47 -2
- aip_agents/mcp/client/persistent_session.pyi +113 -0
- aip_agents/mcp/client/session_pool.pyi +101 -0
- aip_agents/mcp/client/transports.pyi +123 -0
- aip_agents/mcp/utils/__init__.pyi +0 -0
- aip_agents/mcp/utils/config_validator.pyi +82 -0
- aip_agents/memory/adapters/__init__.pyi +4 -0
- aip_agents/memory/adapters/base_adapter.pyi +150 -0
- aip_agents/memory/adapters/mem0.pyi +22 -0
- aip_agents/memory/base.pyi +3 -3
- aip_agents/memory/constants.pyi +9 -0
- aip_agents/memory/factory.pyi +1 -1
- aip_agents/memory/guidance.pyi +3 -0
- aip_agents/middleware/__init__.pyi +5 -0
- aip_agents/middleware/base.pyi +71 -0
- aip_agents/middleware/manager.pyi +80 -0
- aip_agents/middleware/todolist.pyi +125 -0
- aip_agents/schema/__init__.pyi +9 -0
- aip_agents/schema/a2a.pyi +40 -0
- aip_agents/schema/agent.pyi +65 -0
- aip_agents/schema/hitl.pyi +89 -0
- aip_agents/schema/langgraph.pyi +28 -0
- aip_agents/schema/model_id.pyi +54 -0
- aip_agents/schema/step_limit.pyi +63 -0
- aip_agents/schema/storage.pyi +21 -0
- aip_agents/sentry/__init__.pyi +1 -1
- aip_agents/sentry/sentry.pyi +2 -2
- aip_agents/storage/base.pyi +1 -2
- aip_agents/storage/config.pyi +9 -46
- aip_agents/storage/providers/base.pyi +2 -3
- aip_agents/storage/providers/object_storage.pyi +1 -1
- aip_agents/tools/__init__.pyi +1 -1
- aip_agents/tools/bosa_tools.pyi +2 -2
- aip_agents/tools/constants.pyi +105 -100
- aip_agents/tools/memory_search/__init__.pyi +5 -0
- aip_agents/tools/memory_search/base.pyi +69 -0
- aip_agents/tools/memory_search/mem0.pyi +19 -0
- aip_agents/tools/memory_search/schema.pyi +15 -0
- aip_agents/tools/memory_search_tool.pyi +3 -0
- aip_agents/types/__init__.pyi +19 -3
- aip_agents/types/a2a_events.pyi +2 -73
- aip_agents/utils/__init__.pyi +7 -2
- aip_agents/utils/a2a_connector.pyi +14 -4
- aip_agents/utils/artifact_helpers.pyi +26 -2
- aip_agents/utils/constants.pyi +10 -0
- aip_agents/utils/datetime/__init__.pyi +4 -0
- aip_agents/utils/datetime/normalization.pyi +95 -0
- aip_agents/utils/datetime/timezone.pyi +48 -0
- aip_agents/utils/env_loader.pyi +2 -2
- aip_agents/utils/event_handler_registry.pyi +23 -0
- aip_agents/utils/final_response_builder.pyi +34 -0
- aip_agents/utils/formatter_llm_client.pyi +71 -0
- aip_agents/utils/langgraph/converter.pyi +1 -1
- aip_agents/utils/langgraph/tool_managers/a2a_tool_manager.pyi +2 -2
- aip_agents/utils/langgraph/tool_managers/base_tool_manager.pyi +2 -3
- aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.pyi +14 -8
- aip_agents/utils/langgraph/tool_output_management.pyi +15 -2
- aip_agents/utils/logger.pyi +60 -0
- aip_agents/utils/metadata/__init__.pyi +5 -0
- aip_agents/utils/metadata/activity_metadata_helper.pyi +25 -0
- aip_agents/utils/metadata/activity_narrative/__init__.pyi +7 -0
- aip_agents/utils/metadata/activity_narrative/builder.pyi +35 -0
- aip_agents/utils/metadata/activity_narrative/constants.pyi +10 -0
- aip_agents/utils/metadata/activity_narrative/context.pyi +32 -0
- aip_agents/utils/metadata/activity_narrative/formatters.pyi +48 -0
- aip_agents/utils/metadata/activity_narrative/utils.pyi +12 -0
- aip_agents/utils/metadata/schemas/__init__.pyi +4 -0
- aip_agents/utils/metadata/schemas/activity_schema.pyi +18 -0
- aip_agents/utils/metadata/schemas/thinking_schema.pyi +20 -0
- aip_agents/utils/metadata/thinking_metadata_helper.pyi +4 -0
- aip_agents/utils/metadata_helper.pyi +50 -34
- aip_agents/utils/name_preprocessor/base_name_preprocessor.pyi +1 -2
- aip_agents/utils/name_preprocessor/google_name_preprocessor.pyi +1 -1
- aip_agents/utils/name_preprocessor/name_preprocessor.pyi +4 -4
- aip_agents/utils/name_preprocessor/openai_name_preprocessor.pyi +1 -1
- aip_agents/utils/pii/__init__.pyi +5 -0
- aip_agents/utils/pii/pii_handler.pyi +86 -0
- aip_agents/utils/pii/pii_helper.pyi +69 -0
- aip_agents/utils/pii/uuid_deanonymizer_mapping.pyi +62 -0
- aip_agents/utils/reference_helper.pyi +38 -6
- aip_agents/utils/sse_chunk_transformer.pyi +166 -0
- aip_agents/utils/step_limit_manager.pyi +112 -0
- aip_agents/utils/token_usage_helper.pyi +1 -1
- aip_agents.cp311-win_amd64.pyd +0 -0
- aip_agents.pyi +92 -34
- aip_agents_binary-0.5.4.dist-info/METADATA +649 -0
- aip_agents_binary-0.5.4.dist-info/RECORD +242 -0
- {aip_agents_binary-0.4.8.dist-info → aip_agents_binary-0.5.4.dist-info}/WHEEL +2 -1
- aip_agents_binary-0.5.4.dist-info/top_level.txt +1 -0
- aip_agents/agent/types.pyi +0 -109
- aip_agents/examples/hello_world_a2a_mem0_coordinator_client.pyi +0 -14
- aip_agents/examples/hello_world_a2a_mem0_coordinator_server.pyi +0 -10
- aip_agents/examples/hello_world_a2a_multi_agent_coordinator_client.pyi +0 -19
- aip_agents/examples/hello_world_a2a_multi_agent_coordinator_client_streaming.pyi +0 -9
- aip_agents/examples/hello_world_a2a_multi_agent_coordinator_server.pyi +0 -12
- aip_agents/examples/hello_world_langgraph_bosa.pyi +0 -5
- aip_agents/examples/hello_world_mem0_coordinator.pyi +0 -5
- aip_agents/examples/tools/pr_details_bosa_tool.pyi +0 -26
- aip_agents/memory/mem0_memory.pyi +0 -94
- aip_agents/tools/base.pyi +0 -44
- aip_agents/tools/base_bosa_tools.pyi +0 -12
- aip_agents/tools/bosa_connector.pyi +0 -30
- aip_agents/tools/bosa_tools_interface.pyi +0 -26
- aip_agents/utils/logger_manager.pyi +0 -151
- aip_agents.build/.gitignore +0 -1
- aip_agents_binary-0.4.8.dist-info/METADATA +0 -280
- aip_agents_binary-0.4.8.dist-info/RECORD +0 -166
aip_agents/__init__.pyi
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
__all__ = ['a2a', 'agent', 'clients', 'constants', 'credentials', 'executor', 'memory', 'mcp', 'schema', 'sentry', 'storage', 'tools', 'types', 'utils', '__version__']
|
|
2
|
+
|
|
3
|
+
__version__: str
|
|
4
|
+
|
|
5
|
+
# Names in __all__ with no definition:
|
|
6
|
+
# a2a
|
|
7
|
+
# agent
|
|
8
|
+
# clients
|
|
9
|
+
# constants
|
|
10
|
+
# credentials
|
|
11
|
+
# executor
|
|
12
|
+
# mcp
|
|
13
|
+
# memory
|
|
14
|
+
# schema
|
|
15
|
+
# sentry
|
|
16
|
+
# storage
|
|
17
|
+
# tools
|
|
18
|
+
# types
|
|
19
|
+
# utils
|
aip_agents/a2a/__init__.pyi
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from .types import ArtifactType as ArtifactType, MimeType as MimeType, get_extension_from_mime_type as get_extension_from_mime_type, get_mime_type_from_filename as get_mime_type_from_filename
|
|
1
|
+
from aip_agents.a2a.types import ArtifactType as ArtifactType, MimeType as MimeType, get_extension_from_mime_type as get_extension_from_mime_type, get_mime_type_from_filename as get_mime_type_from_filename
|
|
2
2
|
|
|
3
3
|
__all__ = ['ArtifactType', 'MimeType', 'get_mime_type_from_filename', 'get_extension_from_mime_type']
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import abc
|
|
2
1
|
from _typeshed import Incomplete
|
|
3
|
-
from a2a.server.agent_execution import AgentExecutor as A2ASDKExecutor, RequestContext
|
|
4
|
-
from a2a.server.events.event_queue import EventQueue
|
|
2
|
+
from a2a.server.agent_execution import AgentExecutor as A2ASDKExecutor, RequestContext
|
|
3
|
+
from a2a.server.events.event_queue import EventQueue
|
|
5
4
|
from abc import ABC, abstractmethod
|
|
6
5
|
from aip_agents.types import A2AEvent as A2AEvent, A2AStreamEventType as A2AStreamEventType
|
|
7
6
|
from aip_agents.utils import serialize_references_for_metadata as serialize_references_for_metadata
|
|
8
7
|
from aip_agents.utils.artifact_helpers import ArtifactHandler as ArtifactHandler
|
|
9
|
-
from aip_agents.utils.
|
|
8
|
+
from aip_agents.utils.logger import get_logger as get_logger
|
|
10
9
|
from aip_agents.utils.metadata_helper import MetadataFieldKeys as MetadataFieldKeys
|
|
10
|
+
from collections.abc import Callable as Callable
|
|
11
11
|
from dataclasses import dataclass
|
|
12
12
|
from typing import Any
|
|
13
13
|
|
|
@@ -21,12 +21,12 @@ class StatusUpdateParams:
|
|
|
21
21
|
task_id: str | None = ...
|
|
22
22
|
context_id: str | None = ...
|
|
23
23
|
|
|
24
|
-
class BaseA2AExecutor(A2ASDKExecutor, ABC
|
|
24
|
+
class BaseA2AExecutor(A2ASDKExecutor, ABC):
|
|
25
25
|
"""Abstract base class for GLLM Agent framework's A2A server-side executors.
|
|
26
26
|
|
|
27
27
|
This class extends the A2A SDK's `AgentExecutor`. It serves as a common
|
|
28
28
|
foundation for specific executors tailored to different agent types within the
|
|
29
|
-
`
|
|
29
|
+
`aip-agents` framework, such as `LangGraphA2AExecutor` or
|
|
30
30
|
`GoogleADKA2AExecutor`.
|
|
31
31
|
|
|
32
32
|
Subclasses are required to implement the `execute` method to handle A2A
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
|
-
from a2a.server.agent_execution import RequestContext
|
|
3
|
-
from a2a.server.events.event_queue import EventQueue
|
|
4
|
-
from a2a.server.tasks import TaskUpdater as TaskUpdater
|
|
2
|
+
from a2a.server.agent_execution import RequestContext
|
|
3
|
+
from a2a.server.events.event_queue import EventQueue
|
|
5
4
|
from aip_agents.a2a.server.base_executor import BaseA2AExecutor as BaseA2AExecutor, StatusUpdateParams as StatusUpdateParams
|
|
6
|
-
from aip_agents.agent.
|
|
7
|
-
from aip_agents.
|
|
5
|
+
from aip_agents.agent.google_adk_constants import DEFAULT_AUTH_URL as DEFAULT_AUTH_URL
|
|
6
|
+
from aip_agents.agent.interfaces import GoogleADKAgentProtocol as GoogleADKAgentProtocol
|
|
7
|
+
from aip_agents.utils.logger import get_logger as get_logger
|
|
8
8
|
|
|
9
9
|
logger: Incomplete
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ class GoogleADKExecutor(BaseA2AExecutor):
|
|
|
12
12
|
'''A2A Executor for serving a `GoogleADKAgent`.
|
|
13
13
|
|
|
14
14
|
This executor bridges the A2A server protocol with a `aip_agents.agent.GoogleADKAgent`.
|
|
15
|
-
It handles incoming requests by invoking the agent\'s `arun_a2a_stream` method
|
|
15
|
+
It handles incoming requests by invoking the agent\'s `arun_a2a_stream` method,
|
|
16
16
|
which is specifically designed to yield ADK events in an A2A-compatible dictionary
|
|
17
17
|
format. This executor\'s `_process_stream` method is tailored to handle this stream,
|
|
18
18
|
including ADK-specific statuses like "auth_required", before delegating common
|
|
@@ -22,17 +22,17 @@ class GoogleADKExecutor(BaseA2AExecutor):
|
|
|
22
22
|
initial request checks, and cancellation.
|
|
23
23
|
|
|
24
24
|
Attributes:
|
|
25
|
-
agent (
|
|
25
|
+
agent (GoogleADKAgentProtocol): The instance of `GoogleADKAgent`-compatible class to execute.
|
|
26
26
|
'''
|
|
27
|
-
agent:
|
|
28
|
-
def __init__(self, agent:
|
|
27
|
+
agent: GoogleADKAgentProtocol
|
|
28
|
+
def __init__(self, agent: GoogleADKAgentProtocol) -> None:
|
|
29
29
|
"""Initializes the GoogleADKExecutor.
|
|
30
30
|
|
|
31
31
|
Args:
|
|
32
|
-
agent
|
|
32
|
+
agent: Component implementing `GoogleADKAgentProtocol`.
|
|
33
33
|
|
|
34
34
|
Raises:
|
|
35
|
-
TypeError: If
|
|
35
|
+
TypeError: If the provided agent does not satisfy `GoogleADKAgentProtocol`.
|
|
36
36
|
"""
|
|
37
37
|
async def execute(self, context: RequestContext, event_queue: EventQueue) -> None:
|
|
38
38
|
"""Processes an incoming agent request using the `GoogleADKAgent`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from a2a.server.agent_execution import RequestContext
|
|
3
|
+
from a2a.server.events.event_queue import EventQueue
|
|
4
|
+
from abc import ABC
|
|
5
|
+
from aip_agents.a2a.server.base_executor import BaseA2AExecutor as BaseA2AExecutor, StatusUpdateParams as StatusUpdateParams
|
|
6
|
+
from aip_agents.agent.interfaces import LangflowAgentProtocol as LangflowAgentProtocol
|
|
7
|
+
from aip_agents.utils.logger import get_logger as get_logger
|
|
8
|
+
|
|
9
|
+
logger: Incomplete
|
|
10
|
+
|
|
11
|
+
class LangflowA2AExecutor(BaseA2AExecutor, ABC):
|
|
12
|
+
"""A2A executor for Langflow agents.
|
|
13
|
+
|
|
14
|
+
This class extends BaseA2AExecutor to provide A2A execution capabilities
|
|
15
|
+
for Langflow agents. It follows the same patterns as LangGraphA2AExecutor
|
|
16
|
+
but handles Langflow-specific streaming and execution logic.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
agent: The LangflowAgent-compatible instance to be executed.
|
|
20
|
+
"""
|
|
21
|
+
agent: LangflowAgentProtocol
|
|
22
|
+
def __init__(self, langflow_agent_instance: LangflowAgentProtocol) -> None:
|
|
23
|
+
"""Initialize the LangflowA2AExecutor.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
langflow_agent_instance: Component implementing `LangflowAgentProtocol`.
|
|
27
|
+
|
|
28
|
+
Raises:
|
|
29
|
+
TypeError: If the agent does not satisfy `LangflowAgentProtocol`.
|
|
30
|
+
"""
|
|
31
|
+
async def execute(self, context: RequestContext, event_queue: EventQueue) -> None:
|
|
32
|
+
"""Process an incoming agent request using a Langflow agent.
|
|
33
|
+
|
|
34
|
+
This method handles the execution lifecycle for Langflow agents:
|
|
35
|
+
1. Performs initial validation and setup
|
|
36
|
+
2. Creates agent processing coroutine
|
|
37
|
+
3. Manages the execution lifecycle through BaseA2AExecutor
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
context: The A2A request context containing message details,
|
|
41
|
+
task ID, and context ID.
|
|
42
|
+
event_queue: The queue for sending A2A events back to the server.
|
|
43
|
+
"""
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
|
-
from a2a.server.agent_execution import RequestContext
|
|
3
|
-
from a2a.server.events.event_queue import EventQueue
|
|
4
|
-
from a2a.server.tasks import TaskUpdater as TaskUpdater
|
|
2
|
+
from a2a.server.agent_execution import RequestContext
|
|
3
|
+
from a2a.server.events.event_queue import EventQueue
|
|
5
4
|
from abc import ABC
|
|
6
5
|
from aip_agents.a2a.server.base_executor import BaseA2AExecutor as BaseA2AExecutor, StatusUpdateParams as StatusUpdateParams
|
|
7
|
-
from aip_agents.agent import
|
|
8
|
-
from aip_agents.
|
|
6
|
+
from aip_agents.agent.interfaces import LangGraphAgentProtocol as LangGraphAgentProtocol
|
|
7
|
+
from aip_agents.schema.step_limit import StepLimitConfig as StepLimitConfig
|
|
8
|
+
from aip_agents.utils.logger import get_logger as get_logger
|
|
9
9
|
|
|
10
10
|
logger: Incomplete
|
|
11
11
|
|
|
@@ -18,18 +18,17 @@ class LangGraphA2AExecutor(BaseA2AExecutor, ABC):
|
|
|
18
18
|
agent execution, while leaving agent-specific initialization to subclasses.
|
|
19
19
|
|
|
20
20
|
Attributes:
|
|
21
|
-
agent (
|
|
21
|
+
agent (LangGraphAgentProtocol): The LangChain-based agent instance to be executed.
|
|
22
22
|
"""
|
|
23
|
-
agent:
|
|
24
|
-
def __init__(self, langgraph_agent_instance:
|
|
23
|
+
agent: LangGraphAgentProtocol
|
|
24
|
+
def __init__(self, langgraph_agent_instance: LangGraphAgentProtocol) -> None:
|
|
25
25
|
"""Initializes the LangGraphA2AExecutor.
|
|
26
26
|
|
|
27
27
|
Args:
|
|
28
|
-
langgraph_agent_instance
|
|
29
|
-
of `BaseLangGraphAgent`.
|
|
28
|
+
langgraph_agent_instance: Component implementing `LangGraphAgentProtocol`.
|
|
30
29
|
|
|
31
30
|
Raises:
|
|
32
|
-
TypeError: If
|
|
31
|
+
TypeError: If the provided agent does not satisfy `LangGraphAgentProtocol`.
|
|
33
32
|
"""
|
|
34
33
|
async def execute(self, context: RequestContext, event_queue: EventQueue) -> None:
|
|
35
34
|
"""Processes an incoming agent request using a LangChain-based agent.
|
aip_agents/a2a/types.pyi
CHANGED
|
@@ -9,58 +9,58 @@ class MimeType(StrEnum):
|
|
|
9
9
|
This class provides constants for commonly used MIME types in artifact generation,
|
|
10
10
|
ensuring consistency and reducing typos across the codebase.
|
|
11
11
|
"""
|
|
12
|
-
TEXT_PLAIN
|
|
13
|
-
TEXT_HTML
|
|
14
|
-
TEXT_CSS
|
|
15
|
-
TEXT_JAVASCRIPT
|
|
16
|
-
TEXT_CSV
|
|
17
|
-
TEXT_XML
|
|
18
|
-
TEXT_MARKDOWN
|
|
19
|
-
APPLICATION_JSON
|
|
20
|
-
APPLICATION_XML
|
|
21
|
-
APPLICATION_PDF
|
|
22
|
-
APPLICATION_ZIP
|
|
23
|
-
APPLICATION_GZIP
|
|
24
|
-
APPLICATION_TAR
|
|
25
|
-
APPLICATION_OCTET_STREAM
|
|
26
|
-
APPLICATION_MSWORD
|
|
27
|
-
APPLICATION_EXCEL
|
|
28
|
-
APPLICATION_POWERPOINT
|
|
29
|
-
APPLICATION_DOCX
|
|
30
|
-
APPLICATION_XLSX
|
|
31
|
-
APPLICATION_PPTX
|
|
32
|
-
IMAGE_JPEG
|
|
33
|
-
IMAGE_PNG
|
|
34
|
-
IMAGE_GIF
|
|
35
|
-
IMAGE_WEBP
|
|
36
|
-
IMAGE_SVG
|
|
37
|
-
IMAGE_BMP
|
|
38
|
-
IMAGE_TIFF
|
|
39
|
-
IMAGE_ICO
|
|
40
|
-
AUDIO_MP3
|
|
41
|
-
AUDIO_WAV
|
|
42
|
-
AUDIO_OGG
|
|
43
|
-
AUDIO_AAC
|
|
44
|
-
AUDIO_FLAC
|
|
45
|
-
VIDEO_MP4
|
|
46
|
-
VIDEO_AVI
|
|
47
|
-
VIDEO_MOV
|
|
48
|
-
VIDEO_WMV
|
|
49
|
-
VIDEO_WEBM
|
|
50
|
-
VIDEO_MKV
|
|
51
|
-
FONT_TTF
|
|
52
|
-
FONT_OTF
|
|
53
|
-
FONT_WOFF
|
|
54
|
-
FONT_WOFF2
|
|
12
|
+
TEXT_PLAIN: str
|
|
13
|
+
TEXT_HTML: str
|
|
14
|
+
TEXT_CSS: str
|
|
15
|
+
TEXT_JAVASCRIPT: str
|
|
16
|
+
TEXT_CSV: str
|
|
17
|
+
TEXT_XML: str
|
|
18
|
+
TEXT_MARKDOWN: str
|
|
19
|
+
APPLICATION_JSON: str
|
|
20
|
+
APPLICATION_XML: str
|
|
21
|
+
APPLICATION_PDF: str
|
|
22
|
+
APPLICATION_ZIP: str
|
|
23
|
+
APPLICATION_GZIP: str
|
|
24
|
+
APPLICATION_TAR: str
|
|
25
|
+
APPLICATION_OCTET_STREAM: str
|
|
26
|
+
APPLICATION_MSWORD: str
|
|
27
|
+
APPLICATION_EXCEL: str
|
|
28
|
+
APPLICATION_POWERPOINT: str
|
|
29
|
+
APPLICATION_DOCX: str
|
|
30
|
+
APPLICATION_XLSX: str
|
|
31
|
+
APPLICATION_PPTX: str
|
|
32
|
+
IMAGE_JPEG: str
|
|
33
|
+
IMAGE_PNG: str
|
|
34
|
+
IMAGE_GIF: str
|
|
35
|
+
IMAGE_WEBP: str
|
|
36
|
+
IMAGE_SVG: str
|
|
37
|
+
IMAGE_BMP: str
|
|
38
|
+
IMAGE_TIFF: str
|
|
39
|
+
IMAGE_ICO: str
|
|
40
|
+
AUDIO_MP3: str
|
|
41
|
+
AUDIO_WAV: str
|
|
42
|
+
AUDIO_OGG: str
|
|
43
|
+
AUDIO_AAC: str
|
|
44
|
+
AUDIO_FLAC: str
|
|
45
|
+
VIDEO_MP4: str
|
|
46
|
+
VIDEO_AVI: str
|
|
47
|
+
VIDEO_MOV: str
|
|
48
|
+
VIDEO_WMV: str
|
|
49
|
+
VIDEO_WEBM: str
|
|
50
|
+
VIDEO_MKV: str
|
|
51
|
+
FONT_TTF: str
|
|
52
|
+
FONT_OTF: str
|
|
53
|
+
FONT_WOFF: str
|
|
54
|
+
FONT_WOFF2: str
|
|
55
55
|
|
|
56
56
|
class ArtifactType(StrEnum):
|
|
57
57
|
"""Common artifact types for A2A artifacts.
|
|
58
58
|
|
|
59
59
|
This class provides constants for artifact types used in the A2A protocol.
|
|
60
60
|
"""
|
|
61
|
-
FILE
|
|
62
|
-
DATA
|
|
63
|
-
TEXT
|
|
61
|
+
FILE: str
|
|
62
|
+
DATA: str
|
|
63
|
+
TEXT: str
|
|
64
64
|
|
|
65
65
|
EXTENSION_TO_MIME_TYPE: Incomplete
|
|
66
66
|
MIME_TYPE_TO_EXTENSION: Incomplete
|
|
@@ -122,4 +122,11 @@ class Artifact(BaseModel):
|
|
|
122
122
|
metadata: dict[str, Any] | None
|
|
123
123
|
@classmethod
|
|
124
124
|
def validate_base64(cls, v: str) -> str:
|
|
125
|
-
"""Validate that 'data' is a valid base64 string.
|
|
125
|
+
"""Validate that 'data' is a valid base64 string.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
v (str): The base64 string to validate.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
str: The validated base64 string if valid.
|
|
132
|
+
"""
|
aip_agents/agent/__init__.pyi
CHANGED
|
@@ -2,6 +2,8 @@ from aip_agents.agent.base_agent import BaseAgent as BaseAgent
|
|
|
2
2
|
from aip_agents.agent.base_langgraph_agent import BaseLangGraphAgent as BaseLangGraphAgent
|
|
3
3
|
from aip_agents.agent.google_adk_agent import GoogleADKAgent as GoogleADKAgent
|
|
4
4
|
from aip_agents.agent.interface import AgentInterface as AgentInterface
|
|
5
|
+
from aip_agents.agent.langflow_agent import LangflowAgent as LangflowAgent
|
|
6
|
+
from aip_agents.agent.langgraph_memory_enhancer_agent import LangGraphMemoryEnhancerAgent as LangGraphMemoryEnhancerAgent
|
|
5
7
|
from aip_agents.agent.langgraph_react_agent import LangChainAgent as LangChainAgent, LangGraphAgent as LangGraphAgent, LangGraphReactAgent as LangGraphReactAgent
|
|
6
8
|
|
|
7
|
-
__all__ = ['AgentInterface', 'BaseAgent', 'BaseLangGraphAgent', 'LangGraphReactAgent', 'GoogleADKAgent', 'LangGraphAgent', 'LangChainAgent']
|
|
9
|
+
__all__ = ['AgentInterface', 'BaseAgent', 'BaseLangGraphAgent', 'LangGraphReactAgent', 'GoogleADKAgent', 'LangGraphAgent', 'LangChainAgent', 'LangflowAgent', 'LangGraphMemoryEnhancerAgent']
|
aip_agents/agent/base_agent.pyi
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import abc
|
|
2
1
|
from _typeshed import Incomplete
|
|
3
2
|
from a2a.types import AgentCard
|
|
4
|
-
from aip_agents.a2a.server.google_adk_executor import GoogleADKExecutor as GoogleADKExecutor
|
|
5
|
-
from aip_agents.a2a.server.langgraph_executor import LangGraphA2AExecutor as LangGraphA2AExecutor
|
|
6
3
|
from aip_agents.agent.interface import AgentInterface as AgentInterface
|
|
7
|
-
from aip_agents.agent.types import A2AClientConfig as A2AClientConfig, AgentConfig as AgentConfig, BaseAgentConfig as BaseAgentConfig, CredentialType as CredentialType
|
|
8
4
|
from aip_agents.credentials.manager import CredentialsManager as CredentialsManager
|
|
5
|
+
from aip_agents.mcp.client.base_mcp_client import BaseMCPClient as BaseMCPClient
|
|
6
|
+
from aip_agents.schema.agent import A2AClientConfig as A2AClientConfig, AgentConfig as AgentConfig, BaseAgentConfig as BaseAgentConfig, CredentialType as CredentialType
|
|
7
|
+
from aip_agents.schema.model_id import ModelId as ModelId, ModelProvider as ModelProvider
|
|
9
8
|
from aip_agents.utils.a2a_connector import A2AConnector as A2AConnector
|
|
10
|
-
from aip_agents.utils.
|
|
9
|
+
from aip_agents.utils.logger import get_logger as get_logger
|
|
11
10
|
from aip_agents.utils.name_preprocessor.name_preprocessor import NamePreprocessor as NamePreprocessor
|
|
11
|
+
from collections.abc import AsyncGenerator
|
|
12
12
|
from starlette.applications import Starlette
|
|
13
|
-
from typing import Any
|
|
13
|
+
from typing import Any
|
|
14
14
|
|
|
15
15
|
logger: Incomplete
|
|
16
16
|
AGENT_EXECUTOR_MAPPING: Incomplete
|
|
@@ -19,7 +19,7 @@ LM_EXCLUDE_FIELDS: Incomplete
|
|
|
19
19
|
CUSTOM_PROVIDERS: Incomplete
|
|
20
20
|
OUTPUT_ANALYTICS_KEY: str
|
|
21
21
|
|
|
22
|
-
class BaseAgent(AgentInterface
|
|
22
|
+
class BaseAgent(AgentInterface):
|
|
23
23
|
"""Base class for agents, providing common A2A client method implementations.
|
|
24
24
|
|
|
25
25
|
Concrete agent implementations (e.g., LangGraphAgent, GoogleADKAgent)
|
|
@@ -34,8 +34,8 @@ class BaseAgent(AgentInterface, metaclass=abc.ABCMeta):
|
|
|
34
34
|
"""
|
|
35
35
|
model: Incomplete
|
|
36
36
|
tools: Incomplete
|
|
37
|
-
mcp_config: Incomplete
|
|
38
37
|
tool_configs: Incomplete
|
|
38
|
+
mcp_client: BaseMCPClient | None
|
|
39
39
|
name_preprocessor: Incomplete
|
|
40
40
|
def __init__(self, name: str, instruction: str, description: str | None = None, model: Any | None = None, tools: list[Any] | None = None, config: BaseAgentConfig | dict[str, Any] | None = None, tool_configs: dict[str, Any] | None = None, **kwargs: Any) -> None:
|
|
41
41
|
"""Initializes the BaseAgent.
|
|
@@ -69,6 +69,22 @@ class BaseAgent(AgentInterface, metaclass=abc.ABCMeta):
|
|
|
69
69
|
Returns:
|
|
70
70
|
str: The provider of the model.
|
|
71
71
|
"""
|
|
72
|
+
@property
|
|
73
|
+
def mcp_config(self) -> dict[str, dict[str, Any]]:
|
|
74
|
+
"""Read-only view of MCP configuration.
|
|
75
|
+
|
|
76
|
+
Returns a copy to prevent direct mutation; use add_mcp_server() for changes.
|
|
77
|
+
"""
|
|
78
|
+
@mcp_config.setter
|
|
79
|
+
def mcp_config(self, value: dict[str, dict[str, Any]]) -> None:
|
|
80
|
+
"""Set MCP configuration and maintain synchronization.
|
|
81
|
+
|
|
82
|
+
Automatically resets initialization flag and recreates client to ensure consistency.
|
|
83
|
+
Prefer using add_mcp_server() for proper validation.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
value (dict[str, dict[str, Any]]): The MCP configuration to set.
|
|
87
|
+
"""
|
|
72
88
|
def to_a2a(self, agent_card: AgentCard, **kwargs: Any) -> Starlette:
|
|
73
89
|
"""Converts the agent to an A2A-compatible ASGI application.
|
|
74
90
|
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import abc
|
|
2
1
|
from _typeshed import Incomplete
|
|
3
2
|
from a2a.types import AgentCard as AgentCard
|
|
4
3
|
from abc import abstractmethod
|
|
5
4
|
from aip_agents.agent.base_agent import BaseAgent as BaseAgent
|
|
6
|
-
from aip_agents.agent.
|
|
7
|
-
from aip_agents.
|
|
5
|
+
from aip_agents.agent.system_instruction_context import get_current_date_context as get_current_date_context
|
|
6
|
+
from aip_agents.constants import TEXT_PREVIEW_LENGTH as TEXT_PREVIEW_LENGTH
|
|
7
|
+
from aip_agents.mcp.client import LangchainMCPClient as LangchainMCPClient
|
|
8
8
|
from aip_agents.memory import BaseMemory as BaseMemory, MemoryFactory as MemoryFactory, MemoryMethod as MemoryMethod
|
|
9
9
|
from aip_agents.memory.constants import MemoryDefaults as MemoryDefaults
|
|
10
|
+
from aip_agents.schema.agent import StreamMode as StreamMode
|
|
11
|
+
from aip_agents.schema.hitl import HitlMetadata as HitlMetadata
|
|
10
12
|
from aip_agents.tools.tool_config_injector import CONFIG_SCHEMA_ATTR as CONFIG_SCHEMA_ATTR, TOOL_CONFIG_SCHEMA_ATTR as TOOL_CONFIG_SCHEMA_ATTR, inject_config_methods_into_tool as inject_config_methods_into_tool
|
|
11
13
|
from aip_agents.types import A2AEvent as A2AEvent, A2AStreamEventType as A2AStreamEventType
|
|
12
14
|
from aip_agents.utils import validate_references as validate_references
|
|
13
15
|
from aip_agents.utils.langgraph.tool_managers.a2a_tool_manager import A2AToolManager as A2AToolManager
|
|
14
16
|
from aip_agents.utils.langgraph.tool_managers.delegation_tool_manager import DelegationToolManager as DelegationToolManager
|
|
15
|
-
from aip_agents.utils.
|
|
16
|
-
from aip_agents.utils.
|
|
17
|
+
from aip_agents.utils.logger import get_logger as get_logger
|
|
18
|
+
from aip_agents.utils.metadata.activity_metadata_helper import create_tool_activity_info as create_tool_activity_info
|
|
19
|
+
from aip_agents.utils.metadata_helper import DefaultStepMessages as DefaultStepMessages, Kind as Kind, MetadataFieldKeys as MetadataFieldKeys, Status as Status, end_step_counter_scope as end_step_counter_scope, get_next_step_number as get_next_step_number, start_step_counter_scope as start_step_counter_scope
|
|
20
|
+
from aip_agents.utils.pii import deanonymize_final_response_content as deanonymize_final_response_content
|
|
21
|
+
from aip_agents.utils.sse_chunk_transformer import SSEChunkTransformer as SSEChunkTransformer
|
|
17
22
|
from aip_agents.utils.token_usage_helper import STEP_USAGE_KEY as STEP_USAGE_KEY, TOTAL_USAGE_KEY as TOTAL_USAGE_KEY, USAGE_METADATA_KEY as USAGE_METADATA_KEY
|
|
23
|
+
from collections.abc import AsyncGenerator, Sequence
|
|
18
24
|
from dataclasses import dataclass
|
|
19
25
|
from gllm_core.event import EventEmitter
|
|
20
|
-
from
|
|
26
|
+
from gllm_core.schema import Chunk as Chunk
|
|
21
27
|
from langchain_core.tools import BaseTool
|
|
22
28
|
from langgraph.graph import StateGraph
|
|
23
29
|
from langgraph.graph.message import add_messages as add_messages
|
|
24
|
-
from langgraph.graph.state import CompiledStateGraph
|
|
25
|
-
from langgraph.types import Checkpointer
|
|
26
|
-
from typing import Any
|
|
30
|
+
from langgraph.graph.state import CompiledStateGraph
|
|
31
|
+
from langgraph.types import Checkpointer
|
|
32
|
+
from typing import Any
|
|
27
33
|
|
|
28
34
|
logger: Incomplete
|
|
29
35
|
|
|
@@ -31,12 +37,12 @@ logger: Incomplete
|
|
|
31
37
|
class _StreamingContext:
|
|
32
38
|
"""Context object for managing streaming state and configuration."""
|
|
33
39
|
original_query: str
|
|
34
|
-
augmented_query: str
|
|
35
40
|
graph_input: dict[str, Any]
|
|
36
41
|
config: dict[str, Any]
|
|
37
42
|
memory_user_id: str | None
|
|
38
43
|
current_thread_id: str
|
|
39
44
|
token: Any
|
|
45
|
+
enable_token_streaming: bool
|
|
40
46
|
final_event_yielded: bool = ...
|
|
41
47
|
pending_artifacts: list | None = ...
|
|
42
48
|
seen_artifact_hashes: set | None = ...
|
|
@@ -44,10 +50,11 @@ class _StreamingContext:
|
|
|
44
50
|
final_state: dict[str, Any] | None = ...
|
|
45
51
|
last_final_content: str | None = ...
|
|
46
52
|
saved_memory: bool = ...
|
|
53
|
+
is_token_streaming: bool = ...
|
|
47
54
|
def __post_init__(self) -> None:
|
|
48
55
|
"""Initialize mutable defaults."""
|
|
49
56
|
|
|
50
|
-
class BaseLangGraphAgent(BaseAgent
|
|
57
|
+
class BaseLangGraphAgent(BaseAgent):
|
|
51
58
|
"""Base class for LangGraph-based agents with unified tool approach.
|
|
52
59
|
|
|
53
60
|
Provides core LangGraph functionality including:
|
|
@@ -73,6 +80,7 @@ class BaseLangGraphAgent(BaseAgent, metaclass=abc.ABCMeta):
|
|
|
73
80
|
"""
|
|
74
81
|
state_schema: Incomplete
|
|
75
82
|
thread_id_key: Incomplete
|
|
83
|
+
enable_a2a_token_streaming: Incomplete
|
|
76
84
|
event_emitter: Incomplete
|
|
77
85
|
checkpointer: Incomplete
|
|
78
86
|
memory: BaseMemory | None
|
|
@@ -81,8 +89,8 @@ class BaseLangGraphAgent(BaseAgent, metaclass=abc.ABCMeta):
|
|
|
81
89
|
regular_tools: list[BaseTool]
|
|
82
90
|
mcp_tools: list[BaseTool]
|
|
83
91
|
resolved_tools: list[BaseTool]
|
|
84
|
-
def __init__(self, name: str, instruction: str, description: str | None = None, model: Any | None = None, tools: Sequence[BaseTool] | None = None, state_schema: type | None = None, thread_id_key: str = 'thread_id', event_emitter: EventEmitter | None = None, checkpointer: Checkpointer | None = None, **kwargs: Any) -> None:
|
|
85
|
-
|
|
92
|
+
def __init__(self, name: str, instruction: str, description: str | None = None, model: Any | None = None, tools: Sequence[BaseTool] | None = None, state_schema: type | None = None, thread_id_key: str = 'thread_id', event_emitter: EventEmitter | None = None, checkpointer: Checkpointer | None = None, enable_a2a_token_streaming: bool = False, **kwargs: Any) -> None:
|
|
93
|
+
'''Initialize the BaseLangGraphAgent.
|
|
86
94
|
|
|
87
95
|
Args:
|
|
88
96
|
name: The name of the agent.
|
|
@@ -94,8 +102,22 @@ class BaseLangGraphAgent(BaseAgent, metaclass=abc.ABCMeta):
|
|
|
94
102
|
thread_id_key: Key for thread ID in configuration.
|
|
95
103
|
event_emitter: Optional event emitter for streaming updates.
|
|
96
104
|
checkpointer: Optional checkpointer for conversation persistence.
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
enable_a2a_token_streaming: Enable token-level streaming for A2A responses.
|
|
106
|
+
- False (default): Stream message-level events only
|
|
107
|
+
- True: Stream individual tokens plus message-level events
|
|
108
|
+
**kwargs: Additional keyword arguments passed to BaseAgent (including tool_configs and memory settings).
|
|
109
|
+
Memory settings include:
|
|
110
|
+
- memory_backend: Memory backend (e.g., "mem0")
|
|
111
|
+
- agent_id: Agent identifier for memory scoping
|
|
112
|
+
- memory_namespace: Memory namespace
|
|
113
|
+
- save_interaction_to_memory: Whether to save interactions (default True)
|
|
114
|
+
'''
|
|
115
|
+
def set_operation_mode(self, mode: str) -> None:
|
|
116
|
+
'''Set the operation mode for dependency tracking.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
mode: Operation mode - "parallel" (default) or "sequential"
|
|
120
|
+
'''
|
|
99
121
|
@abstractmethod
|
|
100
122
|
def define_graph(self, graph_builder: StateGraph) -> CompiledStateGraph:
|
|
101
123
|
"""Define the specific graph structure for this agent type.
|
|
@@ -143,9 +165,7 @@ class BaseLangGraphAgent(BaseAgent, metaclass=abc.ABCMeta):
|
|
|
143
165
|
Dictionary containing the agent's response.
|
|
144
166
|
"""
|
|
145
167
|
async def arun(self, query: str, **kwargs: Any) -> dict[str, Any]:
|
|
146
|
-
"""Asynchronously run the LangGraph agent.
|
|
147
|
-
|
|
148
|
-
If MCP configuration exists, connects to the MCP server and registers tools before running.
|
|
168
|
+
"""Asynchronously run the LangGraph agent with lazy MCP initialization.
|
|
149
169
|
|
|
150
170
|
Args:
|
|
151
171
|
query: The input query for the agent.
|
|
@@ -169,16 +189,15 @@ class BaseLangGraphAgent(BaseAgent, metaclass=abc.ABCMeta):
|
|
|
169
189
|
Yields:
|
|
170
190
|
Chunks of output (strings or dicts) from the streaming response.
|
|
171
191
|
"""
|
|
172
|
-
def
|
|
173
|
-
"""
|
|
192
|
+
async def cleanup(self) -> None:
|
|
193
|
+
"""Cleanup MCP resources including persistent sessions.
|
|
174
194
|
|
|
175
|
-
|
|
176
|
-
|
|
195
|
+
This method performs best-effort cleanup of MCP client resources.
|
|
196
|
+
Errors during cleanup are logged but do not raise exceptions to ensure
|
|
197
|
+
the cleanup process completes gracefully.
|
|
177
198
|
"""
|
|
178
199
|
async def arun_a2a_stream(self, query: str, **kwargs: Any) -> AsyncGenerator[dict[str, Any], None]:
|
|
179
|
-
'''Asynchronously streams the agent\'s response in
|
|
180
|
-
|
|
181
|
-
If MCP configuration exists, connects to the MCP server and registers tools before streaming.
|
|
200
|
+
'''Asynchronously streams the agent\'s response in A2A format.
|
|
182
201
|
|
|
183
202
|
Args:
|
|
184
203
|
query: The input query for the agent.
|
|
@@ -188,3 +207,26 @@ class BaseLangGraphAgent(BaseAgent, metaclass=abc.ABCMeta):
|
|
|
188
207
|
Dictionaries with "status" and "content" keys.
|
|
189
208
|
Possible statuses: "working", "completed", "failed", "canceled".
|
|
190
209
|
'''
|
|
210
|
+
async def arun_sse_stream(self, query: str, task_id: str | None = None, context_id: str | None = None, **kwargs: Any) -> AsyncGenerator[dict[str, Any], None]:
|
|
211
|
+
'''Stream agent response as SSE-compatible chunks.
|
|
212
|
+
|
|
213
|
+
This method wraps arun_a2a_stream and transforms output to the normalized
|
|
214
|
+
dict format matching A2AConnector.astream_to_agent output, enabling direct
|
|
215
|
+
streaming without A2A server overhead.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
query: The input query for the agent.
|
|
219
|
+
task_id: Optional task identifier for the stream.
|
|
220
|
+
context_id: Optional context identifier for the stream.
|
|
221
|
+
**kwargs: Additional arguments passed to arun_a2a_stream.
|
|
222
|
+
|
|
223
|
+
Yields:
|
|
224
|
+
SSEChunk dicts with normalized structure:
|
|
225
|
+
- status: "success" | "error"
|
|
226
|
+
- task_state: "working" | "completed" | "failed" | "canceled"
|
|
227
|
+
- content: Text content or None
|
|
228
|
+
- event_type: Always string (never enum)
|
|
229
|
+
- final: True for terminal events
|
|
230
|
+
- metadata: Normalized metadata dict
|
|
231
|
+
- artifacts: Only present when non-empty
|
|
232
|
+
'''
|