aip-agents-binary 0.0.0__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/__init__.py +66 -0
- aip_agents/a2a/__init__.py +19 -0
- aip_agents/a2a/server/__init__.py +10 -0
- aip_agents/a2a/server/base_executor.py +1125 -0
- aip_agents/a2a/server/google_adk_executor.py +198 -0
- aip_agents/a2a/server/langflow_executor.py +180 -0
- aip_agents/a2a/server/langgraph_executor.py +270 -0
- aip_agents/a2a/types.py +232 -0
- aip_agents/a2ui/__init__.py +26 -0
- aip_agents/a2ui/catalog_provider.py +109 -0
- aip_agents/a2ui/examples/0.8/booking_form.json +1 -0
- aip_agents/a2ui/examples/0.8/confirmation.json +1 -0
- aip_agents/a2ui/examples/0.8/single_column_list.json +1 -0
- aip_agents/a2ui/examples/0.9/booking_form.json +1 -0
- aip_agents/a2ui/examples/0.9/confirmation.json +1 -0
- aip_agents/a2ui/examples/0.9/single_column_list.json +1 -0
- aip_agents/a2ui/middleware.py +754 -0
- aip_agents/a2ui/models.py +153 -0
- aip_agents/a2ui/public_url.py +138 -0
- aip_agents/a2ui/stream_filter.py +67 -0
- aip_agents/agent/__init__.py +72 -0
- aip_agents/agent/base_agent.py +1437 -0
- aip_agents/agent/base_langgraph_agent.py +4048 -0
- aip_agents/agent/google_adk_agent.py +932 -0
- aip_agents/agent/google_adk_constants.py +11 -0
- aip_agents/agent/graph_runtime.py +185 -0
- aip_agents/agent/hitl/__init__.py +24 -0
- aip_agents/agent/hitl/config.py +28 -0
- aip_agents/agent/hitl/langgraph_hitl_mixin.py +515 -0
- aip_agents/agent/hitl/manager.py +532 -0
- aip_agents/agent/hitl/models.py +18 -0
- aip_agents/agent/hitl/prompt/__init__.py +9 -0
- aip_agents/agent/hitl/prompt/base.py +42 -0
- aip_agents/agent/hitl/prompt/deferred.py +73 -0
- aip_agents/agent/hitl/registry.py +149 -0
- aip_agents/agent/interface.py +138 -0
- aip_agents/agent/interfaces.py +65 -0
- aip_agents/agent/langflow_agent.py +464 -0
- aip_agents/agent/langgraph_react_agent.py +3741 -0
- aip_agents/agent/model_invocation_adapter.py +346 -0
- aip_agents/agent/system_instruction_context.py +34 -0
- aip_agents/agent/tool_execution_engine.py +587 -0
- aip_agents/audio_interface/__init__.py +30 -0
- aip_agents/audio_interface/audio_agent_adapter.py +254 -0
- aip_agents/audio_interface/config.py +146 -0
- aip_agents/audio_interface/errors.py +15 -0
- aip_agents/audio_interface/livekit_audio_session.py +504 -0
- aip_agents/audio_interface/livekit_realtime_audio_session.py +142 -0
- aip_agents/audio_interface/session_factory.py +40 -0
- aip_agents/clients/__init__.py +10 -0
- aip_agents/clients/langflow/__init__.py +10 -0
- aip_agents/clients/langflow/client.py +477 -0
- aip_agents/clients/langflow/types.py +18 -0
- aip_agents/common/__init__.py +5 -0
- aip_agents/common/callable_introspection.py +17 -0
- aip_agents/constants.py +23 -0
- aip_agents/context/__init__.py +5 -0
- aip_agents/context/budget.py +237 -0
- aip_agents/context/compaction.py +339 -0
- aip_agents/context/metadata.py +169 -0
- aip_agents/context/offload.py +449 -0
- aip_agents/context/preparation.py +196 -0
- aip_agents/context/prompt.py +61 -0
- aip_agents/context/runtime.py +149 -0
- aip_agents/context/session_recall.py +69 -0
- aip_agents/context/state.py +48 -0
- aip_agents/context/utils.py +44 -0
- aip_agents/credentials/manager.py +132 -0
- aip_agents/examples/__init__.py +5 -0
- aip_agents/examples/audio_livekit_session.py +116 -0
- aip_agents/examples/compare_streaming_client.py +783 -0
- aip_agents/examples/compare_streaming_server.py +141 -0
- aip_agents/examples/gl_connectors_smoke.py +148 -0
- aip_agents/examples/hello_world_a2a_google_adk_client.py +49 -0
- aip_agents/examples/hello_world_a2a_google_adk_client_agent.py +48 -0
- aip_agents/examples/hello_world_a2a_google_adk_client_streaming.py +60 -0
- aip_agents/examples/hello_world_a2a_google_adk_server.py +78 -0
- aip_agents/examples/hello_world_a2a_langchain_client.py +39 -0
- aip_agents/examples/hello_world_a2a_langchain_client_agent.py +39 -0
- aip_agents/examples/hello_world_a2a_langchain_client_lm_invoker.py +37 -0
- aip_agents/examples/hello_world_a2a_langchain_client_streaming.py +41 -0
- aip_agents/examples/hello_world_a2a_langchain_reference_client_streaming.py +60 -0
- aip_agents/examples/hello_world_a2a_langchain_reference_server.py +104 -0
- aip_agents/examples/hello_world_a2a_langchain_server.py +78 -0
- aip_agents/examples/hello_world_a2a_langchain_server_lm_invoker.py +77 -0
- aip_agents/examples/hello_world_a2a_langflow_client.py +83 -0
- aip_agents/examples/hello_world_a2a_langflow_server.py +80 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client.py +73 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client_streaming.py +76 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_server.py +91 -0
- aip_agents/examples/hello_world_a2a_langgraph_client.py +54 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_agent.py +54 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_agent_lm_invoker.py +32 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming.py +50 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_lm_invoker.py +44 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_tool_streaming.py +92 -0
- aip_agents/examples/hello_world_a2a_langgraph_server.py +83 -0
- aip_agents/examples/hello_world_a2a_langgraph_server_lm_invoker.py +78 -0
- aip_agents/examples/hello_world_a2a_langgraph_server_tool_streaming.py +131 -0
- aip_agents/examples/hello_world_a2a_mcp_langgraph.py +196 -0
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_client.py +244 -0
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_server.py +250 -0
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_client.py +57 -0
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_server_lm_invoker.py +79 -0
- aip_agents/examples/hello_world_filesystem.py +162 -0
- aip_agents/examples/hello_world_google_adk.py +41 -0
- aip_agents/examples/hello_world_google_adk_mcp_http.py +34 -0
- aip_agents/examples/hello_world_google_adk_mcp_http_stream.py +40 -0
- aip_agents/examples/hello_world_google_adk_mcp_sse.py +44 -0
- aip_agents/examples/hello_world_google_adk_mcp_sse_stream.py +48 -0
- aip_agents/examples/hello_world_google_adk_mcp_stdio.py +44 -0
- aip_agents/examples/hello_world_google_adk_mcp_stdio_stream.py +48 -0
- aip_agents/examples/hello_world_google_adk_stream.py +44 -0
- aip_agents/examples/hello_world_langchain.py +28 -0
- aip_agents/examples/hello_world_langchain_lm_invoker.py +15 -0
- aip_agents/examples/hello_world_langchain_mcp_http.py +34 -0
- aip_agents/examples/hello_world_langchain_mcp_http_interactive.py +130 -0
- aip_agents/examples/hello_world_langchain_mcp_http_stream.py +42 -0
- aip_agents/examples/hello_world_langchain_mcp_multi_server.py +155 -0
- aip_agents/examples/hello_world_langchain_mcp_sse.py +34 -0
- aip_agents/examples/hello_world_langchain_mcp_sse_stream.py +40 -0
- aip_agents/examples/hello_world_langchain_mcp_stdio.py +30 -0
- aip_agents/examples/hello_world_langchain_mcp_stdio_stream.py +41 -0
- aip_agents/examples/hello_world_langchain_stream.py +36 -0
- aip_agents/examples/hello_world_langchain_stream_lm_invoker.py +39 -0
- aip_agents/examples/hello_world_langflow_agent.py +163 -0
- aip_agents/examples/hello_world_langgraph.py +39 -0
- aip_agents/examples/hello_world_langgraph_gl_connector_twitter.py +44 -0
- aip_agents/examples/hello_world_langgraph_mcp_http.py +31 -0
- aip_agents/examples/hello_world_langgraph_mcp_http_stream.py +34 -0
- aip_agents/examples/hello_world_langgraph_mcp_sse.py +35 -0
- aip_agents/examples/hello_world_langgraph_mcp_sse_stream.py +50 -0
- aip_agents/examples/hello_world_langgraph_mcp_stdio.py +35 -0
- aip_agents/examples/hello_world_langgraph_mcp_stdio_stream.py +50 -0
- aip_agents/examples/hello_world_langgraph_skills.py +62 -0
- aip_agents/examples/hello_world_langgraph_stream.py +43 -0
- aip_agents/examples/hello_world_langgraph_stream_lm_invoker.py +37 -0
- aip_agents/examples/hello_world_model_switch_cli.py +210 -0
- aip_agents/examples/hello_world_multi_agent_adk.py +75 -0
- aip_agents/examples/hello_world_multi_agent_langchain.py +54 -0
- aip_agents/examples/hello_world_multi_agent_langgraph.py +66 -0
- aip_agents/examples/hello_world_multi_agent_langgraph_lm_invoker.py +69 -0
- aip_agents/examples/hello_world_multi_agent_tool_output_client.py +57 -0
- aip_agents/examples/hello_world_multi_agent_tool_output_server.py +131 -0
- aip_agents/examples/hello_world_pii_logger.py +21 -0
- aip_agents/examples/hello_world_ptc.py +49 -0
- aip_agents/examples/hello_world_ptc_custom_tools.py +83 -0
- aip_agents/examples/hello_world_sentry.py +133 -0
- aip_agents/examples/hello_world_step_limits.py +273 -0
- aip_agents/examples/hello_world_stock_a2a_server.py +100 -0
- aip_agents/examples/hello_world_tool_output_client.py +55 -0
- aip_agents/examples/hello_world_tool_output_server.py +113 -0
- aip_agents/examples/hitl_demo.py +724 -0
- aip_agents/examples/mcp_configs/configs.py +63 -0
- aip_agents/examples/mcp_servers/common.py +76 -0
- aip_agents/examples/mcp_servers/mcp_name.py +29 -0
- aip_agents/examples/mcp_servers/mcp_server_http.py +19 -0
- aip_agents/examples/mcp_servers/mcp_server_sse.py +19 -0
- aip_agents/examples/mcp_servers/mcp_server_stdio.py +19 -0
- aip_agents/examples/mcp_servers/mcp_time.py +10 -0
- aip_agents/examples/pii_demo_langgraph_client.py +69 -0
- aip_agents/examples/pii_demo_langgraph_server.py +125 -0
- aip_agents/examples/pii_demo_multi_agent_client.py +80 -0
- aip_agents/examples/pii_demo_multi_agent_server.py +246 -0
- aip_agents/examples/todolist_planning_a2a_langchain_client.py +70 -0
- aip_agents/examples/todolist_planning_a2a_langgraph_server.py +87 -0
- aip_agents/examples/tools/__init__.py +27 -0
- aip_agents/examples/tools/adk_arithmetic_tools.py +36 -0
- aip_agents/examples/tools/adk_weather_tool.py +60 -0
- aip_agents/examples/tools/data_generator_tool.py +103 -0
- aip_agents/examples/tools/data_visualization_tool.py +312 -0
- aip_agents/examples/tools/image_artifact_tool.py +136 -0
- aip_agents/examples/tools/langchain_arithmetic_tools.py +26 -0
- aip_agents/examples/tools/langchain_currency_exchange_tool.py +88 -0
- aip_agents/examples/tools/langchain_graph_artifact_tool.py +172 -0
- aip_agents/examples/tools/langchain_weather_tool.py +48 -0
- aip_agents/examples/tools/langgraph_streaming_tool.py +130 -0
- aip_agents/examples/tools/mock_retrieval_tool.py +56 -0
- aip_agents/examples/tools/multiply_tool.py +43 -0
- aip_agents/examples/tools/pii_demo_tools.py +189 -0
- aip_agents/examples/tools/random_chart_tool.py +142 -0
- aip_agents/examples/tools/serper_tool.py +202 -0
- aip_agents/examples/tools/stock_tools.py +82 -0
- aip_agents/examples/tools/table_generator_tool.py +167 -0
- aip_agents/examples/tools/time_tool.py +82 -0
- aip_agents/examples/tools/weather_forecast_tool.py +38 -0
- aip_agents/guardrails/__init__.py +83 -0
- aip_agents/guardrails/engines/__init__.py +69 -0
- aip_agents/guardrails/engines/base.py +90 -0
- aip_agents/guardrails/engines/nemo.py +101 -0
- aip_agents/guardrails/engines/phrase_matcher.py +113 -0
- aip_agents/guardrails/exceptions.py +39 -0
- aip_agents/guardrails/manager.py +163 -0
- aip_agents/guardrails/middleware.py +199 -0
- aip_agents/guardrails/schemas.py +63 -0
- aip_agents/guardrails/utils.py +45 -0
- aip_agents/integration/__init__.py +43 -0
- aip_agents/integration/agent.py +58 -0
- aip_agents/integration/guardrails.py +52 -0
- aip_agents/integration/hitl.py +71 -0
- aip_agents/integration/ptc.py +95 -0
- aip_agents/integration/skills.py +37 -0
- aip_agents/integration/storage.py +81 -0
- aip_agents/integration/version.py +103 -0
- aip_agents/mcp/__init__.py +1 -0
- aip_agents/mcp/client/__init__.py +60 -0
- aip_agents/mcp/client/base_mcp_client.py +377 -0
- aip_agents/mcp/client/connection_manager.py +231 -0
- aip_agents/mcp/client/errors.py +119 -0
- aip_agents/mcp/client/google_adk/__init__.py +45 -0
- aip_agents/mcp/client/google_adk/client.py +383 -0
- aip_agents/mcp/client/langchain/__init__.py +11 -0
- aip_agents/mcp/client/langchain/client.py +265 -0
- aip_agents/mcp/client/persistent_session.py +704 -0
- aip_agents/mcp/client/session_pool.py +358 -0
- aip_agents/mcp/client/transports.py +288 -0
- aip_agents/mcp/utils/__init__.py +7 -0
- aip_agents/mcp/utils/config_validator.py +139 -0
- aip_agents/memory/__init__.py +14 -0
- aip_agents/memory/adapters/__init__.py +10 -0
- aip_agents/memory/adapters/base_adapter.py +815 -0
- aip_agents/memory/adapters/mem0.py +286 -0
- aip_agents/memory/base.py +84 -0
- aip_agents/memory/constants.py +49 -0
- aip_agents/memory/factory.py +86 -0
- aip_agents/memory/guidance.py +20 -0
- aip_agents/memory/simple_memory.py +47 -0
- aip_agents/middleware/__init__.py +65 -0
- aip_agents/middleware/backends/__init__.py +72 -0
- aip_agents/middleware/backends/in_memory.py +578 -0
- aip_agents/middleware/backends/local_disk.py +1203 -0
- aip_agents/middleware/backends/protocol.py +353 -0
- aip_agents/middleware/backends/sandbox.py +1431 -0
- aip_agents/middleware/backends/sandbox_files.py +113 -0
- aip_agents/middleware/backends/utils.py +293 -0
- aip_agents/middleware/base.py +239 -0
- aip_agents/middleware/filesystem.py +690 -0
- aip_agents/middleware/manager.py +291 -0
- aip_agents/middleware/memory.py +532 -0
- aip_agents/middleware/pii_middleware.py +192 -0
- aip_agents/middleware/schema.py +19 -0
- aip_agents/middleware/skills.py +872 -0
- aip_agents/middleware/task_delegation.py +1656 -0
- aip_agents/middleware/todolist.py +276 -0
- aip_agents/middleware/tools/__init__.py +23 -0
- aip_agents/middleware/tools/edit_file.py +70 -0
- aip_agents/middleware/tools/execute.py +428 -0
- aip_agents/middleware/tools/grep_file.py +79 -0
- aip_agents/middleware/tools/ls.py +71 -0
- aip_agents/middleware/tools/read_file.py +239 -0
- aip_agents/middleware/tools/skill_load.py +193 -0
- aip_agents/middleware/tools/skill_resource.py +338 -0
- aip_agents/middleware/tools/write_file.py +114 -0
- aip_agents/middleware/vision.py +322 -0
- aip_agents/ptc/__init__.py +87 -0
- aip_agents/ptc/custom_tools.py +511 -0
- aip_agents/ptc/custom_tools_payload.py +499 -0
- aip_agents/ptc/custom_tools_templates/__init__.py +1 -0
- aip_agents/ptc/custom_tools_templates/custom_build_function.py.template +24 -0
- aip_agents/ptc/custom_tools_templates/custom_init.py.template +26 -0
- aip_agents/ptc/custom_tools_templates/custom_invoke.py.template +149 -0
- aip_agents/ptc/custom_tools_templates/custom_registry.py.template +112 -0
- aip_agents/ptc/custom_tools_templates/custom_sources_init.py.template +7 -0
- aip_agents/ptc/custom_tools_templates/custom_wrapper.py.template +87 -0
- aip_agents/ptc/doc_gen.py +122 -0
- aip_agents/ptc/exceptions.py +57 -0
- aip_agents/ptc/executor.py +627 -0
- aip_agents/ptc/mcp/__init__.py +45 -0
- aip_agents/ptc/mcp/sandbox_bridge.py +679 -0
- aip_agents/ptc/mcp/templates/__init__.py +1 -0
- aip_agents/ptc/mcp/templates/mcp_client.py.template +240 -0
- aip_agents/ptc/naming.py +430 -0
- aip_agents/ptc/payload.py +26 -0
- aip_agents/ptc/prompt_builder.py +674 -0
- aip_agents/ptc/ptc_helper.py +16 -0
- aip_agents/ptc/sandbox_bridge.py +297 -0
- aip_agents/ptc/template_utils.py +33 -0
- aip_agents/ptc/templates/__init__.py +1 -0
- aip_agents/ptc/templates/ptc_helper.py.template +134 -0
- aip_agents/ptc/tool_def_helpers.py +101 -0
- aip_agents/ptc/tool_enrichment.py +163 -0
- aip_agents/resilience/__init__.py +10 -0
- aip_agents/resilience/base.py +46 -0
- aip_agents/resilience/tool.py +1661 -0
- aip_agents/sandbox/__init__.py +62 -0
- aip_agents/sandbox/defaults.py +220 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-1-datasaur.Dockerfile +120 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-1.Dockerfile +100 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-2-datasaur.Dockerfile +143 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-2.Dockerfile +119 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-3-datasaur.Dockerfile +173 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-3.Dockerfile +130 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-4-runner-managed.Dockerfile +164 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-4-runner-managed.patch_js_context.py +41 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2-4-runner-managed.requirements.txt +29 -0
- aip_agents/sandbox/dockerfiles/aip-agents-sandbox-v2.Dockerfile +87 -0
- aip_agents/sandbox/e2b_runtime.py +27 -0
- aip_agents/sandbox/image_registry.py +98 -0
- aip_agents/sandbox/providers/__init__.py +76 -0
- aip_agents/sandbox/providers/base.py +392 -0
- aip_agents/sandbox/providers/bedrock.py +28 -0
- aip_agents/sandbox/providers/e2b.py +230 -0
- aip_agents/sandbox/providers/opensandbox.py +163 -0
- aip_agents/sandbox/sandbox_runtime.py +967 -0
- aip_agents/sandbox/template_builder.py +240 -0
- aip_agents/sandbox/types.py +141 -0
- aip_agents/sandbox/validation.py +50 -0
- aip_agents/schema/__init__.py +106 -0
- aip_agents/schema/a2a.py +58 -0
- aip_agents/schema/agent.py +117 -0
- aip_agents/schema/artifacts.py +75 -0
- aip_agents/schema/attachments.py +425 -0
- aip_agents/schema/hitl.py +157 -0
- aip_agents/schema/langgraph.py +47 -0
- aip_agents/schema/model_id.py +103 -0
- aip_agents/schema/model_usage.py +50 -0
- aip_agents/schema/runtime_metadata.py +78 -0
- aip_agents/schema/step_limit.py +108 -0
- aip_agents/schema/storage.py +40 -0
- aip_agents/schema/tool_payloads.py +68 -0
- aip_agents/sentry/__init__.py +11 -0
- aip_agents/sentry/sentry.py +267 -0
- aip_agents/skills/__init__.py +30 -0
- aip_agents/skills/errors.py +110 -0
- aip_agents/skills/installer.py +479 -0
- aip_agents/skills/models.py +769 -0
- aip_agents/skills/stager.py +224 -0
- aip_agents/skills/validation.py +53 -0
- aip_agents/storage/__init__.py +41 -0
- aip_agents/storage/base.py +85 -0
- aip_agents/storage/clients/__init__.py +12 -0
- aip_agents/storage/clients/minio_client.py +318 -0
- aip_agents/storage/config.py +62 -0
- aip_agents/storage/providers/__init__.py +15 -0
- aip_agents/storage/providers/base.py +106 -0
- aip_agents/storage/providers/memory.py +114 -0
- aip_agents/storage/providers/object_storage.py +214 -0
- aip_agents/tools/__init__.py +65 -0
- aip_agents/tools/agent_schedule_tool.py +392 -0
- aip_agents/tools/browser_use/__init__.py +83 -0
- aip_agents/tools/browser_use/action_parser.py +104 -0
- aip_agents/tools/browser_use/browser_use_tool.py +1118 -0
- aip_agents/tools/browser_use/llm_config.py +120 -0
- aip_agents/tools/browser_use/minio_storage.py +203 -0
- aip_agents/tools/browser_use/schemas.py +121 -0
- aip_agents/tools/browser_use/session.py +13 -0
- aip_agents/tools/browser_use/session_errors.py +132 -0
- aip_agents/tools/browser_use/steel_session_recording.py +321 -0
- aip_agents/tools/browser_use/streaming.py +263 -0
- aip_agents/tools/browser_use/structured_data_parser.py +257 -0
- aip_agents/tools/browser_use/structured_data_recovery.py +204 -0
- aip_agents/tools/browser_use/types.py +37 -0
- aip_agents/tools/code_sandbox/__init__.py +48 -0
- aip_agents/tools/code_sandbox/code_sandbox_tool.py +350 -0
- aip_agents/tools/code_sandbox/constant.py +13 -0
- aip_agents/tools/code_sandbox/e2b_cloud_sandbox_extended.py +346 -0
- aip_agents/tools/code_sandbox/e2b_sandbox_tool.py +65 -0
- aip_agents/tools/computer_use/__init__.py +75 -0
- aip_agents/tools/computer_use/computer_use_tool.py +910 -0
- aip_agents/tools/computer_use/schemas.py +78 -0
- aip_agents/tools/computer_use/streaming.py +198 -0
- aip_agents/tools/computer_use/types.py +32 -0
- aip_agents/tools/constants.py +177 -0
- aip_agents/tools/date_range_tool.py +554 -0
- aip_agents/tools/document_loader/__init__.py +44 -0
- aip_agents/tools/document_loader/base_reader.py +302 -0
- aip_agents/tools/document_loader/docx_reader_tool.py +68 -0
- aip_agents/tools/document_loader/excel_reader_tool.py +171 -0
- aip_agents/tools/document_loader/pdf_reader_tool.py +79 -0
- aip_agents/tools/document_loader/pdf_splitter.py +169 -0
- aip_agents/tools/execute_ptc_code.py +582 -0
- aip_agents/tools/gl_connector/__init__.py +5 -0
- aip_agents/tools/gl_connector/tool.py +518 -0
- aip_agents/tools/gl_connector_tools.py +170 -0
- aip_agents/tools/memory_search/__init__.py +29 -0
- aip_agents/tools/memory_search/base.py +213 -0
- aip_agents/tools/memory_search/mem0.py +424 -0
- aip_agents/tools/memory_search/schema.py +81 -0
- aip_agents/tools/memory_search_tool.py +34 -0
- aip_agents/tools/streaming_common.py +577 -0
- aip_agents/tools/time_tool.py +117 -0
- aip_agents/tools/tool_config_injector.py +300 -0
- aip_agents/tools/web_search/__init__.py +15 -0
- aip_agents/tools/web_search/serper_tool.py +187 -0
- aip_agents/types/__init__.py +73 -0
- aip_agents/types/a2a_events.py +13 -0
- aip_agents/utils/__init__.py +91 -0
- aip_agents/utils/a2a_connector.py +1758 -0
- aip_agents/utils/artifact_helpers.py +542 -0
- aip_agents/utils/artifacts/__init__.py +20 -0
- aip_agents/utils/artifacts/tracker.py +367 -0
- aip_agents/utils/attachment_helpers.py +178 -0
- aip_agents/utils/constants.py +22 -0
- aip_agents/utils/datetime/__init__.py +34 -0
- aip_agents/utils/datetime/normalization.py +231 -0
- aip_agents/utils/datetime/timezone.py +206 -0
- aip_agents/utils/env_loader.py +27 -0
- aip_agents/utils/event_handler_registry.py +58 -0
- aip_agents/utils/file_prompt_utils.py +276 -0
- aip_agents/utils/file_watchers/__init__.py +33 -0
- aip_agents/utils/file_watchers/base.py +46 -0
- aip_agents/utils/file_watchers/e2b.py +128 -0
- aip_agents/utils/file_watchers/factory.py +39 -0
- aip_agents/utils/file_watchers/ls_diff.py +88 -0
- aip_agents/utils/file_watchers/sandbox.py +66 -0
- aip_agents/utils/file_watchers/watchdog.py +97 -0
- aip_agents/utils/final_response_builder.py +211 -0
- aip_agents/utils/formatter_llm_client.py +258 -0
- aip_agents/utils/langgraph/__init__.py +19 -0
- aip_agents/utils/langgraph/converter.py +399 -0
- aip_agents/utils/langgraph/delegation_context.py +22 -0
- aip_agents/utils/langgraph/tool_managers/__init__.py +15 -0
- aip_agents/utils/langgraph/tool_managers/a2a_tool_manager.py +99 -0
- aip_agents/utils/langgraph/tool_managers/base_tool_manager.py +66 -0
- aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.py +1329 -0
- aip_agents/utils/langgraph/tool_output_management.py +1047 -0
- aip_agents/utils/logger.py +195 -0
- aip_agents/utils/metadata/__init__.py +27 -0
- aip_agents/utils/metadata/activity_metadata_helper.py +407 -0
- aip_agents/utils/metadata/activity_narrative/__init__.py +35 -0
- aip_agents/utils/metadata/activity_narrative/builder.py +822 -0
- aip_agents/utils/metadata/activity_narrative/constants.py +51 -0
- aip_agents/utils/metadata/activity_narrative/context.py +49 -0
- aip_agents/utils/metadata/activity_narrative/formatters.py +230 -0
- aip_agents/utils/metadata/activity_narrative/utils.py +35 -0
- aip_agents/utils/metadata/schemas/__init__.py +16 -0
- aip_agents/utils/metadata/schemas/activity_schema.py +29 -0
- aip_agents/utils/metadata/schemas/thinking_schema.py +31 -0
- aip_agents/utils/metadata/thinking_metadata_helper.py +38 -0
- aip_agents/utils/metadata_helper.py +363 -0
- aip_agents/utils/name_preprocessor/__init__.py +17 -0
- aip_agents/utils/name_preprocessor/base_name_preprocessor.py +73 -0
- aip_agents/utils/name_preprocessor/google_name_preprocessor.py +100 -0
- aip_agents/utils/name_preprocessor/name_preprocessor.py +87 -0
- aip_agents/utils/name_preprocessor/openai_name_preprocessor.py +48 -0
- aip_agents/utils/pii/__init__.py +29 -0
- aip_agents/utils/pii/pii_handler.py +555 -0
- aip_agents/utils/pii/pii_helper.py +225 -0
- aip_agents/utils/pii/uuid_deanonymizer_mapping.py +195 -0
- aip_agents/utils/reference_helper.py +273 -0
- aip_agents/utils/sse_chunk_transformer.py +836 -0
- aip_agents/utils/step_limit_manager.py +265 -0
- aip_agents/utils/token_usage_helper.py +531 -0
- aip_agents_binary-0.0.0.dist-info/METADATA +825 -0
- aip_agents_binary-0.0.0.dist-info/RECORD +447 -0
- aip_agents_binary-0.0.0.dist-info/WHEEL +5 -0
- aip_agents_binary-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aip-agents-binary
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: A library for managing agents in Gen AI applications.
|
|
5
|
+
Author-email: Raymond Christopher <raymond.christopher@gdplabs.id>
|
|
6
|
+
Requires-Python: <3.13,>=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: a2a-sdk<0.4.0,>=0.3.0
|
|
9
|
+
Requires-Dist: aiostream<0.7.0,>=0.6.0
|
|
10
|
+
Requires-Dist: authlib<2.0.0,>=1.6.4
|
|
11
|
+
Requires-Dist: gl-connectors-sdk<0.2.0,>=0.1.1
|
|
12
|
+
Requires-Dist: gl-observability-binary<0.3.0,>=0.1.2
|
|
13
|
+
Requires-Dist: colorama<0.5.0,>=0.4.6
|
|
14
|
+
Requires-Dist: deprecated<2.0.0,>=1.2.18
|
|
15
|
+
Requires-Dist: fastapi<1.0.0,>=0.124.1
|
|
16
|
+
Requires-Dist: gllm-core-binary<0.5.0,>=0.4.3
|
|
17
|
+
Requires-Dist: gllm-datastore-binary<0.6.0,>=0.5.73
|
|
18
|
+
Requires-Dist: gllm-inference-binary[anthropic,bedrock,google-genai,google-vertexai,openai]<0.7.0,>=0.6.0
|
|
19
|
+
Requires-Dist: gllm-tools<0.3.0,>=0.2.8
|
|
20
|
+
Requires-Dist: langchain<2.0.0,>=1.0.0
|
|
21
|
+
Requires-Dist: langchain-openai<0.4.0,>=0.3.17
|
|
22
|
+
Requires-Dist: langchain-mcp-adapters<0.2.0,>=0.1.0
|
|
23
|
+
Requires-Dist: mcp<2.0.0,>=1.24.0
|
|
24
|
+
Requires-Dist: langchain-experimental<0.5.0,>=0.4.0
|
|
25
|
+
Requires-Dist: langgraph<2.0.0,>=1.0.10
|
|
26
|
+
Requires-Dist: langgraph-checkpoint<5.0.0,>=2.0.0
|
|
27
|
+
Requires-Dist: minio<8.0.0,>=7.2.20
|
|
28
|
+
Requires-Dist: pydantic<3.0.0,>=2.11.7
|
|
29
|
+
Requires-Dist: python-dateutil<3.0.0,>=2.9.0
|
|
30
|
+
Requires-Dist: python-dotenv<2.0.0,>=1.1.0
|
|
31
|
+
Requires-Dist: pybreaker<2.0.0,>=1.4.0
|
|
32
|
+
Requires-Dist: requests<3.0.0,>=2.32.4
|
|
33
|
+
Requires-Dist: tenacity<10.0.0,>=9.1.2
|
|
34
|
+
Requires-Dist: uvicorn<0.50.0,>=0.34.3
|
|
35
|
+
Requires-Dist: watchdog<7.0.0,>=6.0.0
|
|
36
|
+
Provides-Extra: audio
|
|
37
|
+
Requires-Dist: livekit<2.0.0,>=1.0.25; extra == "audio"
|
|
38
|
+
Requires-Dist: livekit-agents<2.0.0,>=1.4.1; extra == "audio"
|
|
39
|
+
Requires-Dist: livekit-plugins-openai<2.0.0,>=1.4.1; extra == "audio"
|
|
40
|
+
Provides-Extra: memory
|
|
41
|
+
Requires-Dist: gllm-memory-binary[mem0ai]<0.2.0,>=0.1.12; extra == "memory"
|
|
42
|
+
Provides-Extra: privacy
|
|
43
|
+
Requires-Dist: gllm-privacy-binary<0.5.0,>=0.4.28; extra == "privacy"
|
|
44
|
+
Provides-Extra: guardrails
|
|
45
|
+
Requires-Dist: gllm-guardrail-binary<0.1.0,>=0.0.1; extra == "guardrails"
|
|
46
|
+
Provides-Extra: google
|
|
47
|
+
Requires-Dist: a2ui-agent-sdk<0.3.0,>=0.2.1; extra == "google"
|
|
48
|
+
Requires-Dist: google-adk<2.0.0,>=1.28.0; extra == "google"
|
|
49
|
+
Provides-Extra: google-adk
|
|
50
|
+
Requires-Dist: google-adk<2.0.0,>=1.28.0; extra == "google-adk"
|
|
51
|
+
Provides-Extra: gl-connector
|
|
52
|
+
Requires-Dist: gl-connectors-sdk<0.2.0,>=0.1.1; extra == "gl-connector"
|
|
53
|
+
Provides-Extra: skills
|
|
54
|
+
Requires-Dist: gl-connectors-tools-binary>=0.0.9; extra == "skills"
|
|
55
|
+
Provides-Extra: local
|
|
56
|
+
Requires-Dist: PyPDF2<4.0.0,>=3.0.0; extra == "local"
|
|
57
|
+
Requires-Dist: unidecode<2.0.0,>=1.3.0; extra == "local"
|
|
58
|
+
Requires-Dist: gllm-docproc-binary[docx,pdf,xlsx]<0.12.0,>=0.10.9; extra == "local"
|
|
59
|
+
Requires-Dist: gl-connectors-sdk<0.2.0,>=0.1.1; extra == "local"
|
|
60
|
+
Provides-Extra: browser-use
|
|
61
|
+
Requires-Dist: browser-use<0.12.0,>=0.11.13; extra == "browser-use"
|
|
62
|
+
Requires-Dist: steel-sdk>=0.16.0; extra == "browser-use"
|
|
63
|
+
Requires-Dist: json-repair<0.47.0,>=0.46.0; extra == "browser-use"
|
|
64
|
+
Provides-Extra: computer-use
|
|
65
|
+
Requires-Dist: gl-computer-use-binary[opensandbox,recording]<0.1.0,>=0.0.1b6; extra == "computer-use"
|
|
66
|
+
Provides-Extra: dev
|
|
67
|
+
Requires-Dist: coverage<8.0.0,>=7.4.4; extra == "dev"
|
|
68
|
+
Requires-Dist: mypy<2.0.0,>=1.15.0; extra == "dev"
|
|
69
|
+
Requires-Dist: nest-asyncio<2.0.0,>=1.6.0; extra == "dev"
|
|
70
|
+
Requires-Dist: pre-commit<4.0.0,>=3.7.0; extra == "dev"
|
|
71
|
+
Requires-Dist: pyrefly<2.0.0,>=1.0.0; extra == "dev"
|
|
72
|
+
Requires-Dist: pytest<9.0.0,>=8.1.1; extra == "dev"
|
|
73
|
+
Requires-Dist: pytest-asyncio<1.0.0,>=0.26.0; extra == "dev"
|
|
74
|
+
Requires-Dist: pytest-cov<6.0.0,>=5.0.0; extra == "dev"
|
|
75
|
+
Requires-Dist: pytest-timeout<3.0.0,>=2.4.0; extra == "dev"
|
|
76
|
+
Requires-Dist: pytest-rerunfailures<15.0,>=14.0; extra == "dev"
|
|
77
|
+
Requires-Dist: pytest-xdist>=3.8.0; extra == "dev"
|
|
78
|
+
Requires-Dist: ruff<0.7.0,>=0.6.7; extra == "dev"
|
|
79
|
+
|
|
80
|
+
# AIP Agents
|
|
81
|
+
|
|
82
|
+
## Description
|
|
83
|
+
|
|
84
|
+
The core agent library for **local execution** in GL AIP (GDP Labs AI Agents Package). `aip-agents` is part of the GL AIP ecosystem:
|
|
85
|
+
|
|
86
|
+
- **`aip-agents`** (this library) — The underlying agent library for local execution
|
|
87
|
+
- **[`ai-agent-platform`](https://github.com/GDP-ADMIN/ai-agent-platform)** — The platform that provides remote server/run capabilities (uses `aip-agents` internally)
|
|
88
|
+
- **[`glaip-sdk`](https://github.com/GDP-ADMIN/glaip-sdk/tree/main/python/glaip-sdk)** — The SDK that end users use to run agents either locally (directly via `aip-agents`) or on the remote server (via `ai-agent-platform`)
|
|
89
|
+
|
|
90
|
+
You can use `aip-agents` directly for local execution, or let `glaip-sdk` manage local vs remote mode for you. See the [GL AIP overview](../glaip-sdk/gitbook/introduction-to-gl-aip.md) for the full architecture.
|
|
91
|
+
|
|
92
|
+
## Installation
|
|
93
|
+
|
|
94
|
+
### Prerequisites
|
|
95
|
+
- Python 3.11 - 3.12 - [Install here](https://www.python.org/downloads/)
|
|
96
|
+
- Pip (if using Pip) - [Install here](https://pip.pypa.io/en/stable/installation/)
|
|
97
|
+
- Poetry 1.8.1+ (if using Poetry) - [Install here](https://python-poetry.org/docs/#installation)
|
|
98
|
+
- Git (if using Git) - [Install here](https://git-scm.com/downloads)
|
|
99
|
+
- For git installation:
|
|
100
|
+
- Access to the [GDP Labs SDK repository](https://github.com/GDP-ADMIN/glaip-sdk)
|
|
101
|
+
|
|
102
|
+
### 1. Installation from the GDP Labs registry
|
|
103
|
+
This package is published to the internal GDP Labs registry. Ensure your pip/Poetry config includes the registry:
|
|
104
|
+
`https://glsdk.gdplabs.id/gen-ai-internal/simple/`.
|
|
105
|
+
|
|
106
|
+
#### Using pip
|
|
107
|
+
```bash
|
|
108
|
+
pip install aip-agents
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Using Poetry
|
|
112
|
+
```bash
|
|
113
|
+
poetry add aip-agents
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 2. Development Installation (Git)
|
|
117
|
+
For development purposes, you can install directly from the Git repository:
|
|
118
|
+
```bash
|
|
119
|
+
poetry add "git+ssh://git@github.com/GDP-ADMIN/glaip-sdk.git#subdirectory=python/aip-agents"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 3. Recommended: install via glaip-sdk for local mode
|
|
123
|
+
If you want local + remote compatibility, install the SDK's local extra instead:
|
|
124
|
+
```bash
|
|
125
|
+
pip install "glaip-sdk[local]"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Optional Extras
|
|
129
|
+
```bash
|
|
130
|
+
pip install "aip-agents[google]"
|
|
131
|
+
pip install "aip-agents[google-adk]"
|
|
132
|
+
pip install "aip-agents[memory]"
|
|
133
|
+
pip install "aip-agents[privacy]"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- `google`: Enable `GoogleADKAgent` plus A2UI support for the umbrella Google install.
|
|
137
|
+
- `google-adk`: Enable `GoogleADKAgent` and Google ADK MCP client integration.
|
|
138
|
+
|
|
139
|
+
## Skills (PR-001 Foundation)
|
|
140
|
+
|
|
141
|
+
The Skills installer relies on GL Connectors `SkillFactory`. To install skills from GitHub,
|
|
142
|
+
install the `skills` extra so `gl-connectors-tools>=0.0.6` is available.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pip install "aip-agents[skills]"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from aip_agents.skills import Skill
|
|
150
|
+
|
|
151
|
+
skill = await Skill.from_github(
|
|
152
|
+
source="https://github.com/anthropics/skills/tree/main/skills/brand-guidelines",
|
|
153
|
+
destination_root=".agents/skills",
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
assert skill.name == "brand-guidelines"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
If you only need to load an already-installed skill, use `Skill.from_path(...)`.
|
|
160
|
+
|
|
161
|
+
Skill staging copies all resource files — both UTF-8 text and binary assets (images,
|
|
162
|
+
PDFs, archives) — into the configured backend via `write` / `write_bytes`. A resource
|
|
163
|
+
manifest is written at `/skills/<skill>/.aip-skill-index.json` with each resource's
|
|
164
|
+
relative path, type classification (instruction/reference/example/script/asset),
|
|
165
|
+
binary flag, and content summary. Noise directories such as `.git`, `.venv`, and
|
|
166
|
+
`node_modules` are excluded.
|
|
167
|
+
|
|
168
|
+
When `SkillsMiddleware` receives multiple GitHub sources (for example, `skills=["...", "..."]`),
|
|
169
|
+
it now attempts every install before failing. If one or more sources fail, middleware raises a
|
|
170
|
+
single `SkillInstallError` that summarizes failed source URLs and underlying errors. This
|
|
171
|
+
compatibility handling targets the upstream `SkillFactory.create_multiple` breaking-change line
|
|
172
|
+
described in `GDP-ADMIN/gl-connectors-sdk` PR `#699` (BatchResult + non-fail-fast behavior).
|
|
173
|
+
|
|
174
|
+
## Integration Facade
|
|
175
|
+
|
|
176
|
+
Cross-package consumers such as `glaip-sdk` should import local-runtime boundary
|
|
177
|
+
contracts from `aip_agents.integration` rather than reaching into deep internal
|
|
178
|
+
modules.
|
|
179
|
+
|
|
180
|
+
Current contract modules:
|
|
181
|
+
|
|
182
|
+
- `aip_agents.integration.agent`
|
|
183
|
+
- `aip_agents.integration.guardrails`
|
|
184
|
+
- `aip_agents.integration.hitl`
|
|
185
|
+
- `aip_agents.integration.ptc`
|
|
186
|
+
- `aip_agents.integration.skills`
|
|
187
|
+
- `aip_agents.integration.storage`
|
|
188
|
+
|
|
189
|
+
The initial public contract version is `v1` via
|
|
190
|
+
`aip_agents.integration.integration_contract_version`.
|
|
191
|
+
|
|
192
|
+
The following deep paths are non-contract surfaces and may change without
|
|
193
|
+
notice even when the facade currently re-exports related behavior:
|
|
194
|
+
|
|
195
|
+
- `aip_agents.agent.hitl.*`
|
|
196
|
+
- `aip_agents.guardrails.engines.*`
|
|
197
|
+
- `aip_agents.guardrails.manager`
|
|
198
|
+
- `aip_agents.guardrails.schemas`
|
|
199
|
+
- `aip_agents.ptc.custom_tools`
|
|
200
|
+
- `aip_agents.ptc.naming`
|
|
201
|
+
- `aip_agents.ptc.tool_def_helpers`
|
|
202
|
+
- `aip_agents.storage.clients.*`
|
|
203
|
+
- `aip_agents.storage.providers.*`
|
|
204
|
+
- `aip_agents.utils.langgraph.tool_output_management`
|
|
205
|
+
|
|
206
|
+
During the additive migration window, existing deep imports may still work, but
|
|
207
|
+
new cross-package integrations should target the facade namespace only.
|
|
208
|
+
|
|
209
|
+
The legacy `aip_agents.agent` runtime import inventory and compatibility risks
|
|
210
|
+
are captured in [`docs/public-agent-api-compatibility.md`](docs/public-agent-api-compatibility.md).
|
|
211
|
+
|
|
212
|
+
## A2UI Support (v0.8 and v0.9 standard catalogs)
|
|
213
|
+
|
|
214
|
+
`aip-agents` can emit and preserve A2UI payloads in the final SSE metadata as `metadata.a2ui_content` when configured with `a2ui` at agent creation.
|
|
215
|
+
|
|
216
|
+
Enablement example:
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
from aip_agents.agent.langgraph_react_agent import LangGraphReactAgent
|
|
220
|
+
|
|
221
|
+
agent = LangGraphReactAgent(
|
|
222
|
+
name="restaurant-finder",
|
|
223
|
+
instruction="Help customer choose a restaurant.",
|
|
224
|
+
config={
|
|
225
|
+
"a2ui": {
|
|
226
|
+
"enabled": True,
|
|
227
|
+
"schema_version": "0.9",
|
|
228
|
+
"allow_user_actions": True,
|
|
229
|
+
"fallback_to_text": True,
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Behavior in this release:
|
|
236
|
+
|
|
237
|
+
- Outbound A2UI payload in the final response is validated and normalized to `A2UIContentMetadata`.
|
|
238
|
+
- On validation fallback, metadata includes `validation.status = "fallback"` and a machine-readable `validation.fallback_reason`.
|
|
239
|
+
- Inbound `userAction` payloads are validated and normalized before routing to downstream action handling.
|
|
240
|
+
- `schema_version` controls catalog selection and defaults to `"0.9"` (`STANDARD_SCHEMA_VERSION`) when omitted; pass `schema_version="0.8"` explicitly to keep the legacy wire shape.
|
|
241
|
+
- Both `"0.8"` and `"0.9"` ship bundled default list/form/confirmation examples (`aip_agents/a2ui/examples/<version>/`) used to enrich the system prompt.
|
|
242
|
+
- Deep semantic renderability checks (root/child-reference validation beyond jsonschema) remain v0.8-only; v0.9 payloads are jsonschema-validated but not yet checked for renderability parity.
|
|
243
|
+
|
|
244
|
+
## Managing Dependencies
|
|
245
|
+
1. Go to the `aip-agents` module root, e.g. `cd python/aip-agents`.
|
|
246
|
+
2. Run `poetry shell` to create a virtual environment.
|
|
247
|
+
3. Run `poetry install` to install the `aip-agents` requirements (Poetry will generate a local lock file for you if needed; the repository ignores it).
|
|
248
|
+
4. Run `poetry update` if you change any dependency versions in `pyproject.toml`.
|
|
249
|
+
|
|
250
|
+
## Contributing
|
|
251
|
+
Please refer to this [Python Style Guide](https://docs.google.com/document/d/1uRggCrHnVfDPBnG641FyQBwUwLoFw0kTzNqRm92vUwM/edit?usp=sharing)
|
|
252
|
+
to get information about code style, documentation standard, and SCA that you need to use when contributing to this project
|
|
253
|
+
|
|
254
|
+
1. From `python/aip-agents`, install hooks with `pre-commit install` (this enables the module `deep-import-scanner` hook to run on every commit)
|
|
255
|
+
2. Run `poetry shell` to create a virtual environment.
|
|
256
|
+
3. Run `poetry install` to install the `aip-agents` requirements (this will also create a local lock file that stays local).
|
|
257
|
+
4. Run `which python` to get the path to be referenced at Visual Studio Code interpreter path (`Ctrl`+`Shift`+`P` or `Cmd`+`Shift`+`P`)
|
|
258
|
+
5. Try running the unit test to see if it's working:
|
|
259
|
+
```bash
|
|
260
|
+
poetry run pytest -s tests/unit_tests/
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Hello World Examples
|
|
264
|
+
|
|
265
|
+
### Prerequisites
|
|
266
|
+
- Python 3.11 - 3.12
|
|
267
|
+
- Install the package:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
pip install aip-agents
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
- Install Google ADK support only if you use Google ADK examples:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
pip install "aip-agents[google-adk]"
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
- For OpenAI: Set your API key in the environment:
|
|
280
|
+
```bash
|
|
281
|
+
export OPENAI_API_KEY=your-openai-key
|
|
282
|
+
```
|
|
283
|
+
- For Google ADK: Set your API key in the environment:
|
|
284
|
+
```bash
|
|
285
|
+
export GOOGLE_API_KEY=your-google-api-key
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Run the Hello World Examples
|
|
289
|
+
|
|
290
|
+
The example scripts are located in `aip_agents/examples` in the source repo. You can run them individually or use the `run_all_examples.py` script.
|
|
291
|
+
|
|
292
|
+
**1. Running Individual Examples:**
|
|
293
|
+
|
|
294
|
+
Navigate to the library's root directory (e.g., `python/aip-agents` if you cloned the repository).
|
|
295
|
+
|
|
296
|
+
**LangGraph (OpenAI):**
|
|
297
|
+
```bash
|
|
298
|
+
python aip_agents/examples/hello_world_langgraph.py
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**LangGraph with GL Connectors (OpenAI):**
|
|
302
|
+
```bash
|
|
303
|
+
python aip_agents/examples/hello_world_langgraph_gl_connector_twitter.py
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**LangGraph Streaming (OpenAI):**
|
|
307
|
+
```bash
|
|
308
|
+
python aip_agents/examples/hello_world_langgraph_stream.py
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**LangGraph Multi-Agent Coordinator (OpenAI):**
|
|
312
|
+
```bash
|
|
313
|
+
python aip_agents/examples/hello_world_a2a_multi_agent_coordinator_server.py
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Google ADK:**
|
|
317
|
+
```bash
|
|
318
|
+
python aip_agents/examples/hello_world_google_adk.py
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Google ADK Streaming:**
|
|
322
|
+
```bash
|
|
323
|
+
python aip_agents/examples/hello_world_google_adk_stream.py
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**LangChain (OpenAI):**
|
|
327
|
+
```bash
|
|
328
|
+
python aip_agents/examples/hello_world_langchain.py
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**LangChain Streaming (OpenAI):**
|
|
332
|
+
```bash
|
|
333
|
+
python aip_agents/examples/hello_world_langchain_stream.py
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**HITL (Human-in-the-Loop) Approval Demo:**
|
|
337
|
+
```bash
|
|
338
|
+
python aip_agents/examples/hitl_demo.py
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**2. Running MCP Examples**
|
|
342
|
+
|
|
343
|
+
### Prerequisites
|
|
344
|
+
|
|
345
|
+
Ensure you have set the environment variables for API keys required by the examples you run:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
export OPENAI_API_KEY="your-openai-key"
|
|
349
|
+
export GOOGLE_API_KEY="your-google-api-key"
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
`GOOGLE_API_KEY` is only required for Google ADK examples.
|
|
353
|
+
|
|
354
|
+
For examples that use stateful MCP tools like browser automation, start the Playwright MCP server in a separate terminal:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
npx @playwright/mcp@latest --headless --port 8931
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Note:** Use the `--headless` flag to run the server without a visible browser window, which is recommended if the browser is not installed yet to avoid failures. For using an actual (non-headless) browser, refer to the [Playwright MCP documentation](https://github.com/microsoft/playwright-mcp).
|
|
361
|
+
|
|
362
|
+
### Local MCP Servers
|
|
363
|
+
|
|
364
|
+
For STDIO, SSE, and HTTP transports using local servers, open a terminal in the library root (`python/aip-agents`) and run:
|
|
365
|
+
|
|
366
|
+
- For STDIO:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
poetry run python aip_agents/examples/mcp_servers/mcp_server_stdio.py
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
- For SSE:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
poetry run python aip_agents/examples/mcp_servers/mcp_server_sse.py
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
- For HTTP:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
poetry run python aip_agents/examples/mcp_servers/mcp_server_http.py
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Note: Start the appropriate server before running the client examples for that transport.
|
|
385
|
+
|
|
386
|
+
### Running Examples
|
|
387
|
+
|
|
388
|
+
All examples are run from the library root using `poetry run python aip_agents/examples/<file>.py`. Examples support OpenAI for LangGraph/LangChain and Google ADK where specified.
|
|
389
|
+
|
|
390
|
+
#### LangChain Examples
|
|
391
|
+
|
|
392
|
+
##### STDIO Transport
|
|
393
|
+
- Non-Streaming:
|
|
394
|
+
```bash
|
|
395
|
+
poetry run python aip_agents/examples/hello_world_langchain_mcp_stdio.py
|
|
396
|
+
```
|
|
397
|
+
- Streaming:
|
|
398
|
+
```bash
|
|
399
|
+
poetry run python aip_agents/examples/hello_world_langchain_mcp_stdio_stream.py
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
##### SSE Transport
|
|
403
|
+
- Non-Streaming:
|
|
404
|
+
```bash
|
|
405
|
+
poetry run python aip_agents/examples/hello_world_langchain_mcp_sse.py
|
|
406
|
+
```
|
|
407
|
+
- Streaming:
|
|
408
|
+
```bash
|
|
409
|
+
poetry run python aip_agents/examples/hello_world_langchain_mcp_sse_stream.py
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
##### HTTP Transport
|
|
413
|
+
- Non-Streaming:
|
|
414
|
+
```bash
|
|
415
|
+
poetry run python aip_agents/examples/hello_world_langchain_mcp_http.py
|
|
416
|
+
```
|
|
417
|
+
- Streaming:
|
|
418
|
+
```bash
|
|
419
|
+
poetry run python aip_agents/examples/hello_world_langchain_mcp_http_stream.py
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### Google ADK Examples
|
|
423
|
+
|
|
424
|
+
##### STDIO Transport
|
|
425
|
+
- Non-Streaming:
|
|
426
|
+
```bash
|
|
427
|
+
poetry run python aip_agents/examples/hello_world_google_adk_mcp_stdio.py
|
|
428
|
+
```
|
|
429
|
+
- Streaming:
|
|
430
|
+
```bash
|
|
431
|
+
poetry run python aip_agents/examples/hello_world_google_adk_mcp_stdio_stream.py
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
##### SSE Transport
|
|
435
|
+
- Non-Streaming:
|
|
436
|
+
```bash
|
|
437
|
+
poetry run python aip_agents/examples/hello_world_google_adk_mcp_sse.py
|
|
438
|
+
```
|
|
439
|
+
- Streaming:
|
|
440
|
+
```bash
|
|
441
|
+
poetry run python aip_agents/examples/hello_world_google_adk_mcp_sse_stream.py
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
##### HTTP Transport
|
|
445
|
+
- Non-Streaming:
|
|
446
|
+
```bash
|
|
447
|
+
poetry run python aip_agents/examples/hello_world_google_adk_mcp_http.py
|
|
448
|
+
```
|
|
449
|
+
- Streaming:
|
|
450
|
+
```bash
|
|
451
|
+
poetry run python aip_agents/examples/hello_world_google_adk_mcp_http_stream.py
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
#### LangGraph Examples (OpenAI)
|
|
455
|
+
|
|
456
|
+
##### STDIO Transport
|
|
457
|
+
- Non-Streaming:
|
|
458
|
+
```bash
|
|
459
|
+
poetry run python aip_agents/examples/hello_world_langgraph_mcp_stdio.py
|
|
460
|
+
```
|
|
461
|
+
- Streaming:
|
|
462
|
+
```bash
|
|
463
|
+
poetry run python aip_agents/examples/hello_world_langgraph_mcp_stdio_stream.py
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
##### SSE Transport
|
|
467
|
+
- Non-Streaming:
|
|
468
|
+
```bash
|
|
469
|
+
poetry run python aip_agents/examples/hello_world_langgraph_mcp_sse.py
|
|
470
|
+
```
|
|
471
|
+
- Streaming:
|
|
472
|
+
```bash
|
|
473
|
+
poetry run python aip_agents/examples/hello_world_langgraph_mcp_sse_stream.py
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
##### HTTP Transport
|
|
477
|
+
- Non-Streaming:
|
|
478
|
+
```bash
|
|
479
|
+
poetry run python aip_agents/examples/hello_world_langgraph_mcp_http.py
|
|
480
|
+
```
|
|
481
|
+
- Streaming:
|
|
482
|
+
```bash
|
|
483
|
+
poetry run python aip_agents/examples/hello_world_langgraph_mcp_http_stream.py
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Multi-Server Example
|
|
487
|
+
|
|
488
|
+
This LangChain example uses multiple MCP servers: Playwright (for browser actions) and a random name generator (SSE transport) with persistent sessions across multiple `arun` calls.
|
|
489
|
+
|
|
490
|
+
1. Start the Playwright server:
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
npx @playwright/mcp@latest --headless --port 8931
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
2. In another terminal, start the Name Generator SSE server:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
poetry run python aip_agents/examples/mcp_servers/mcp_name.py
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
3. Run the multi-server client example:
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
poetry run python aip_agents/examples/hello_world_langchain_mcp_multi_server.py
|
|
506
|
+
```
|
|
507
|
+
**3. Running Individual A2A Examples:**
|
|
508
|
+
|
|
509
|
+
* Navigate to the library's root directory (e.g., `libs/aip-agents` if you cloned the repository).
|
|
510
|
+
* Open a new terminal and navigate to the `aip_agents/examples` directory to run the A2A server.
|
|
511
|
+
|
|
512
|
+
**LangChain Server:**
|
|
513
|
+
```bash
|
|
514
|
+
python hello_world_a2a_langchain_server.py
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
* Open a new terminal and navigate to the `aip_agents/examples` directory to run the A2A client.
|
|
518
|
+
|
|
519
|
+
**LangChain Client:**
|
|
520
|
+
```bash
|
|
521
|
+
python hello_world_a2a_langchain_client.py
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
**LangChain Client Integrated with Agent Workflow:**
|
|
525
|
+
```bash
|
|
526
|
+
python hello_world_a2a_langchain_client_agent.py
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
**LangChain Client Streaming:**
|
|
530
|
+
```bash
|
|
531
|
+
python hello_world_a2a_langchain_client_stream.py
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
## Human-in-the-Loop (HITL) Approval
|
|
536
|
+
|
|
537
|
+
AIP Agents supports Human-in-the-Loop approval for tool execution, allowing human operators to review and approve high-risk tool calls before they execute.
|
|
538
|
+
|
|
539
|
+
### Features
|
|
540
|
+
|
|
541
|
+
- **Configurable Approval Policies**: Set approval requirements per tool with customizable timeouts and behaviors
|
|
542
|
+
- **Interactive CLI Prompts**: Clear, structured prompts showing tool details and context
|
|
543
|
+
- **Structured Logging**: All approval decisions are logged with full metadata
|
|
544
|
+
- **Timeout Handling**: Configurable behavior when approval requests time out
|
|
545
|
+
- **Non-blocking**: Tools without HITL configuration execute normally
|
|
546
|
+
|
|
547
|
+
### Quick Start
|
|
548
|
+
|
|
549
|
+
Configure HITL for specific tools in your agent:
|
|
550
|
+
|
|
551
|
+
```python
|
|
552
|
+
from aip_agents.agent import LangGraphReactAgent
|
|
553
|
+
from aip_agents.agent.hitl.config import ToolApprovalConfig
|
|
554
|
+
|
|
555
|
+
# Create agent with tools
|
|
556
|
+
agent = LangGraphReactAgent(
|
|
557
|
+
name="My Agent",
|
|
558
|
+
tools=[send_email_tool, search_tool],
|
|
559
|
+
)
|
|
560
|
+
|
|
561
|
+
# Configure HITL via tool_configs
|
|
562
|
+
agent.tool_configs = {
|
|
563
|
+
"tool_configs": {
|
|
564
|
+
"send_email": {"hitl": {"timeout_seconds": 300}}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
When the agent attempts to use the `send_email` tool, it will:
|
|
570
|
+
|
|
571
|
+
1. Emit a pending approval event via `DeferredPromptHandler`
|
|
572
|
+
2. Wait for `ApprovalManager.resolve_pending_request()` to be called
|
|
573
|
+
3. Execute the tool only if approved
|
|
574
|
+
4. Log the decision for audit purposes
|
|
575
|
+
|
|
576
|
+
### Configuration Options
|
|
577
|
+
|
|
578
|
+
| Option | Type | Default | Description |
|
|
579
|
+
|--------|------|---------|-------------|
|
|
580
|
+
| `timeout_seconds` | int | 300 | Seconds to wait for operator input |
|
|
581
|
+
|
|
582
|
+
### Logging
|
|
583
|
+
|
|
584
|
+
All HITL decisions are logged with structured data:
|
|
585
|
+
|
|
586
|
+
```json
|
|
587
|
+
{
|
|
588
|
+
"event": "hitl_decision",
|
|
589
|
+
"tool": "send_email",
|
|
590
|
+
"decision": "approved",
|
|
591
|
+
"operator_input": "A",
|
|
592
|
+
"latency_ms": 2500,
|
|
593
|
+
"timestamp": "2025-09-25T10:15:00Z"
|
|
594
|
+
}
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
### Demo
|
|
598
|
+
|
|
599
|
+
Run the interactive demo to see HITL in action:
|
|
600
|
+
|
|
601
|
+
```bash
|
|
602
|
+
python aip_agents/examples/hitl_demo.py
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
## Delegation Timeout Policy
|
|
606
|
+
|
|
607
|
+
When using coordinator agents with delegated sub-agents (`delegate_to_<agent>` tools), timeout behavior follows a dedicated policy:
|
|
608
|
+
|
|
609
|
+
- Source of truth: delegated timeout comes from the delegated agent configuration (`agent.timeout` or `agent.config.timeout_seconds`).
|
|
610
|
+
- Direct `aip-agents` callers may still supply legacy `agent.config.execution_timeout`; delegation treats it as a compatibility fallback after checking `timeout_seconds`.
|
|
611
|
+
- Regular tool timeout overrides (`resilience.timeout_seconds`, `timeout_seconds`, `tool_timeout_seconds`) do not control delegated-agent timeout behavior.
|
|
612
|
+
- Legacy delegation timeout override keys are accepted for compatibility but ignored for effective timeout resolution.
|
|
613
|
+
- Ignored override attempts emit a deterministic warning signal in tool metadata:
|
|
614
|
+
- `metadata.delegation_timeout_warning.code = \"delegation_timeout_override_ignored\"`
|
|
615
|
+
- `metadata.delegation_timeout_warning.ignored_keys` lists ignored keys
|
|
616
|
+
- `metadata.delegation_timeout_warning.effective_timeout_seconds` records delegated effective timeout when available
|
|
617
|
+
|
|
618
|
+
If delegated timeout configuration is missing, invalid, or non-positive, delegation fails before execution with `invalid_timeout_config`.
|
|
619
|
+
|
|
620
|
+
## Architectural Notes
|
|
621
|
+
|
|
622
|
+
### Memory Features
|
|
623
|
+
|
|
624
|
+
The library supports Mem0 as a memory backend for long-term conversation recall. Key features:
|
|
625
|
+
- Automatic persistence of user-agent interactions via `memory_backend="mem0"`.
|
|
626
|
+
- Semantic search for relevant past conversations.
|
|
627
|
+
- New `built_in_mem0_search` tool for explicit recall by time period (e.g., "yesterday", "last week", "July 2025").
|
|
628
|
+
- Date range parsing for natural language time filters using `dateparser`.
|
|
629
|
+
- Conditional auto-augmentation (disabled by default to reduce noise; enable with `memory_auto_augment=True`).
|
|
630
|
+
|
|
631
|
+
#### Mem0 Integration Tests
|
|
632
|
+
|
|
633
|
+
Use the Mem0 integration tests to validate memory persistence, recall, and deletion:
|
|
634
|
+
|
|
635
|
+
```bash
|
|
636
|
+
cd python/aip-agents && poetry run pytest tests/integration_tests/test_mem0_coordinator.py -q
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
## Deep Agents Middleware
|
|
640
|
+
|
|
641
|
+
The Deep Agents Middleware system provides composable components for enhancing agent capabilities with planning, context management, and custom lifecycle hooks.
|
|
642
|
+
|
|
643
|
+
### Quick Start
|
|
644
|
+
|
|
645
|
+
Enable deep agent capabilities with a single parameter:
|
|
646
|
+
|
|
647
|
+
```python
|
|
648
|
+
from aip_agents.agent.langgraph_react_agent import LangGraphReactAgent
|
|
649
|
+
|
|
650
|
+
# Enable planning + filesystem for complex multi-step tasks
|
|
651
|
+
agent = LangGraphReactAgent(
|
|
652
|
+
name="research_agent",
|
|
653
|
+
model="gpt-4",
|
|
654
|
+
planning=True, # Enables TodoListMiddleware for task decomposition
|
|
655
|
+
tools=[search_tool, calculator_tool],
|
|
656
|
+
)
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### Understanding Planning vs Filesystem
|
|
660
|
+
|
|
661
|
+
**Important**: `planning` and `filesystem` are **completely independent** features:
|
|
662
|
+
|
|
663
|
+
- **`planning=True`**
|
|
664
|
+
- Adds `write_todos` tool for task decomposition
|
|
665
|
+
- Stores todos in **in-memory dictionary** (per thread_id)
|
|
666
|
+
- Does NOT use or require filesystem
|
|
667
|
+
- Perfect for breaking down complex tasks into steps
|
|
668
|
+
- Example: "Research quantum computing" → agent creates 5 subtasks
|
|
669
|
+
|
|
670
|
+
- **`filesystem=True`**
|
|
671
|
+
- Adds file operation tools: `ls`, `read_file`, `write_file`, `edit_file`, `grep`
|
|
672
|
+
- Stores data in **pluggable backend** (default: InMemoryBackend)
|
|
673
|
+
- Does NOT interact with planning/todos
|
|
674
|
+
- Perfect for offloading large tool results to prevent context overflow
|
|
675
|
+
- Example: Web search returns 50KB → agent writes to `/research/results.txt`
|
|
676
|
+
|
|
677
|
+
- **Both together** (`planning=True, filesystem=True`)
|
|
678
|
+
- Agent can plan tasks AND manage large data
|
|
679
|
+
- Todos stored separately in memory, files in backend
|
|
680
|
+
- Most powerful combination for complex research/analysis tasks
|
|
681
|
+
|
|
682
|
+
### Planning Only
|
|
683
|
+
|
|
684
|
+
For task decomposition without filesystem:
|
|
685
|
+
|
|
686
|
+
```python
|
|
687
|
+
agent = LangGraphReactAgent(
|
|
688
|
+
name="planner_agent",
|
|
689
|
+
model="gpt-4",
|
|
690
|
+
planning=True,
|
|
691
|
+
tools=[...],
|
|
692
|
+
)
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### Filesystem Only
|
|
696
|
+
|
|
697
|
+
For context offloading without planning:
|
|
698
|
+
|
|
699
|
+
```python
|
|
700
|
+
agent = LangGraphReactAgent(
|
|
701
|
+
name="data_processor",
|
|
702
|
+
model="gpt-4",
|
|
703
|
+
filesystem=True, # Enables FilesystemMiddleware
|
|
704
|
+
tools=[...],
|
|
705
|
+
)
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### Custom Middleware
|
|
709
|
+
|
|
710
|
+
Create domain-specific middleware by implementing the `AgentMiddleware` protocol:
|
|
711
|
+
|
|
712
|
+
```python
|
|
713
|
+
from aip_agents.middleware.base import AgentMiddleware, ModelRequest
|
|
714
|
+
|
|
715
|
+
class CustomMiddleware:
|
|
716
|
+
def __init__(self):
|
|
717
|
+
self.tools = [] # Add custom tools here
|
|
718
|
+
self.system_prompt_additions = "Custom instructions..."
|
|
719
|
+
|
|
720
|
+
def before_model(self, state: dict) -> dict:
|
|
721
|
+
# Hook executed before model invocation
|
|
722
|
+
return {}
|
|
723
|
+
|
|
724
|
+
def modify_model_request(self, request: ModelRequest, state: dict) -> ModelRequest:
|
|
725
|
+
# Modify the model request (add tools, adjust params, etc.)
|
|
726
|
+
return request
|
|
727
|
+
|
|
728
|
+
def after_model(self, state: dict) -> dict:
|
|
729
|
+
# Hook executed after model invocation
|
|
730
|
+
return {}
|
|
731
|
+
|
|
732
|
+
# COMPOSITION (not override): Custom middlewares EXTEND built-in middleware
|
|
733
|
+
agent = LangGraphReactAgent(
|
|
734
|
+
name="custom_agent",
|
|
735
|
+
model="gpt-4",
|
|
736
|
+
planning=True, # Adds TodoListMiddleware
|
|
737
|
+
filesystem=True, # Adds FilesystemMiddleware
|
|
738
|
+
middlewares=[CustomMiddleware()], # EXTENDS (doesn't replace) the above
|
|
739
|
+
tools=[...],
|
|
740
|
+
)
|
|
741
|
+
# Result: Agent has ALL THREE middleware active:
|
|
742
|
+
# 1. TodoListMiddleware (from planning=True)
|
|
743
|
+
# 2. FilesystemMiddleware (from filesystem=True)
|
|
744
|
+
# 3. CustomMiddleware (from middlewares parameter)
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
**Key Points:**
|
|
748
|
+
- ✅ `middlewares` parameter **extends** (never replaces) auto-configured middleware
|
|
749
|
+
- ✅ `planning` and `filesystem` are **independent** - use either, both, or neither
|
|
750
|
+
- ✅ `planning=True` stores todos in **memory** (does NOT require filesystem)
|
|
751
|
+
- ✅ Execution order: built-in middleware (planning, filesystem) → custom middlewares
|
|
752
|
+
- ✅ All hooks from all middleware execute in sequence
|
|
753
|
+
|
|
754
|
+
**Common Combinations:**
|
|
755
|
+
```python
|
|
756
|
+
# Planning only (no filesystem)
|
|
757
|
+
# → Todos stored in memory, no file operations available
|
|
758
|
+
agent = LangGraphReactAgent(planning=True)
|
|
759
|
+
# → [TodoListMiddleware]
|
|
760
|
+
|
|
761
|
+
# Filesystem only (no planning)
|
|
762
|
+
# → File operations available, no todo planning
|
|
763
|
+
agent = LangGraphReactAgent(filesystem=True)
|
|
764
|
+
# → [FilesystemMiddleware]
|
|
765
|
+
|
|
766
|
+
# Both planning and filesystem
|
|
767
|
+
# → Todos in memory + file operations (most powerful combination)
|
|
768
|
+
agent = LangGraphReactAgent(planning=True, filesystem=True)
|
|
769
|
+
# → [TodoListMiddleware, FilesystemMiddleware]
|
|
770
|
+
|
|
771
|
+
# Custom only (no auto-configuration)
|
|
772
|
+
agent = LangGraphReactAgent(middlewares=[CustomMiddleware()])
|
|
773
|
+
# → [CustomMiddleware]
|
|
774
|
+
|
|
775
|
+
# All together (composition)
|
|
776
|
+
agent = LangGraphReactAgent(
|
|
777
|
+
planning=True,
|
|
778
|
+
filesystem=True,
|
|
779
|
+
middlewares=[CustomMiddleware()]
|
|
780
|
+
)
|
|
781
|
+
# → [TodoListMiddleware, FilesystemMiddleware, CustomMiddleware]
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
### Advanced: Custom Storage Backend
|
|
785
|
+
|
|
786
|
+
Provide your own storage backend for filesystem operations:
|
|
787
|
+
|
|
788
|
+
```python
|
|
789
|
+
from aip_agents.middleware.backends.protocol import BackendProtocol
|
|
790
|
+
from aip_agents.middleware.backends.memory import InMemoryBackend
|
|
791
|
+
|
|
792
|
+
# Use custom backend (e.g., PostgreSQL, S3, Redis)
|
|
793
|
+
custom_backend = MyCustomBackend()
|
|
794
|
+
|
|
795
|
+
agent = LangGraphReactAgent(
|
|
796
|
+
name="agent",
|
|
797
|
+
model="gpt-4",
|
|
798
|
+
filesystem=custom_backend, # Pass BackendProtocol instance
|
|
799
|
+
tools=[...],
|
|
800
|
+
)
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
### Benefits
|
|
804
|
+
|
|
805
|
+
- **Context Window Management**: Automatically offload large tool results to files
|
|
806
|
+
- **Task Decomposition**: Break down complex multi-step tasks into trackable todos
|
|
807
|
+
- **Incremental Development**: Add capabilities gradually (filesystem first, then planning)
|
|
808
|
+
- **Zero Breaking Changes**: Existing agents work unchanged (backward compatible)
|
|
809
|
+
- **Extensible**: Compose custom middleware with built-in components
|
|
810
|
+
|
|
811
|
+
For detailed documentation, see `docs/deep_agents_guide.md` (coming soon).
|
|
812
|
+
|
|
813
|
+
### Agent Interface (`AgentInterface`)
|
|
814
|
+
|
|
815
|
+
The `aip_agents.agent.interface.AgentInterface` class defines a standardized contract for all agent implementations within the AIP Agents ecosystem. It ensures that different agent types (e.g., LangGraph-based, Google ADK-based) expose a consistent set of methods for core operations.
|
|
816
|
+
|
|
817
|
+
Key methods defined by `AgentInterface` typically include:
|
|
818
|
+
- `arun()`: For asynchronous execution of the agent that returns a final consolidated response.
|
|
819
|
+
- `arun_stream()`: For asynchronous execution that streams back partial responses or events from the agent.
|
|
820
|
+
|
|
821
|
+
By adhering to this interface, users can interact with various agents in a uniform way, making it easier to switch between or combine different agent technologies.
|
|
822
|
+
|
|
823
|
+
### Inversion of Control (IoC) / Dependency Injection (DI)
|
|
824
|
+
|
|
825
|
+
The agent implementations (e.g., `LangGraphAgent`, `GoogleADKAgent`) utilize Dependency Injection. For instance, `LangGraphAgent` accepts an `agent_executor` (like one created by LangGraph's `create_react_agent`) in its constructor. Similarly, `GoogleADKAgent` accepts a native `adk_native_agent`. This allows the core execution logic to be provided externally, promoting flexibility and decoupling the agent wrapper from the specific instantiation details of its underlying engine.
|