aip-agents-binary 0.6.3__py3-none-any.whl → 0.6.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.5.dist-info/RECORD +314 -0
- aip_agents/__init__.pyi +0 -19
- aip_agents/a2a/__init__.pyi +0 -3
- aip_agents/a2a/server/__init__.pyi +0 -4
- aip_agents/a2a/server/base_executor.pyi +0 -73
- aip_agents/a2a/server/google_adk_executor.pyi +0 -51
- aip_agents/a2a/server/langflow_executor.pyi +0 -43
- aip_agents/a2a/server/langgraph_executor.pyi +0 -47
- aip_agents/a2a/types.pyi +0 -132
- aip_agents/agent/__init__.pyi +0 -9
- aip_agents/agent/base_agent.pyi +0 -221
- aip_agents/agent/base_langgraph_agent.pyi +0 -233
- aip_agents/agent/google_adk_agent.pyi +0 -141
- aip_agents/agent/google_adk_constants.pyi +0 -3
- aip_agents/agent/hitl/__init__.pyi +0 -6
- aip_agents/agent/hitl/config.pyi +0 -15
- aip_agents/agent/hitl/langgraph_hitl_mixin.pyi +0 -42
- aip_agents/agent/hitl/manager.pyi +0 -200
- aip_agents/agent/hitl/models.pyi +0 -3
- aip_agents/agent/hitl/prompt/__init__.pyi +0 -4
- aip_agents/agent/hitl/prompt/base.pyi +0 -24
- aip_agents/agent/hitl/prompt/deferred.pyi +0 -30
- aip_agents/agent/hitl/registry.pyi +0 -101
- aip_agents/agent/interface.pyi +0 -81
- aip_agents/agent/interfaces.pyi +0 -44
- aip_agents/agent/langflow_agent.pyi +0 -133
- aip_agents/agent/langgraph_memory_enhancer_agent.pyi +0 -49
- aip_agents/agent/langgraph_react_agent.pyi +0 -170
- aip_agents/agent/system_instruction_context.pyi +0 -13
- aip_agents/clients/__init__.pyi +0 -4
- aip_agents/clients/langflow/__init__.pyi +0 -4
- aip_agents/clients/langflow/client.pyi +0 -140
- aip_agents/clients/langflow/types.pyi +0 -7
- aip_agents/constants.pyi +0 -7
- aip_agents/examples/__init__.pyi +0 -0
- aip_agents/examples/compare_streaming_client.pyi +0 -48
- aip_agents/examples/compare_streaming_server.pyi +0 -18
- aip_agents/examples/demo_memory_recall.py +0 -401
- aip_agents/examples/demo_memory_recall.pyi +0 -58
- aip_agents/examples/hello_world_a2a_google_adk_client.pyi +0 -9
- aip_agents/examples/hello_world_a2a_google_adk_client_agent.pyi +0 -9
- aip_agents/examples/hello_world_a2a_google_adk_client_streaming.pyi +0 -9
- aip_agents/examples/hello_world_a2a_google_adk_server.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langchain_client.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_client_agent.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_client_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_client_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_reference_client_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_reference_server.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langchain_server.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langchain_server_lm_invoker.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langflow_client.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langflow_server.pyi +0 -14
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_artifact_server.pyi +0 -16
- aip_agents/examples/hello_world_a2a_langgraph_client.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langgraph_client_agent.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langgraph_client_agent_lm_invoker.pyi +0 -2
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_tool_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_server.pyi +0 -14
- aip_agents/examples/hello_world_a2a_langgraph_server_lm_invoker.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langgraph_server_tool_streaming.pyi +0 -15
- aip_agents/examples/hello_world_a2a_mcp_langgraph.pyi +0 -48
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_client.pyi +0 -48
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_server.pyi +0 -45
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_client.pyi +0 -5
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_server_lm_invoker.pyi +0 -15
- aip_agents/examples/hello_world_google_adk.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_http.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_http_stream.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_sse.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_sse_stream.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_stdio.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_stdio_stream.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain.pyi +0 -5
- aip_agents/examples/hello_world_langchain_lm_invoker.pyi +0 -2
- aip_agents/examples/hello_world_langchain_mcp_http.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_http_interactive.pyi +0 -16
- aip_agents/examples/hello_world_langchain_mcp_http_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_multi_server.pyi +0 -18
- aip_agents/examples/hello_world_langchain_mcp_sse.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_sse_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_stdio.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_stdio_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_stream_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_langflow_agent.pyi +0 -35
- aip_agents/examples/hello_world_langgraph.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_gl_connector_twitter.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_http.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_http_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_sse.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_sse_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_stdio.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_stdio_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_stream_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_model_switch_cli.pyi +0 -30
- aip_agents/examples/hello_world_multi_agent_adk.pyi +0 -6
- aip_agents/examples/hello_world_multi_agent_langchain.pyi +0 -5
- aip_agents/examples/hello_world_multi_agent_langgraph.pyi +0 -5
- aip_agents/examples/hello_world_multi_agent_langgraph_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_pii_logger.pyi +0 -5
- aip_agents/examples/hello_world_ptc.pyi +0 -5
- aip_agents/examples/hello_world_sentry.pyi +0 -21
- aip_agents/examples/hello_world_step_limits.pyi +0 -17
- aip_agents/examples/hello_world_stock_a2a_server.pyi +0 -17
- aip_agents/examples/hello_world_tool_output_client.pyi +0 -5
- aip_agents/examples/hello_world_tool_output_server.pyi +0 -19
- aip_agents/examples/hitl_demo.pyi +0 -67
- aip_agents/examples/pii_demo_langgraph_client.pyi +0 -5
- aip_agents/examples/pii_demo_langgraph_server.pyi +0 -20
- aip_agents/examples/pii_demo_multi_agent_client.pyi +0 -5
- aip_agents/examples/pii_demo_multi_agent_server.pyi +0 -40
- aip_agents/examples/todolist_planning_a2a_langchain_client.pyi +0 -5
- aip_agents/examples/todolist_planning_a2a_langgraph_server.pyi +0 -19
- aip_agents/examples/tools/__init__.pyi +0 -9
- aip_agents/examples/tools/adk_arithmetic_tools.pyi +0 -24
- aip_agents/examples/tools/adk_weather_tool.pyi +0 -18
- aip_agents/examples/tools/data_generator_tool.pyi +0 -15
- aip_agents/examples/tools/data_visualization_tool.pyi +0 -19
- aip_agents/examples/tools/image_artifact_tool.pyi +0 -26
- aip_agents/examples/tools/langchain_arithmetic_tools.pyi +0 -17
- aip_agents/examples/tools/langchain_currency_exchange_tool.pyi +0 -20
- aip_agents/examples/tools/langchain_graph_artifact_tool.pyi +0 -25
- aip_agents/examples/tools/langchain_weather_tool.pyi +0 -19
- aip_agents/examples/tools/langgraph_streaming_tool.pyi +0 -43
- aip_agents/examples/tools/mock_retrieval_tool.pyi +0 -13
- aip_agents/examples/tools/pii_demo_tools.pyi +0 -54
- aip_agents/examples/tools/random_chart_tool.pyi +0 -20
- aip_agents/examples/tools/serper_tool.pyi +0 -16
- aip_agents/examples/tools/stock_tools.pyi +0 -36
- aip_agents/examples/tools/table_generator_tool.pyi +0 -22
- aip_agents/examples/tools/time_tool.pyi +0 -15
- aip_agents/examples/tools/weather_forecast_tool.pyi +0 -14
- aip_agents/guardrails/__init__.pyi +0 -6
- aip_agents/guardrails/engines/__init__.pyi +0 -4
- aip_agents/guardrails/engines/base.pyi +0 -61
- aip_agents/guardrails/engines/nemo.pyi +0 -46
- aip_agents/guardrails/engines/phrase_matcher.pyi +0 -48
- aip_agents/guardrails/exceptions.pyi +0 -23
- aip_agents/guardrails/manager.pyi +0 -42
- aip_agents/guardrails/middleware.pyi +0 -87
- aip_agents/guardrails/schemas.pyi +0 -43
- aip_agents/guardrails/utils.pyi +0 -19
- aip_agents/mcp/__init__.pyi +0 -0
- aip_agents/mcp/client/__init__.pyi +0 -5
- aip_agents/mcp/client/base_mcp_client.pyi +0 -148
- aip_agents/mcp/client/connection_manager.pyi +0 -51
- aip_agents/mcp/client/google_adk/__init__.pyi +0 -3
- aip_agents/mcp/client/google_adk/client.pyi +0 -75
- aip_agents/mcp/client/langchain/__init__.pyi +0 -3
- aip_agents/mcp/client/langchain/client.pyi +0 -48
- aip_agents/mcp/client/persistent_session.pyi +0 -122
- aip_agents/mcp/client/session_pool.pyi +0 -101
- aip_agents/mcp/client/transports.pyi +0 -132
- aip_agents/mcp/utils/__init__.pyi +0 -0
- aip_agents/mcp/utils/config_validator.pyi +0 -82
- aip_agents/memory/__init__.pyi +0 -5
- aip_agents/memory/adapters/__init__.pyi +0 -4
- aip_agents/memory/adapters/base_adapter.pyi +0 -150
- aip_agents/memory/adapters/mem0.pyi +0 -22
- aip_agents/memory/base.pyi +0 -60
- aip_agents/memory/constants.pyi +0 -25
- aip_agents/memory/factory.pyi +0 -24
- aip_agents/memory/guidance.pyi +0 -3
- aip_agents/memory/simple_memory.pyi +0 -23
- aip_agents/middleware/__init__.pyi +0 -5
- aip_agents/middleware/base.pyi +0 -75
- aip_agents/middleware/manager.pyi +0 -84
- aip_agents/middleware/todolist.pyi +0 -125
- aip_agents/ptc/__init__.pyi +0 -10
- aip_agents/ptc/doc_gen.pyi +0 -40
- aip_agents/ptc/exceptions.pyi +0 -22
- aip_agents/ptc/executor.pyi +0 -73
- aip_agents/ptc/mcp/__init__.pyi +0 -7
- aip_agents/ptc/mcp/sandbox_bridge.pyi +0 -47
- aip_agents/ptc/mcp/templates/__init__.pyi +0 -0
- aip_agents/ptc/naming.pyi +0 -76
- aip_agents/ptc/payload.pyi +0 -15
- aip_agents/ptc/prompt_builder.pyi +0 -55
- aip_agents/ptc/ptc_helper.pyi +0 -1
- aip_agents/ptc/sandbox_bridge.pyi +0 -25
- aip_agents/ptc/template_utils.pyi +0 -13
- aip_agents/ptc/templates/__init__.pyi +0 -0
- aip_agents/sandbox/__init__.pyi +0 -5
- aip_agents/sandbox/defaults.pyi +0 -2
- aip_agents/sandbox/e2b_runtime.pyi +0 -51
- aip_agents/sandbox/template_builder.pyi +0 -36
- aip_agents/sandbox/types.pyi +0 -14
- aip_agents/sandbox/validation.pyi +0 -20
- aip_agents/schema/__init__.pyi +0 -9
- aip_agents/schema/a2a.pyi +0 -40
- aip_agents/schema/agent.pyi +0 -65
- aip_agents/schema/hitl.pyi +0 -89
- aip_agents/schema/langgraph.pyi +0 -28
- aip_agents/schema/model_id.pyi +0 -54
- aip_agents/schema/step_limit.pyi +0 -63
- aip_agents/schema/storage.pyi +0 -21
- aip_agents/sentry/__init__.pyi +0 -3
- aip_agents/sentry/sentry.pyi +0 -48
- aip_agents/storage/__init__.pyi +0 -8
- aip_agents/storage/base.pyi +0 -58
- aip_agents/storage/clients/__init__.pyi +0 -3
- aip_agents/storage/clients/minio_client.pyi +0 -137
- aip_agents/storage/config.pyi +0 -29
- aip_agents/storage/providers/__init__.pyi +0 -5
- aip_agents/storage/providers/base.pyi +0 -88
- aip_agents/storage/providers/memory.pyi +0 -79
- aip_agents/storage/providers/object_storage.pyi +0 -98
- aip_agents/tools/__init__.pyi +0 -11
- aip_agents/tools/browser_use/__init__.pyi +0 -14
- aip_agents/tools/browser_use/action_parser.pyi +0 -18
- aip_agents/tools/browser_use/browser_use_tool.pyi +0 -50
- aip_agents/tools/browser_use/llm_config.pyi +0 -52
- aip_agents/tools/browser_use/minio_storage.pyi +0 -109
- aip_agents/tools/browser_use/schemas.pyi +0 -32
- aip_agents/tools/browser_use/session.pyi +0 -4
- aip_agents/tools/browser_use/session_errors.pyi +0 -53
- aip_agents/tools/browser_use/steel_session_recording.pyi +0 -63
- aip_agents/tools/browser_use/streaming.pyi +0 -81
- aip_agents/tools/browser_use/structured_data_parser.pyi +0 -86
- aip_agents/tools/browser_use/structured_data_recovery.pyi +0 -43
- aip_agents/tools/browser_use/types.pyi +0 -45
- aip_agents/tools/code_sandbox/__init__.pyi +0 -3
- aip_agents/tools/code_sandbox/constant.pyi +0 -4
- aip_agents/tools/code_sandbox/e2b_cloud_sandbox_extended.pyi +0 -102
- aip_agents/tools/code_sandbox/e2b_sandbox_tool.pyi +0 -29
- aip_agents/tools/constants.pyi +0 -138
- aip_agents/tools/date_range_tool.pyi +0 -21
- aip_agents/tools/document_loader/__init__.pyi +0 -7
- aip_agents/tools/document_loader/base_reader.pyi +0 -75
- aip_agents/tools/document_loader/docx_reader_tool.pyi +0 -10
- aip_agents/tools/document_loader/excel_reader_tool.pyi +0 -26
- aip_agents/tools/document_loader/pdf_reader_tool.pyi +0 -11
- aip_agents/tools/document_loader/pdf_splitter.pyi +0 -18
- aip_agents/tools/execute_ptc_code.pyi +0 -90
- aip_agents/tools/gl_connector/__init__.pyi +0 -3
- aip_agents/tools/gl_connector/tool.pyi +0 -74
- aip_agents/tools/gl_connector_tools.pyi +0 -39
- aip_agents/tools/memory_search/__init__.pyi +0 -5
- aip_agents/tools/memory_search/base.pyi +0 -69
- aip_agents/tools/memory_search/mem0.pyi +0 -19
- aip_agents/tools/memory_search/schema.pyi +0 -15
- aip_agents/tools/memory_search_tool.pyi +0 -3
- aip_agents/tools/time_tool.pyi +0 -16
- aip_agents/tools/tool_config_injector.pyi +0 -26
- aip_agents/tools/web_search/__init__.pyi +0 -3
- aip_agents/tools/web_search/serper_tool.pyi +0 -19
- aip_agents/types/__init__.pyi +0 -36
- aip_agents/types/a2a_events.pyi +0 -3
- aip_agents/utils/__init__.pyi +0 -11
- aip_agents/utils/a2a_connector.pyi +0 -146
- aip_agents/utils/artifact_helpers.pyi +0 -203
- aip_agents/utils/constants.pyi +0 -10
- aip_agents/utils/datetime/__init__.pyi +0 -4
- aip_agents/utils/datetime/normalization.pyi +0 -95
- aip_agents/utils/datetime/timezone.pyi +0 -48
- aip_agents/utils/env_loader.pyi +0 -10
- aip_agents/utils/event_handler_registry.pyi +0 -23
- aip_agents/utils/file_prompt_utils.pyi +0 -21
- aip_agents/utils/final_response_builder.pyi +0 -34
- aip_agents/utils/formatter_llm_client.pyi +0 -71
- aip_agents/utils/langgraph/__init__.pyi +0 -3
- aip_agents/utils/langgraph/converter.pyi +0 -49
- aip_agents/utils/langgraph/tool_managers/__init__.pyi +0 -5
- aip_agents/utils/langgraph/tool_managers/a2a_tool_manager.pyi +0 -35
- aip_agents/utils/langgraph/tool_managers/base_tool_manager.pyi +0 -48
- aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.pyi +0 -56
- aip_agents/utils/langgraph/tool_output_management.pyi +0 -329
- aip_agents/utils/logger.pyi +0 -60
- aip_agents/utils/metadata/__init__.pyi +0 -5
- aip_agents/utils/metadata/activity_metadata_helper.pyi +0 -25
- aip_agents/utils/metadata/activity_narrative/__init__.pyi +0 -7
- aip_agents/utils/metadata/activity_narrative/builder.pyi +0 -35
- aip_agents/utils/metadata/activity_narrative/constants.pyi +0 -10
- aip_agents/utils/metadata/activity_narrative/context.pyi +0 -32
- aip_agents/utils/metadata/activity_narrative/formatters.pyi +0 -48
- aip_agents/utils/metadata/activity_narrative/utils.pyi +0 -12
- aip_agents/utils/metadata/schemas/__init__.pyi +0 -4
- aip_agents/utils/metadata/schemas/activity_schema.pyi +0 -18
- aip_agents/utils/metadata/schemas/thinking_schema.pyi +0 -20
- aip_agents/utils/metadata/thinking_metadata_helper.pyi +0 -4
- aip_agents/utils/metadata_helper.pyi +0 -117
- aip_agents/utils/name_preprocessor/__init__.pyi +0 -6
- aip_agents/utils/name_preprocessor/base_name_preprocessor.pyi +0 -52
- aip_agents/utils/name_preprocessor/google_name_preprocessor.pyi +0 -38
- aip_agents/utils/name_preprocessor/name_preprocessor.pyi +0 -41
- aip_agents/utils/name_preprocessor/openai_name_preprocessor.pyi +0 -34
- aip_agents/utils/pii/__init__.pyi +0 -5
- aip_agents/utils/pii/pii_handler.pyi +0 -96
- aip_agents/utils/pii/pii_helper.pyi +0 -78
- aip_agents/utils/pii/uuid_deanonymizer_mapping.pyi +0 -73
- aip_agents/utils/reference_helper.pyi +0 -81
- aip_agents/utils/sse_chunk_transformer.pyi +0 -166
- aip_agents/utils/step_limit_manager.pyi +0 -112
- aip_agents/utils/token_usage_helper.pyi +0 -60
- aip_agents_binary-0.6.3.dist-info/RECORD +0 -614
- {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/a2a/types.pyi
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from enum import StrEnum
|
|
3
|
-
from pydantic import BaseModel
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
class MimeType(StrEnum):
|
|
7
|
-
"""Common MIME types for A2A artifacts.
|
|
8
|
-
|
|
9
|
-
This class provides constants for commonly used MIME types in artifact generation,
|
|
10
|
-
ensuring consistency and reducing typos across the codebase.
|
|
11
|
-
"""
|
|
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
|
-
|
|
56
|
-
class ArtifactType(StrEnum):
|
|
57
|
-
"""Common artifact types for A2A artifacts.
|
|
58
|
-
|
|
59
|
-
This class provides constants for artifact types used in the A2A protocol.
|
|
60
|
-
"""
|
|
61
|
-
FILE: str
|
|
62
|
-
DATA: str
|
|
63
|
-
TEXT: str
|
|
64
|
-
|
|
65
|
-
EXTENSION_TO_MIME_TYPE: Incomplete
|
|
66
|
-
MIME_TYPE_TO_EXTENSION: Incomplete
|
|
67
|
-
|
|
68
|
-
def get_mime_type_from_filename(filename: str) -> str:
|
|
69
|
-
'''Get MIME type from filename extension.
|
|
70
|
-
|
|
71
|
-
Args:
|
|
72
|
-
filename: The filename to get the MIME type for.
|
|
73
|
-
|
|
74
|
-
Returns:
|
|
75
|
-
The MIME type string, or application/octet-stream if unknown.
|
|
76
|
-
|
|
77
|
-
Example:
|
|
78
|
-
>>> get_mime_type_from_filename("data.csv")
|
|
79
|
-
\'text/csv\'
|
|
80
|
-
>>> get_mime_type_from_filename("image.png")
|
|
81
|
-
\'image/png\'
|
|
82
|
-
>>> get_mime_type_from_filename("unknown.xyz")
|
|
83
|
-
\'application/octet-stream\'
|
|
84
|
-
'''
|
|
85
|
-
def get_extension_from_mime_type(mime_type: str) -> str | None:
|
|
86
|
-
'''Get file extension from MIME type.
|
|
87
|
-
|
|
88
|
-
Args:
|
|
89
|
-
mime_type: The MIME type to get the extension for.
|
|
90
|
-
|
|
91
|
-
Returns:
|
|
92
|
-
The file extension (with dot) or None if not found.
|
|
93
|
-
|
|
94
|
-
Example:
|
|
95
|
-
>>> get_extension_from_mime_type("text/csv")
|
|
96
|
-
\'.csv\'
|
|
97
|
-
>>> get_extension_from_mime_type("image/png")
|
|
98
|
-
\'.png\'
|
|
99
|
-
>>> get_extension_from_mime_type("unknown/type")
|
|
100
|
-
None
|
|
101
|
-
'''
|
|
102
|
-
|
|
103
|
-
class Artifact(BaseModel):
|
|
104
|
-
"""Represents an artifact payload used by A2A helpers and executors.
|
|
105
|
-
|
|
106
|
-
This model standardizes the structure for artifacts generated by tools and
|
|
107
|
-
passed through the A2A pipeline.
|
|
108
|
-
|
|
109
|
-
Attributes:
|
|
110
|
-
artifact_type (ArtifactType): The type of artifact. Defaults to FILE.
|
|
111
|
-
data (str): Base64-encoded content of the artifact.
|
|
112
|
-
name (str): Display name or filename of the artifact.
|
|
113
|
-
description (str): Optional description for the artifact. Defaults to empty string.
|
|
114
|
-
mime_type (str): MIME type of the artifact content.
|
|
115
|
-
metadata (dict[str, Any] | None): Optional per-artifact metadata to pass through.
|
|
116
|
-
"""
|
|
117
|
-
artifact_type: ArtifactType
|
|
118
|
-
data: str
|
|
119
|
-
name: str
|
|
120
|
-
description: str
|
|
121
|
-
mime_type: str
|
|
122
|
-
metadata: dict[str, Any] | None
|
|
123
|
-
@classmethod
|
|
124
|
-
def validate_base64(cls, v: str) -> str:
|
|
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
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
from aip_agents.agent.base_agent import BaseAgent as BaseAgent
|
|
2
|
-
from aip_agents.agent.base_langgraph_agent import BaseLangGraphAgent as BaseLangGraphAgent
|
|
3
|
-
from aip_agents.agent.google_adk_agent import GoogleADKAgent as GoogleADKAgent
|
|
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
|
|
7
|
-
from aip_agents.agent.langgraph_react_agent import LangChainAgent as LangChainAgent, LangGraphAgent as LangGraphAgent, LangGraphReactAgent as LangGraphReactAgent
|
|
8
|
-
|
|
9
|
-
__all__ = ['AgentInterface', 'BaseAgent', 'BaseLangGraphAgent', 'LangGraphReactAgent', 'GoogleADKAgent', 'LangGraphAgent', 'LangChainAgent', 'LangflowAgent', 'LangGraphMemoryEnhancerAgent']
|
aip_agents/agent/base_agent.pyi
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from a2a.types import AgentCard
|
|
3
|
-
from aip_agents.agent.interface import AgentInterface as AgentInterface
|
|
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
|
|
8
|
-
from aip_agents.utils.a2a_connector import A2AConnector as A2AConnector
|
|
9
|
-
from aip_agents.utils.logger import get_logger as get_logger
|
|
10
|
-
from aip_agents.utils.name_preprocessor.name_preprocessor import NamePreprocessor as NamePreprocessor
|
|
11
|
-
from collections.abc import AsyncGenerator
|
|
12
|
-
from starlette.applications import Starlette
|
|
13
|
-
from typing import Any
|
|
14
|
-
|
|
15
|
-
logger: Incomplete
|
|
16
|
-
AGENT_EXECUTOR_MAPPING: Incomplete
|
|
17
|
-
DEFAULT_RETRY_CONFIG: Incomplete
|
|
18
|
-
LM_EXCLUDE_FIELDS: Incomplete
|
|
19
|
-
CUSTOM_PROVIDERS: Incomplete
|
|
20
|
-
OUTPUT_ANALYTICS_KEY: str
|
|
21
|
-
|
|
22
|
-
class BaseAgent(AgentInterface):
|
|
23
|
-
"""Base class for agents, providing common A2A client method implementations.
|
|
24
|
-
|
|
25
|
-
Concrete agent implementations (e.g., LangGraphAgent, GoogleADKAgent)
|
|
26
|
-
should inherit from this class if they need to utilize the shared A2A
|
|
27
|
-
client functionalities.
|
|
28
|
-
|
|
29
|
-
This class now supports flexible model handling:
|
|
30
|
-
- model: Optional[Any] - can be an lm_invoker, string/ModelId, LangChain BaseChatModel, or other types
|
|
31
|
-
- Automatically sets self.lm_invoker if an lm_invoker is provided or can be built
|
|
32
|
-
- Stores the original model in self.model for subclass use
|
|
33
|
-
- Enhanced credential support with automatic type detection
|
|
34
|
-
"""
|
|
35
|
-
model: Incomplete
|
|
36
|
-
tools: Incomplete
|
|
37
|
-
tool_configs: Incomplete
|
|
38
|
-
mcp_client: BaseMCPClient | None
|
|
39
|
-
name_preprocessor: Incomplete
|
|
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
|
-
"""Initializes the BaseAgent.
|
|
42
|
-
|
|
43
|
-
Args:
|
|
44
|
-
name: The name of the agent.
|
|
45
|
-
instruction: The core directive or system prompt for the agent.
|
|
46
|
-
description: Human-readable description. Defaults to instruction if not provided.
|
|
47
|
-
model: The model to use. Can be:
|
|
48
|
-
- BaseLMInvoker instance (will be set as self.lm_invoker)
|
|
49
|
-
- String or ModelId (will build an lm_invoker)
|
|
50
|
-
- LangChain BaseChatModel (will be stored in self.model)
|
|
51
|
-
- Any other type (will be stored in self.model)
|
|
52
|
-
tools: List of tools available to the agent.
|
|
53
|
-
config: Additional configuration for the agent. Can be a BaseAgentConfig instance or dict.
|
|
54
|
-
tool_configs: Default tool configurations applied to all tool calls from this agent.
|
|
55
|
-
**kwargs: Additional keyword arguments for AgentInterface.
|
|
56
|
-
"""
|
|
57
|
-
def get_name_preprocessor(self) -> NamePreprocessor:
|
|
58
|
-
"""Get the name preprocessor based on the provider.
|
|
59
|
-
|
|
60
|
-
This will be used to correct the agent name and tool name. (mostly tool name)
|
|
61
|
-
|
|
62
|
-
Returns:
|
|
63
|
-
NamePreprocessor: The name preprocessor for the model.
|
|
64
|
-
"""
|
|
65
|
-
@property
|
|
66
|
-
def model_provider(self) -> str:
|
|
67
|
-
"""Get the provider of the model with simplified logic.
|
|
68
|
-
|
|
69
|
-
Returns:
|
|
70
|
-
str: The provider of the model.
|
|
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
|
-
"""
|
|
88
|
-
def to_a2a(self, agent_card: AgentCard, **kwargs: Any) -> Starlette:
|
|
89
|
-
"""Converts the agent to an A2A-compatible ASGI application.
|
|
90
|
-
|
|
91
|
-
This implementation provides a base setup for A2A server components.
|
|
92
|
-
Subclasses can override this method if they need custom executor
|
|
93
|
-
or task store implementations.
|
|
94
|
-
|
|
95
|
-
Args:
|
|
96
|
-
agent_card: The agent card to use for the A2A application.
|
|
97
|
-
**kwargs: Additional keyword arguments for ASGI application configuration.
|
|
98
|
-
|
|
99
|
-
Returns:
|
|
100
|
-
A Starlette ASGI application that can be used with any ASGI server.
|
|
101
|
-
"""
|
|
102
|
-
@classmethod
|
|
103
|
-
def discover_agents(cls, a2a_config: A2AClientConfig, **kwargs: Any) -> list[AgentCard]:
|
|
104
|
-
"""Discover agents from the URLs specified in a2a_config.discovery_urls.
|
|
105
|
-
|
|
106
|
-
This concrete implementation fetches and parses .well-known/agent.json
|
|
107
|
-
from each discovery URL to build a list of available agents.
|
|
108
|
-
|
|
109
|
-
Args:
|
|
110
|
-
a2a_config: Configuration containing discovery URLs and other A2A settings.
|
|
111
|
-
**kwargs: Additional keyword arguments (unused in this implementation).
|
|
112
|
-
|
|
113
|
-
Returns:
|
|
114
|
-
A list of AgentCard objects representing discovered agents.
|
|
115
|
-
"""
|
|
116
|
-
def send_to_agent(self, agent_card: AgentCard, message: str | dict[str, Any], **kwargs: Any) -> dict[str, Any]:
|
|
117
|
-
"""Synchronously sends a message to another agent using the A2A protocol.
|
|
118
|
-
|
|
119
|
-
This method is a synchronous wrapper around asend_to_agent. It handles the creation
|
|
120
|
-
of an event loop if one doesn't exist, and manages the asynchronous call internally.
|
|
121
|
-
|
|
122
|
-
Args:
|
|
123
|
-
agent_card: The AgentCard instance containing the target agent's details including
|
|
124
|
-
URL, authentication requirements, and capabilities.
|
|
125
|
-
message: The message to send to the agent. Can be either a string for simple text
|
|
126
|
-
messages or a dictionary for structured data.
|
|
127
|
-
**kwargs: Additional keyword arguments passed to asend_to_agent.
|
|
128
|
-
|
|
129
|
-
Returns:
|
|
130
|
-
A dictionary containing the response details:
|
|
131
|
-
- status (str): 'success' or 'error'
|
|
132
|
-
- content (str): Extracted text content from the response
|
|
133
|
-
- task_id (str, optional): ID of the created/updated task
|
|
134
|
-
- task_state (str, optional): Current state of the task
|
|
135
|
-
- raw_response (str): Complete JSON response from the A2A client
|
|
136
|
-
- error_type (str, optional): Type of error if status is 'error'
|
|
137
|
-
- message (str, optional): Error message if status is 'error'
|
|
138
|
-
|
|
139
|
-
Raises:
|
|
140
|
-
RuntimeError: If called from within an existing event loop or if asend_to_agent
|
|
141
|
-
encounters an unhandled exception.
|
|
142
|
-
"""
|
|
143
|
-
async def asend_to_agent(self, agent_card: AgentCard, message: str | dict[str, Any], **kwargs: Any) -> dict[str, Any]:
|
|
144
|
-
"""Asynchronously sends a message to another agent using the A2A protocol.
|
|
145
|
-
|
|
146
|
-
This method handles the core A2A communication logic, creating and sending properly
|
|
147
|
-
formatted A2A messages and processing the responses.
|
|
148
|
-
|
|
149
|
-
Args:
|
|
150
|
-
agent_card: The AgentCard instance containing the target agent's details including
|
|
151
|
-
URL, authentication requirements, and capabilities.
|
|
152
|
-
message: The message to send to the agent. Can be either a string for simple text
|
|
153
|
-
messages or a dictionary for structured data.
|
|
154
|
-
**kwargs: Additional keyword arguments.
|
|
155
|
-
|
|
156
|
-
Returns:
|
|
157
|
-
A dictionary containing the response details:
|
|
158
|
-
- status (str): 'success' or 'error'
|
|
159
|
-
- content (str): Extracted text content from the response
|
|
160
|
-
- task_id (str, optional): ID of the created/updated task
|
|
161
|
-
- task_state (str, optional): Current state of the task
|
|
162
|
-
- raw_response (str): Complete JSON response from the A2A client
|
|
163
|
-
- error_type (str, optional): Type of error if status is 'error'
|
|
164
|
-
- message (str, optional): Error message if status is 'error'
|
|
165
|
-
|
|
166
|
-
Raises:
|
|
167
|
-
httpx.HTTPError: If there's an HTTP-related error during the request.
|
|
168
|
-
Exception: For any other unexpected errors during message sending or processing.
|
|
169
|
-
"""
|
|
170
|
-
async def astream_to_agent(self, agent_card: AgentCard, message: str | dict[str, Any], **kwargs: Any) -> AsyncGenerator[dict[str, Any], None]:
|
|
171
|
-
"""Asynchronously sends a streaming message to another agent using the A2A protocol.
|
|
172
|
-
|
|
173
|
-
This method supports streaming responses from the target agent, yielding chunks of
|
|
174
|
-
the response as they become available. It handles various types of streaming events
|
|
175
|
-
including task status updates, artifact updates, and message parts.
|
|
176
|
-
|
|
177
|
-
Args:
|
|
178
|
-
agent_card: The AgentCard instance containing the target agent's details including
|
|
179
|
-
URL, authentication requirements, and capabilities.
|
|
180
|
-
message: The message to send to the agent. Can be either a string for simple text
|
|
181
|
-
messages or a dictionary for structured data.
|
|
182
|
-
**kwargs: Additional keyword arguments.
|
|
183
|
-
|
|
184
|
-
Yields:
|
|
185
|
-
Dictionaries containing streaming response chunks:
|
|
186
|
-
For successful chunks:
|
|
187
|
-
- status (str): 'success'
|
|
188
|
-
- content (str): Extracted text content from the chunk
|
|
189
|
-
- task_id (str): ID of the associated task
|
|
190
|
-
- task_state (str): Current state of the task
|
|
191
|
-
- final (bool): Whether this is the final chunk
|
|
192
|
-
- artifact_name (str, optional): Name of the artifact if chunk is an artifact update
|
|
193
|
-
For error chunks:
|
|
194
|
-
- status (str): 'error'
|
|
195
|
-
- error_type (str): Type of error encountered
|
|
196
|
-
- message (str): Error description
|
|
197
|
-
|
|
198
|
-
Raises:
|
|
199
|
-
httpx.HTTPError: If there's an HTTP-related error during the streaming request.
|
|
200
|
-
Exception: For any other unexpected errors during message streaming or processing.
|
|
201
|
-
"""
|
|
202
|
-
@staticmethod
|
|
203
|
-
def format_agent_description(agent_card: AgentCard) -> str:
|
|
204
|
-
"""Format the description of an agent card including skills information.
|
|
205
|
-
|
|
206
|
-
Args:
|
|
207
|
-
agent_card (AgentCard): The agent card to format.
|
|
208
|
-
|
|
209
|
-
Returns:
|
|
210
|
-
str: The formatted description including skills.
|
|
211
|
-
"""
|
|
212
|
-
def add_mcp_server(self, mcp_config: dict[str, dict[str, Any]]) -> None:
|
|
213
|
-
"""Adds MCP servers to the agent.
|
|
214
|
-
|
|
215
|
-
Args:
|
|
216
|
-
mcp_config: A dictionary containing MCP server configurations.
|
|
217
|
-
|
|
218
|
-
Raises:
|
|
219
|
-
ValueError: If the MCP configuration is empty or None.
|
|
220
|
-
KeyError: If a server with the same name already exists in the MCP configuration.
|
|
221
|
-
"""
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from a2a.types import AgentCard as AgentCard
|
|
3
|
-
from abc import abstractmethod
|
|
4
|
-
from aip_agents.agent.base_agent import BaseAgent as BaseAgent
|
|
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
|
-
from aip_agents.memory import BaseMemory as BaseMemory, MemoryFactory as MemoryFactory, MemoryMethod as MemoryMethod
|
|
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
|
|
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
|
|
13
|
-
from aip_agents.types import A2AEvent as A2AEvent, A2AStreamEventType as A2AStreamEventType
|
|
14
|
-
from aip_agents.utils import augment_query_with_file_paths as augment_query_with_file_paths, validate_references as validate_references
|
|
15
|
-
from aip_agents.utils.langgraph.tool_managers.a2a_tool_manager import A2AToolManager as A2AToolManager
|
|
16
|
-
from aip_agents.utils.langgraph.tool_managers.delegation_tool_manager import DelegationToolManager as DelegationToolManager
|
|
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
|
|
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
|
|
24
|
-
from dataclasses import dataclass
|
|
25
|
-
from gllm_core.event import EventEmitter
|
|
26
|
-
from gllm_core.schema import Chunk as Chunk
|
|
27
|
-
from langchain_core.tools import BaseTool
|
|
28
|
-
from langgraph.graph import StateGraph
|
|
29
|
-
from langgraph.graph.message import add_messages as add_messages
|
|
30
|
-
from langgraph.graph.state import CompiledStateGraph
|
|
31
|
-
from langgraph.types import Checkpointer
|
|
32
|
-
from typing import Any
|
|
33
|
-
|
|
34
|
-
logger: Incomplete
|
|
35
|
-
|
|
36
|
-
@dataclass
|
|
37
|
-
class _StreamingContext:
|
|
38
|
-
"""Context object for managing streaming state and configuration."""
|
|
39
|
-
original_query: str
|
|
40
|
-
graph_input: dict[str, Any]
|
|
41
|
-
config: dict[str, Any]
|
|
42
|
-
memory_user_id: str | None
|
|
43
|
-
current_thread_id: str
|
|
44
|
-
token: Any
|
|
45
|
-
enable_token_streaming: bool
|
|
46
|
-
final_event_yielded: bool = ...
|
|
47
|
-
pending_artifacts: list | None = ...
|
|
48
|
-
seen_artifact_hashes: set | None = ...
|
|
49
|
-
processed_message_count: int = ...
|
|
50
|
-
final_state: dict[str, Any] | None = ...
|
|
51
|
-
last_final_content: str | None = ...
|
|
52
|
-
saved_memory: bool = ...
|
|
53
|
-
is_token_streaming: bool = ...
|
|
54
|
-
def __post_init__(self) -> None:
|
|
55
|
-
"""Initialize mutable defaults."""
|
|
56
|
-
|
|
57
|
-
class BaseLangGraphAgent(BaseAgent):
|
|
58
|
-
"""Base class for LangGraph-based agents with unified tool approach.
|
|
59
|
-
|
|
60
|
-
Provides core LangGraph functionality including:
|
|
61
|
-
- Graph compilation and execution
|
|
62
|
-
- State schema management
|
|
63
|
-
- I/O mapping between user inputs and graph states
|
|
64
|
-
- Event emission support
|
|
65
|
-
- Tool resolution and handling
|
|
66
|
-
- A2A communication capabilities via tools
|
|
67
|
-
- Agent delegation capabilities via tools
|
|
68
|
-
- MCP server integration via tools
|
|
69
|
-
- Enhanced output extraction from various state formats
|
|
70
|
-
|
|
71
|
-
Tool Management:
|
|
72
|
-
- regular_tools: Standard LangChain tools provided during initialization
|
|
73
|
-
- mcp_tools: Tools retrieved from MCP servers
|
|
74
|
-
- resolved_tools: Combined collection of all tools for graph execution
|
|
75
|
-
|
|
76
|
-
Subclasses must implement:
|
|
77
|
-
- define_graph(): Define the specific graph structure
|
|
78
|
-
- _prepare_graph_input(): Convert user input to graph state
|
|
79
|
-
- _format_graph_output(): Convert final graph state to user output
|
|
80
|
-
"""
|
|
81
|
-
state_schema: Incomplete
|
|
82
|
-
thread_id_key: Incomplete
|
|
83
|
-
enable_a2a_token_streaming: Incomplete
|
|
84
|
-
event_emitter: Incomplete
|
|
85
|
-
checkpointer: Incomplete
|
|
86
|
-
tool_output_manager: Incomplete
|
|
87
|
-
memory: BaseMemory | None
|
|
88
|
-
a2a_tool_manager: Incomplete
|
|
89
|
-
delegation_tool_manager: Incomplete
|
|
90
|
-
regular_tools: list[BaseTool]
|
|
91
|
-
mcp_tools: list[BaseTool]
|
|
92
|
-
resolved_tools: list[BaseTool]
|
|
93
|
-
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:
|
|
94
|
-
'''Initialize the BaseLangGraphAgent.
|
|
95
|
-
|
|
96
|
-
Args:
|
|
97
|
-
name: The name of the agent.
|
|
98
|
-
instruction: The system instruction for the agent.
|
|
99
|
-
description: Human-readable description of the agent.
|
|
100
|
-
model: The model to use (lm_invoker, LangChain model, string, etc.).
|
|
101
|
-
tools: Sequence of regular LangChain tools (not A2A or delegation tools).
|
|
102
|
-
state_schema: The state schema for the LangGraph. Defaults to basic message state.
|
|
103
|
-
thread_id_key: Key for thread ID in configuration.
|
|
104
|
-
event_emitter: Optional event emitter for streaming updates.
|
|
105
|
-
checkpointer: Optional checkpointer for conversation persistence.
|
|
106
|
-
enable_a2a_token_streaming: Enable token-level streaming for A2A responses.
|
|
107
|
-
- False (default): Stream message-level events only
|
|
108
|
-
- True: Stream individual tokens plus message-level events
|
|
109
|
-
**kwargs: Additional keyword arguments passed to BaseAgent (including tool_configs and memory settings).
|
|
110
|
-
Memory settings include:
|
|
111
|
-
- memory_backend: Memory backend (e.g., "mem0")
|
|
112
|
-
- agent_id: Agent identifier for memory scoping
|
|
113
|
-
- memory_namespace: Memory namespace
|
|
114
|
-
- save_interaction_to_memory: Whether to save interactions (default True)
|
|
115
|
-
'''
|
|
116
|
-
def set_operation_mode(self, mode: str) -> None:
|
|
117
|
-
'''Set the operation mode for dependency tracking.
|
|
118
|
-
|
|
119
|
-
Args:
|
|
120
|
-
mode: Operation mode - "parallel" (default) or "sequential"
|
|
121
|
-
'''
|
|
122
|
-
@abstractmethod
|
|
123
|
-
def define_graph(self, graph_builder: StateGraph) -> CompiledStateGraph:
|
|
124
|
-
"""Define the specific graph structure for this agent type.
|
|
125
|
-
|
|
126
|
-
Subclasses must implement this method to:
|
|
127
|
-
1. Add nodes to the graph_builder
|
|
128
|
-
2. Add edges and conditional edges
|
|
129
|
-
3. Set entry points
|
|
130
|
-
4. Return the compiled graph
|
|
131
|
-
|
|
132
|
-
Args:
|
|
133
|
-
graph_builder: The StateGraph builder to define nodes and edges on.
|
|
134
|
-
|
|
135
|
-
Returns:
|
|
136
|
-
The compiled graph ready for execution.
|
|
137
|
-
"""
|
|
138
|
-
def register_a2a_agents(self, agent_cards: list[AgentCard]) -> None:
|
|
139
|
-
"""Register A2A communication capabilities using the A2A tool manager.
|
|
140
|
-
|
|
141
|
-
Args:
|
|
142
|
-
agent_cards (list[AgentCard]): List of AgentCard instances for external communication.
|
|
143
|
-
"""
|
|
144
|
-
def register_delegation_agents(self, agents: list[BaseAgent]) -> None:
|
|
145
|
-
"""Register internal agent delegation capabilities using the delegation tool manager.
|
|
146
|
-
|
|
147
|
-
Args:
|
|
148
|
-
agents: List of BaseAgent instances for internal task delegation.
|
|
149
|
-
"""
|
|
150
|
-
tools: Incomplete
|
|
151
|
-
def update_regular_tools(self, new_tools: list[BaseTool], rebuild_graph: bool | None = None) -> None:
|
|
152
|
-
"""Update regular tools (not capabilities).
|
|
153
|
-
|
|
154
|
-
Args:
|
|
155
|
-
new_tools: New list of regular tools to use.
|
|
156
|
-
rebuild_graph: Whether to rebuild graph. If None, uses auto_rebuild_graph setting.
|
|
157
|
-
"""
|
|
158
|
-
def run(self, query: str, **kwargs: Any) -> dict[str, Any]:
|
|
159
|
-
"""Synchronously run the LangGraph agent.
|
|
160
|
-
|
|
161
|
-
Args:
|
|
162
|
-
query: The input query for the agent.
|
|
163
|
-
**kwargs: Additional keyword arguments.
|
|
164
|
-
|
|
165
|
-
Returns:
|
|
166
|
-
Dictionary containing the agent's response.
|
|
167
|
-
"""
|
|
168
|
-
async def arun(self, query: str, **kwargs: Any) -> dict[str, Any]:
|
|
169
|
-
"""Asynchronously run the LangGraph agent with lazy MCP initialization.
|
|
170
|
-
|
|
171
|
-
Args:
|
|
172
|
-
query: The input query for the agent.
|
|
173
|
-
**kwargs: Additional keyword arguments including configurable for LangGraph.
|
|
174
|
-
|
|
175
|
-
Returns:
|
|
176
|
-
Dictionary containing the agent's response and full final state.
|
|
177
|
-
"""
|
|
178
|
-
async def arun_stream(self, query: str, **kwargs: Any) -> AsyncGenerator[str | dict[str, Any], None]:
|
|
179
|
-
"""Asynchronously stream the LangGraph agent's response.
|
|
180
|
-
|
|
181
|
-
If MCP configuration exists, connects to the MCP server and registers tools before streaming.
|
|
182
|
-
This method properly handles both LM Invoker and LangChain model streaming:
|
|
183
|
-
- For LM Invoker: Uses StreamEventHandler to capture streaming events
|
|
184
|
-
- For LangChain models: Uses LangGraph's native streaming implementation
|
|
185
|
-
|
|
186
|
-
Args:
|
|
187
|
-
query: The input query for the agent.
|
|
188
|
-
**kwargs: Additional keyword arguments.
|
|
189
|
-
|
|
190
|
-
Yields:
|
|
191
|
-
Chunks of output (strings or dicts) from the streaming response.
|
|
192
|
-
"""
|
|
193
|
-
async def cleanup(self) -> None:
|
|
194
|
-
"""Cleanup MCP resources including persistent sessions.
|
|
195
|
-
|
|
196
|
-
This method performs best-effort cleanup of MCP client resources.
|
|
197
|
-
Errors during cleanup are logged but do not raise exceptions to ensure
|
|
198
|
-
the cleanup process completes gracefully.
|
|
199
|
-
"""
|
|
200
|
-
async def arun_a2a_stream(self, query: str, **kwargs: Any) -> AsyncGenerator[A2AEvent, None]:
|
|
201
|
-
'''Asynchronously streams the agent\'s response in A2A format.
|
|
202
|
-
|
|
203
|
-
Args:
|
|
204
|
-
query: The input query for the agent.
|
|
205
|
-
**kwargs: Additional keyword arguments.
|
|
206
|
-
|
|
207
|
-
Yields:
|
|
208
|
-
Dictionaries with "status" and "content" keys.
|
|
209
|
-
Possible statuses: "working", "completed", "failed", "canceled".
|
|
210
|
-
'''
|
|
211
|
-
async def arun_sse_stream(self, query: str, task_id: str | None = None, context_id: str | None = None, **kwargs: Any) -> AsyncGenerator[A2AEvent, None]:
|
|
212
|
-
'''Stream agent response as SSE-compatible chunks.
|
|
213
|
-
|
|
214
|
-
This method wraps arun_a2a_stream and transforms output to the normalized
|
|
215
|
-
dict format matching A2AConnector.astream_to_agent output, enabling direct
|
|
216
|
-
streaming without A2A server overhead.
|
|
217
|
-
|
|
218
|
-
Args:
|
|
219
|
-
query: The input query for the agent.
|
|
220
|
-
task_id: Optional task identifier for the stream.
|
|
221
|
-
context_id: Optional context identifier for the stream.
|
|
222
|
-
**kwargs: Additional arguments passed to arun_a2a_stream.
|
|
223
|
-
|
|
224
|
-
Yields:
|
|
225
|
-
SSEChunk dicts with normalized structure:
|
|
226
|
-
- status: "success" | "error"
|
|
227
|
-
- task_state: "working" | "completed" | "failed" | "canceled"
|
|
228
|
-
- content: Text content or None
|
|
229
|
-
- event_type: Always string (never enum)
|
|
230
|
-
- final: True for terminal events
|
|
231
|
-
- metadata: Normalized metadata dict
|
|
232
|
-
- artifacts: Only present when non-empty
|
|
233
|
-
'''
|