aip-agents-binary 0.4.8__cp312-cp312-win_amd64.whl → 0.5.4__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aip_agents/__init__.pyi +19 -0
- aip_agents/a2a/__init__.pyi +1 -1
- aip_agents/a2a/server/base_executor.pyi +6 -6
- aip_agents/a2a/server/google_adk_executor.pyi +11 -11
- aip_agents/a2a/server/langflow_executor.pyi +43 -0
- aip_agents/a2a/server/langgraph_executor.pyi +10 -11
- aip_agents/a2a/types.pyi +54 -47
- aip_agents/agent/__init__.pyi +3 -1
- aip_agents/agent/base_agent.pyi +24 -8
- aip_agents/agent/base_langgraph_agent.pyi +67 -25
- aip_agents/agent/google_adk_agent.pyi +34 -21
- aip_agents/agent/google_adk_constants.pyi +3 -0
- aip_agents/agent/hitl/__init__.pyi +6 -0
- aip_agents/agent/hitl/config.pyi +15 -0
- aip_agents/agent/hitl/langgraph_hitl_mixin.pyi +42 -0
- aip_agents/agent/hitl/manager.pyi +199 -0
- aip_agents/agent/hitl/models.pyi +3 -0
- aip_agents/agent/hitl/prompt/__init__.pyi +4 -0
- aip_agents/agent/hitl/prompt/base.pyi +24 -0
- aip_agents/agent/hitl/prompt/deferred.pyi +30 -0
- aip_agents/agent/interface.pyi +5 -5
- aip_agents/agent/interfaces.pyi +44 -0
- aip_agents/agent/langflow_agent.pyi +133 -0
- aip_agents/agent/langgraph_memory_enhancer_agent.pyi +49 -0
- aip_agents/agent/langgraph_react_agent.pyi +50 -57
- aip_agents/agent/system_instruction_context.pyi +13 -0
- aip_agents/clients/__init__.pyi +4 -0
- aip_agents/clients/langflow/__init__.pyi +4 -0
- aip_agents/clients/langflow/client.pyi +140 -0
- aip_agents/clients/langflow/types.pyi +7 -0
- aip_agents/constants.pyi +1 -0
- aip_agents/examples/compare_streaming_client.pyi +48 -0
- aip_agents/examples/compare_streaming_server.pyi +18 -0
- aip_agents/examples/demo_memory_recall.pyi +58 -0
- aip_agents/examples/hello_world_a2a_google_adk_client.pyi +2 -2
- aip_agents/examples/hello_world_a2a_google_adk_client_agent.pyi +2 -2
- aip_agents/examples/hello_world_a2a_google_adk_client_streaming.pyi +2 -2
- aip_agents/examples/hello_world_a2a_google_adk_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langchain_client.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_client_agent.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_client_lm_invoker.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_client_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_reference_client_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langchain_reference_server.pyi +8 -3
- aip_agents/examples/hello_world_a2a_langchain_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langchain_server_lm_invoker.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langflow_client.pyi +9 -0
- aip_agents/examples/hello_world_a2a_langflow_server.pyi +14 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_artifact_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langgraph_client.pyi +2 -2
- aip_agents/examples/hello_world_a2a_langgraph_client_agent.pyi +2 -2
- aip_agents/examples/hello_world_a2a_langgraph_client_agent_lm_invoker.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming.pyi +3 -3
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_lm_invoker.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_tool_streaming.pyi +1 -1
- aip_agents/examples/hello_world_a2a_langgraph_server.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langgraph_server_lm_invoker.pyi +7 -2
- aip_agents/examples/hello_world_a2a_langgraph_server_tool_streaming.pyi +7 -2
- aip_agents/examples/hello_world_a2a_mcp_langgraph.pyi +1 -1
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_client.pyi +31 -6
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_server.pyi +33 -5
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_client.pyi +1 -1
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_server_lm_invoker.pyi +7 -2
- aip_agents/examples/hello_world_langchain_mcp_http_interactive.pyi +16 -0
- aip_agents/examples/hello_world_langchain_mcp_multi_server.pyi +18 -0
- aip_agents/examples/hello_world_langflow_agent.pyi +35 -0
- aip_agents/examples/hello_world_model_switch_cli.pyi +18 -3
- aip_agents/examples/hello_world_pii_logger.pyi +1 -1
- aip_agents/examples/hello_world_sentry.pyi +1 -1
- aip_agents/examples/hello_world_step_limits.pyi +17 -0
- aip_agents/examples/hello_world_stock_a2a_server.pyi +7 -2
- aip_agents/examples/hello_world_tool_output_client.pyi +1 -1
- aip_agents/examples/hello_world_tool_output_server.pyi +7 -2
- aip_agents/examples/hitl_demo.pyi +67 -0
- aip_agents/examples/pii_demo_langgraph_client.pyi +5 -0
- aip_agents/examples/pii_demo_langgraph_server.pyi +20 -0
- aip_agents/examples/pii_demo_multi_agent_client.pyi +5 -0
- aip_agents/examples/pii_demo_multi_agent_server.pyi +40 -0
- aip_agents/examples/todolist_planning_a2a_langchain_client.pyi +5 -0
- aip_agents/examples/todolist_planning_a2a_langgraph_server.pyi +19 -0
- aip_agents/examples/tools/__init__.pyi +3 -1
- aip_agents/examples/tools/adk_weather_tool.pyi +1 -1
- aip_agents/examples/tools/data_visualization_tool.pyi +2 -0
- aip_agents/examples/tools/image_artifact_tool.pyi +2 -0
- aip_agents/examples/tools/langchain_arithmetic_tools.pyi +7 -0
- aip_agents/examples/tools/langchain_currency_exchange_tool.pyi +0 -1
- aip_agents/examples/tools/langchain_graph_artifact_tool.pyi +2 -0
- aip_agents/examples/tools/langchain_weather_tool.pyi +1 -1
- aip_agents/examples/tools/langgraph_streaming_tool.pyi +1 -1
- aip_agents/examples/tools/mock_retrieval_tool.pyi +13 -0
- aip_agents/examples/tools/pii_demo_tools.pyi +54 -0
- aip_agents/examples/tools/random_chart_tool.pyi +20 -0
- aip_agents/examples/tools/stock_tools.pyi +18 -3
- aip_agents/mcp/client/__init__.pyi +4 -3
- aip_agents/mcp/client/base_mcp_client.pyi +148 -0
- aip_agents/mcp/client/connection_manager.pyi +48 -0
- aip_agents/mcp/client/google_adk/__init__.pyi +1 -1
- aip_agents/mcp/client/google_adk/client.pyi +50 -13
- aip_agents/mcp/client/langchain/__init__.pyi +1 -1
- aip_agents/mcp/client/langchain/client.pyi +47 -2
- aip_agents/mcp/client/persistent_session.pyi +113 -0
- aip_agents/mcp/client/session_pool.pyi +101 -0
- aip_agents/mcp/client/transports.pyi +123 -0
- aip_agents/mcp/utils/__init__.pyi +0 -0
- aip_agents/mcp/utils/config_validator.pyi +82 -0
- aip_agents/memory/adapters/__init__.pyi +4 -0
- aip_agents/memory/adapters/base_adapter.pyi +150 -0
- aip_agents/memory/adapters/mem0.pyi +22 -0
- aip_agents/memory/base.pyi +3 -3
- aip_agents/memory/constants.pyi +9 -0
- aip_agents/memory/factory.pyi +1 -1
- aip_agents/memory/guidance.pyi +3 -0
- aip_agents/middleware/__init__.pyi +5 -0
- aip_agents/middleware/base.pyi +71 -0
- aip_agents/middleware/manager.pyi +80 -0
- aip_agents/middleware/todolist.pyi +125 -0
- aip_agents/schema/__init__.pyi +9 -0
- aip_agents/schema/a2a.pyi +40 -0
- aip_agents/schema/agent.pyi +65 -0
- aip_agents/schema/hitl.pyi +89 -0
- aip_agents/schema/langgraph.pyi +28 -0
- aip_agents/schema/model_id.pyi +54 -0
- aip_agents/schema/step_limit.pyi +63 -0
- aip_agents/schema/storage.pyi +21 -0
- aip_agents/sentry/__init__.pyi +1 -1
- aip_agents/sentry/sentry.pyi +2 -2
- aip_agents/storage/base.pyi +1 -2
- aip_agents/storage/config.pyi +9 -46
- aip_agents/storage/providers/base.pyi +2 -3
- aip_agents/storage/providers/object_storage.pyi +1 -1
- aip_agents/tools/__init__.pyi +1 -1
- aip_agents/tools/bosa_tools.pyi +2 -2
- aip_agents/tools/constants.pyi +105 -100
- aip_agents/tools/memory_search/__init__.pyi +5 -0
- aip_agents/tools/memory_search/base.pyi +69 -0
- aip_agents/tools/memory_search/mem0.pyi +19 -0
- aip_agents/tools/memory_search/schema.pyi +15 -0
- aip_agents/tools/memory_search_tool.pyi +3 -0
- aip_agents/types/__init__.pyi +19 -3
- aip_agents/types/a2a_events.pyi +2 -73
- aip_agents/utils/__init__.pyi +7 -2
- aip_agents/utils/a2a_connector.pyi +14 -4
- aip_agents/utils/artifact_helpers.pyi +26 -2
- aip_agents/utils/constants.pyi +10 -0
- aip_agents/utils/datetime/__init__.pyi +4 -0
- aip_agents/utils/datetime/normalization.pyi +95 -0
- aip_agents/utils/datetime/timezone.pyi +48 -0
- aip_agents/utils/env_loader.pyi +2 -2
- aip_agents/utils/event_handler_registry.pyi +23 -0
- aip_agents/utils/final_response_builder.pyi +34 -0
- aip_agents/utils/formatter_llm_client.pyi +71 -0
- aip_agents/utils/langgraph/converter.pyi +1 -1
- aip_agents/utils/langgraph/tool_managers/a2a_tool_manager.pyi +2 -2
- aip_agents/utils/langgraph/tool_managers/base_tool_manager.pyi +2 -3
- aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.pyi +14 -8
- aip_agents/utils/langgraph/tool_output_management.pyi +15 -2
- aip_agents/utils/logger.pyi +60 -0
- aip_agents/utils/metadata/__init__.pyi +5 -0
- aip_agents/utils/metadata/activity_metadata_helper.pyi +25 -0
- aip_agents/utils/metadata/activity_narrative/__init__.pyi +7 -0
- aip_agents/utils/metadata/activity_narrative/builder.pyi +35 -0
- aip_agents/utils/metadata/activity_narrative/constants.pyi +10 -0
- aip_agents/utils/metadata/activity_narrative/context.pyi +32 -0
- aip_agents/utils/metadata/activity_narrative/formatters.pyi +48 -0
- aip_agents/utils/metadata/activity_narrative/utils.pyi +12 -0
- aip_agents/utils/metadata/schemas/__init__.pyi +4 -0
- aip_agents/utils/metadata/schemas/activity_schema.pyi +18 -0
- aip_agents/utils/metadata/schemas/thinking_schema.pyi +20 -0
- aip_agents/utils/metadata/thinking_metadata_helper.pyi +4 -0
- aip_agents/utils/metadata_helper.pyi +50 -34
- aip_agents/utils/name_preprocessor/base_name_preprocessor.pyi +1 -2
- aip_agents/utils/name_preprocessor/google_name_preprocessor.pyi +1 -1
- aip_agents/utils/name_preprocessor/name_preprocessor.pyi +4 -4
- aip_agents/utils/name_preprocessor/openai_name_preprocessor.pyi +1 -1
- aip_agents/utils/pii/__init__.pyi +5 -0
- aip_agents/utils/pii/pii_handler.pyi +86 -0
- aip_agents/utils/pii/pii_helper.pyi +69 -0
- aip_agents/utils/pii/uuid_deanonymizer_mapping.pyi +62 -0
- aip_agents/utils/reference_helper.pyi +38 -6
- aip_agents/utils/sse_chunk_transformer.pyi +166 -0
- aip_agents/utils/step_limit_manager.pyi +112 -0
- aip_agents/utils/token_usage_helper.pyi +1 -1
- aip_agents.cp312-win_amd64.pyd +0 -0
- aip_agents.pyi +92 -34
- aip_agents_binary-0.5.4.dist-info/METADATA +649 -0
- aip_agents_binary-0.5.4.dist-info/RECORD +242 -0
- {aip_agents_binary-0.4.8.dist-info → aip_agents_binary-0.5.4.dist-info}/WHEEL +2 -1
- aip_agents_binary-0.5.4.dist-info/top_level.txt +1 -0
- aip_agents/agent/types.pyi +0 -109
- aip_agents/examples/hello_world_a2a_mem0_coordinator_client.pyi +0 -14
- aip_agents/examples/hello_world_a2a_mem0_coordinator_server.pyi +0 -10
- aip_agents/examples/hello_world_a2a_multi_agent_coordinator_client.pyi +0 -19
- aip_agents/examples/hello_world_a2a_multi_agent_coordinator_client_streaming.pyi +0 -9
- aip_agents/examples/hello_world_a2a_multi_agent_coordinator_server.pyi +0 -12
- aip_agents/examples/hello_world_langgraph_bosa.pyi +0 -5
- aip_agents/examples/hello_world_mem0_coordinator.pyi +0 -5
- aip_agents/examples/tools/pr_details_bosa_tool.pyi +0 -26
- aip_agents/memory/mem0_memory.pyi +0 -94
- aip_agents/tools/base.pyi +0 -44
- aip_agents/tools/base_bosa_tools.pyi +0 -12
- aip_agents/tools/bosa_connector.pyi +0 -30
- aip_agents/tools/bosa_tools_interface.pyi +0 -26
- aip_agents/utils/logger_manager.pyi +0 -151
- aip_agents.build/.gitignore +0 -1
- aip_agents_binary-0.4.8.dist-info/METADATA +0 -280
- aip_agents_binary-0.4.8.dist-info/RECORD +0 -166
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from aip_agents.schema.a2a import A2AEvent
|
|
3
|
+
from collections.abc import AsyncGenerator
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
__all__ = ['SSEChunkTransformer', 'TaskState', 'ChunkStatus', 'ChunkReason', 'ChunkFieldKeys']
|
|
8
|
+
|
|
9
|
+
class TaskState(StrEnum):
|
|
10
|
+
"""Task state values for SSE chunks."""
|
|
11
|
+
WORKING: str
|
|
12
|
+
COMPLETED: str
|
|
13
|
+
FAILED: str
|
|
14
|
+
|
|
15
|
+
class ChunkStatus(StrEnum):
|
|
16
|
+
"""Status values for SSE chunks."""
|
|
17
|
+
SUCCESS: str
|
|
18
|
+
ERROR: str
|
|
19
|
+
|
|
20
|
+
class ChunkReason(StrEnum):
|
|
21
|
+
"""Reason codes for special chunk states."""
|
|
22
|
+
EMPTY_PAYLOAD: str
|
|
23
|
+
|
|
24
|
+
class ChunkFieldKeys(StrEnum):
|
|
25
|
+
"""Field name constants for SSE chunk structure."""
|
|
26
|
+
STATUS: str
|
|
27
|
+
TASK_STATE: str
|
|
28
|
+
CONTENT: str
|
|
29
|
+
EVENT_TYPE: str
|
|
30
|
+
FINAL: str
|
|
31
|
+
METADATA: str
|
|
32
|
+
TIMESTAMP: str
|
|
33
|
+
TASK_ID: str
|
|
34
|
+
CONTEXT_ID: str
|
|
35
|
+
ARTIFACTS: str
|
|
36
|
+
REASON: str
|
|
37
|
+
|
|
38
|
+
class SSEChunkTransformer:
|
|
39
|
+
'''Transforms A2AEvent stream to SSE-compatible output.
|
|
40
|
+
|
|
41
|
+
This class converts events from arun_a2a_stream into the normalized dict format
|
|
42
|
+
matching A2AConnector.astream_to_agent output.
|
|
43
|
+
|
|
44
|
+
Lifecycle:
|
|
45
|
+
Single-stream instance. Must NOT be reused across concurrent streams.
|
|
46
|
+
Each arun_sse_stream call creates a fresh instance.
|
|
47
|
+
|
|
48
|
+
Attributes:
|
|
49
|
+
task_id: Optional task identifier for the stream.
|
|
50
|
+
context_id: Optional context identifier for the stream.
|
|
51
|
+
|
|
52
|
+
Example:
|
|
53
|
+
>>> transformer = SSEChunkTransformer(task_id="task-123")
|
|
54
|
+
>>> async for chunk in transformer.transform_stream(agent.arun_a2a_stream("query")):
|
|
55
|
+
... print(chunk)
|
|
56
|
+
'''
|
|
57
|
+
task_id: Incomplete
|
|
58
|
+
context_id: Incomplete
|
|
59
|
+
def __init__(self, task_id: str | None = None, context_id: str | None = None, pii_mapping: dict[str, str] | None = None) -> None:
|
|
60
|
+
"""Initialize the transformer with optional task and context IDs.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
task_id: Optional task identifier for the stream.
|
|
64
|
+
context_id: Optional context identifier for the stream.
|
|
65
|
+
pii_mapping: Optional PII mapping to inject into each chunk's metadata.
|
|
66
|
+
"""
|
|
67
|
+
@staticmethod
|
|
68
|
+
def normalize_metadata_enums(data: Any) -> Any:
|
|
69
|
+
"""Recursively convert enum keys/values to their string values.
|
|
70
|
+
|
|
71
|
+
This is a pure normalization utility that converts any enum instances
|
|
72
|
+
(MetadataFieldKeys, Kind, Status, etc.) to their .value strings.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
data: Dict, list, or value that may contain enum keys/values.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Normalized data with all enums converted to their .value strings.
|
|
79
|
+
"""
|
|
80
|
+
@staticmethod
|
|
81
|
+
def normalize_event_type_value(event_type: Any) -> str | None:
|
|
82
|
+
"""Convert A2AStreamEventType enum to string.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
event_type: Event type (enum, string, or None).
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
String value of the event type, or None if invalid.
|
|
89
|
+
"""
|
|
90
|
+
@staticmethod
|
|
91
|
+
def create_artifact_hash(artifact: dict[str, Any]) -> str:
|
|
92
|
+
"""Create a stable hash for artifact deduplication.
|
|
93
|
+
|
|
94
|
+
Uses name, content_type, mime_type, and file_data for hashing,
|
|
95
|
+
excluding artifact_id which may be randomly generated.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
artifact: Artifact dict with name, content_type, mime_type, and optionally file_data.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
SHA256 hexdigest hash string for deduplication.
|
|
102
|
+
"""
|
|
103
|
+
@staticmethod
|
|
104
|
+
def extract_tool_outputs(tool_calls: list[dict[str, Any]]) -> list[str]:
|
|
105
|
+
"""Extract human-readable output strings from tool calls.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
tool_calls: List of tool call dictionaries.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
List of human-readable output strings.
|
|
112
|
+
"""
|
|
113
|
+
@staticmethod
|
|
114
|
+
def format_tool_output(output: Any, tool_name: str) -> str:
|
|
115
|
+
"""Format a single tool output for display.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
output: The tool output to format.
|
|
119
|
+
tool_name: The name of the tool.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
The formatted output string.
|
|
123
|
+
"""
|
|
124
|
+
@staticmethod
|
|
125
|
+
def apply_hitl_content_override(content: str | None, event_type_str: str, metadata: dict[str, Any]) -> str | None:
|
|
126
|
+
"""Apply HITL content override when HITL is active and tool results are available.
|
|
127
|
+
|
|
128
|
+
This method overrides the content with human-readable tool output when HITL
|
|
129
|
+
is active, matching A2AConnector behavior.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
content: The original content/status message.
|
|
133
|
+
event_type_str: The type of event being processed (normalized string).
|
|
134
|
+
metadata: The metadata dictionary containing tool_info and hitl flag.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
The original content or human-readable tool output if HITL is active.
|
|
138
|
+
"""
|
|
139
|
+
def transform_event(self, event: A2AEvent) -> dict[str, Any]:
|
|
140
|
+
"""Transform a single A2AEvent to SSE chunk format.
|
|
141
|
+
|
|
142
|
+
Converts the A2AEvent structure to the normalized SSE chunk format,
|
|
143
|
+
relocating fields like tool_info and thinking_and_activity_info into
|
|
144
|
+
metadata, and normalizing enum values to strings.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
event: Single A2AEvent dict from arun_a2a_stream.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
SSEChunk dict with normalized structure.
|
|
151
|
+
"""
|
|
152
|
+
async def transform_stream(self, stream: AsyncGenerator[A2AEvent, None]) -> AsyncGenerator[dict[str, Any], None]:
|
|
153
|
+
"""Transform A2AEvent stream to SSE-compatible chunks.
|
|
154
|
+
|
|
155
|
+
Wraps the input stream and transforms each event, handling artifact
|
|
156
|
+
deduplication and time tracking across the stream.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
stream: Async generator yielding A2AEvent dicts.
|
|
160
|
+
|
|
161
|
+
Yields:
|
|
162
|
+
SSEChunk dicts with normalized structure.
|
|
163
|
+
|
|
164
|
+
Raises:
|
|
165
|
+
Exceptions from underlying stream propagate to caller.
|
|
166
|
+
"""
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from aip_agents.schema.step_limit import MaxDelegationDepthExceededError as MaxDelegationDepthExceededError, MaxStepsExceededError as MaxStepsExceededError, StepLimitConfig as StepLimitConfig, StepLimitErrorResponse as StepLimitErrorResponse, StepLimitErrorType as StepLimitErrorType
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class StepExecutionContext:
|
|
8
|
+
"""Runtime context for tracking step execution and delegation depth.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
current_step: Current step number (0-indexed).
|
|
12
|
+
delegation_depth: Current depth in delegation chain (0 for root agent).
|
|
13
|
+
remaining_step_budget: Steps remaining before limit is hit.
|
|
14
|
+
delegation_chain: List of agent names in the delegation chain.
|
|
15
|
+
"""
|
|
16
|
+
current_step: int = ...
|
|
17
|
+
delegation_depth: int = ...
|
|
18
|
+
remaining_step_budget: int | None = ...
|
|
19
|
+
delegation_chain: list[str] = field(default_factory=list)
|
|
20
|
+
|
|
21
|
+
class StepLimitManager:
|
|
22
|
+
"""Manages step and delegation limit enforcement during agent execution.
|
|
23
|
+
|
|
24
|
+
This manager integrates with LangGraph's existing step mechanisms and adds
|
|
25
|
+
delegation depth tracking and budget propagation.
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
config: Step limit configuration.
|
|
29
|
+
context: Current execution context.
|
|
30
|
+
"""
|
|
31
|
+
config: Incomplete
|
|
32
|
+
context: Incomplete
|
|
33
|
+
def __init__(self, config: StepLimitConfig | None = None, initial_delegation_depth: int = 0, parent_step_budget: int | None = None) -> None:
|
|
34
|
+
"""Initialize step limit manager.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
config: Optional step limit configuration. Uses defaults if None.
|
|
38
|
+
initial_delegation_depth: Starting delegation depth (from parent).
|
|
39
|
+
parent_step_budget: Remaining step budget inherited from parent agent.
|
|
40
|
+
"""
|
|
41
|
+
def check_step_limit(self, agent_name: str = 'agent', count: int = 1) -> None:
|
|
42
|
+
"""Check if taking 'count' steps would exceed limit.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
agent_name: Name of the agent to identify in error message.
|
|
46
|
+
count: Number of steps to check (useful for parallel tool batches).
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
MaxStepsExceededError: If max_steps limit is exceeded.
|
|
50
|
+
"""
|
|
51
|
+
def check_delegation_depth(self, target_agent_name: str) -> None:
|
|
52
|
+
"""Check if delegation to target agent would exceed depth limit.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
target_agent_name: Name of the agent to delegate to.
|
|
56
|
+
|
|
57
|
+
Raises:
|
|
58
|
+
MaxDelegationDepthExceededError: If delegation depth limit exceeded.
|
|
59
|
+
"""
|
|
60
|
+
def increment_step(self, count: int = 1) -> None:
|
|
61
|
+
"""Increment step counter and update remaining budget.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
count: Number of steps to consume (defaults to 1).
|
|
65
|
+
"""
|
|
66
|
+
def get_child_budget(self, child_max_steps: int | None = None) -> int:
|
|
67
|
+
"""Calculate step budget to allocate to child agent.
|
|
68
|
+
|
|
69
|
+
Algorithm:
|
|
70
|
+
1. If remaining_step_budget is None (root with no limit), use config.max_steps - 1
|
|
71
|
+
2. If remaining_step_budget <= 1, return 0 (no budget left for child)
|
|
72
|
+
3. Calculate child_budget = remaining_step_budget - 1 (reserve 1 for parent)
|
|
73
|
+
4. If child has own max_steps config, return min(child_budget, child.max_steps)
|
|
74
|
+
5. Otherwise return child_budget
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
child_max_steps: Optional child agent's own max_steps limit.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Step budget for child agent, accounting for parent's continuation.
|
|
81
|
+
Returns 0 if no budget available for child.
|
|
82
|
+
|
|
83
|
+
Edge Cases:
|
|
84
|
+
- remaining=1: Returns 0 (parent needs the last step)
|
|
85
|
+
- remaining=None: Uses config.max_steps - 1
|
|
86
|
+
- child has own limit: Returns min(calculated_budget, child_limit)
|
|
87
|
+
"""
|
|
88
|
+
def add_to_delegation_chain(self, agent_name: str) -> None:
|
|
89
|
+
"""Add agent to delegation chain for tracking.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
agent_name: Name of the agent being delegated to.
|
|
93
|
+
"""
|
|
94
|
+
@classmethod
|
|
95
|
+
def from_state(cls, state: dict[str, Any], config: StepLimitConfig | None = None) -> StepLimitManager:
|
|
96
|
+
"""Create manager from LangGraph state.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
state: LangGraph agent state containing remaining_steps, etc.
|
|
100
|
+
config: Optional step limit configuration.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
Initialized step limit manager.
|
|
104
|
+
"""
|
|
105
|
+
def set_context(self) -> None:
|
|
106
|
+
"""Set context variables for downstream consumption (e.g. by delegation tools)."""
|
|
107
|
+
def to_state_update(self) -> dict[str, Any]:
|
|
108
|
+
"""Convert current context to LangGraph state update.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Dictionary of state fields to update.
|
|
112
|
+
"""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from langchain_core.messages.ai import AIMessage
|
|
1
|
+
from langchain_core.messages.ai import AIMessage, UsageMetadata
|
|
2
2
|
from langchain_core.messages.tool import ToolMessage as ToolMessage
|
|
3
3
|
from langgraph.types import Command
|
|
4
4
|
from typing import Any
|
aip_agents.cp312-win_amd64.pyd
CHANGED
|
Binary file
|
aip_agents.pyi
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# This file was generated by Nuitka
|
|
2
2
|
|
|
3
3
|
# Stubs included by default
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any
|
|
7
|
+
import importlib
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
__all__: list[str] = []
|
|
11
|
+
def _export(module_name: str) -> None:
|
|
12
|
+
...
|
|
13
|
+
|
|
14
|
+
__version__ = '0.0.0'
|
|
15
|
+
def __getattr__(name: str) -> Any:
|
|
16
|
+
...
|
|
4
17
|
|
|
5
18
|
|
|
6
19
|
__name__ = ...
|
|
@@ -9,13 +22,18 @@ __name__ = ...
|
|
|
9
22
|
|
|
10
23
|
# Modules used internally, to allow implicit dependencies to be seen:
|
|
11
24
|
import os
|
|
25
|
+
import __future__
|
|
26
|
+
import importlib
|
|
27
|
+
import sys
|
|
28
|
+
import typing
|
|
12
29
|
import asyncio
|
|
13
30
|
import time
|
|
14
31
|
import uuid
|
|
15
32
|
import abc
|
|
33
|
+
import collections
|
|
34
|
+
import collections.abc
|
|
16
35
|
import dataclasses
|
|
17
36
|
import datetime
|
|
18
|
-
import typing
|
|
19
37
|
import a2a
|
|
20
38
|
import a2a.server
|
|
21
39
|
import a2a.server.agent_execution
|
|
@@ -28,7 +46,6 @@ import a2a.utils.artifact
|
|
|
28
46
|
import aip_agents.types.A2AEvent
|
|
29
47
|
import aip_agents.types.A2AStreamEventType
|
|
30
48
|
import aip_agents.utils.serialize_references_for_metadata
|
|
31
|
-
import aip_agents.agent.BaseLangGraphAgent
|
|
32
49
|
import base64
|
|
33
50
|
import enum
|
|
34
51
|
import pydantic
|
|
@@ -44,7 +61,6 @@ import gllm_inference
|
|
|
44
61
|
import gllm_inference.builder
|
|
45
62
|
import gllm_inference.lm_invoker
|
|
46
63
|
import gllm_inference.lm_invoker.lm_invoker
|
|
47
|
-
import gllm_inference.schema
|
|
48
64
|
import langchain_core
|
|
49
65
|
import langchain_core.language_models
|
|
50
66
|
import starlette
|
|
@@ -52,9 +68,15 @@ import starlette.applications
|
|
|
52
68
|
import copy
|
|
53
69
|
import hashlib
|
|
54
70
|
import json
|
|
71
|
+
import concurrent
|
|
72
|
+
import concurrent.futures
|
|
73
|
+
import concurrent.futures.Future
|
|
74
|
+
import contextlib
|
|
55
75
|
import contextvars
|
|
76
|
+
import aiostream
|
|
56
77
|
import gllm_core.event
|
|
57
78
|
import gllm_core.event.handler
|
|
79
|
+
import gllm_core.schema
|
|
58
80
|
import langchain_core.messages
|
|
59
81
|
import langchain_core.tools
|
|
60
82
|
import langgraph
|
|
@@ -63,12 +85,12 @@ import langgraph.graph.message
|
|
|
63
85
|
import langgraph.graph.state
|
|
64
86
|
import langgraph.types
|
|
65
87
|
import typing_extensions
|
|
66
|
-
import aip_agents.mcp.client.
|
|
88
|
+
import aip_agents.mcp.client.LangchainMCPClient
|
|
67
89
|
import aip_agents.memory.BaseMemory
|
|
68
90
|
import aip_agents.memory.MemoryFactory
|
|
69
91
|
import aip_agents.memory.MemoryMethod
|
|
70
92
|
import aip_agents.utils.validate_references
|
|
71
|
-
import
|
|
93
|
+
import aip_agents.utils.pii.deanonymize_final_response_content
|
|
72
94
|
import google
|
|
73
95
|
import google.adk
|
|
74
96
|
import google.adk.agents
|
|
@@ -84,37 +106,37 @@ import google.genai
|
|
|
84
106
|
import google.genai.types
|
|
85
107
|
import langchain
|
|
86
108
|
import langchain.tools
|
|
87
|
-
import aip_agents.
|
|
88
|
-
import
|
|
89
|
-
import
|
|
90
|
-
import
|
|
109
|
+
import aip_agents.agent.hitl.prompt.BasePromptHandler
|
|
110
|
+
import aip_agents.agent.hitl.prompt.DeferredPromptHandler
|
|
111
|
+
import langgraph.config
|
|
112
|
+
import aip_agents.utils.datetime.ensure_utc_datetime
|
|
113
|
+
import aip_agents.clients.langflow.LangflowApiClient
|
|
91
114
|
import textwrap
|
|
115
|
+
import functools
|
|
92
116
|
import deprecated
|
|
93
|
-
import gllm_core.schema
|
|
94
117
|
import langchain_core.messages.ai
|
|
95
|
-
import langgraph.config
|
|
96
118
|
import langgraph.managed
|
|
97
119
|
import aip_agents.utils.add_references_chunks
|
|
98
120
|
import aip_agents.utils.langgraph.convert_langchain_messages_to_gllm_messages
|
|
99
121
|
import aip_agents.utils.langgraph.convert_lm_output_to_langchain_message
|
|
122
|
+
import aip_agents.utils.pii.ToolPIIHandler
|
|
123
|
+
import aip_agents.utils.pii.add_pii_mappings
|
|
124
|
+
import aip_agents.utils.datetime.get_timezone_aware_now
|
|
100
125
|
import _frozen_importlib_external
|
|
126
|
+
import langchain_openai
|
|
127
|
+
import aip_agents.agent.LangGraphAgent
|
|
101
128
|
import click
|
|
102
129
|
import uvicorn
|
|
103
|
-
import
|
|
130
|
+
import dotenv
|
|
104
131
|
import aip_agents.agent.LangChainAgent
|
|
105
132
|
import pprint
|
|
106
133
|
import aip_agents.examples.tools.google_serper_tool
|
|
107
|
-
import aip_agents.agent.LangGraphAgent
|
|
108
134
|
import aip_agents.examples.tools.weather_tool_langchain
|
|
109
|
-
import dotenv
|
|
110
|
-
import sys
|
|
111
135
|
import traceback
|
|
112
|
-
import argparse
|
|
113
136
|
import aip_agents.agent.LangGraphReactAgent
|
|
114
|
-
import
|
|
137
|
+
import logging
|
|
115
138
|
import aip_agents.tools.BOSA_AUTOMATED_TOOLS
|
|
116
139
|
import nest_asyncio
|
|
117
|
-
import logging
|
|
118
140
|
import io
|
|
119
141
|
import subprocess
|
|
120
142
|
import threading
|
|
@@ -122,14 +144,20 @@ import fastapi
|
|
|
122
144
|
import fastapi.responses
|
|
123
145
|
import fastapi.staticfiles
|
|
124
146
|
import aip_agents.sentry.setup_telemetry
|
|
147
|
+
import http
|
|
148
|
+
import http.HTTPStatus
|
|
149
|
+
import starlette.requests
|
|
150
|
+
import starlette.responses
|
|
151
|
+
import starlette.routing
|
|
152
|
+
import random
|
|
125
153
|
import mcp
|
|
126
154
|
import mcp.server
|
|
127
155
|
import mcp.server.fastmcp
|
|
128
|
-
import random
|
|
129
156
|
import PIL
|
|
130
157
|
import langchain_core.runnables
|
|
131
158
|
import csv
|
|
132
159
|
import gllm_core.constants
|
|
160
|
+
import gllm_inference.schema
|
|
133
161
|
import langchain.agents
|
|
134
162
|
import langchain.agents.tools
|
|
135
163
|
import langchain_core.agents
|
|
@@ -140,16 +168,21 @@ import gllm_tools.mcp.client
|
|
|
140
168
|
import gllm_tools.mcp.client.client
|
|
141
169
|
import gllm_tools.mcp.client.config
|
|
142
170
|
import gllm_tools.mcp.client.resource
|
|
143
|
-
import gllm_tools.mcp.client.session
|
|
144
|
-
import gllm_tools.mcp.client.tool
|
|
145
171
|
import mcp.types
|
|
146
|
-
import gllm_tools.mcp.client.langchain
|
|
147
|
-
import gllm_tools.mcp.client.langchain.client
|
|
148
|
-
import aip_agents.types.ChatMessage
|
|
149
|
-
import importlib
|
|
150
|
-
import mem0
|
|
151
|
-
import mem0.configs
|
|
152
172
|
import inspect
|
|
173
|
+
import gllm_tools.mcp.client.tool
|
|
174
|
+
import langchain_core.documents
|
|
175
|
+
import langchain_core.documents.base
|
|
176
|
+
import mcp.client
|
|
177
|
+
import mcp.client.sse
|
|
178
|
+
import mcp.client.stdio
|
|
179
|
+
import mcp.client.streamable_http
|
|
180
|
+
import concurrent.futures.ThreadPoolExecutor
|
|
181
|
+
import gllm_inference.schema.message
|
|
182
|
+
import gllm_memory
|
|
183
|
+
import gllm_memory.enums
|
|
184
|
+
import aip_agents.types.ChatMessage
|
|
185
|
+
import aip_agents.utils.datetime.format_created_updated_label
|
|
153
186
|
import bosa_core
|
|
154
187
|
import bosa_core.telemetry
|
|
155
188
|
import bosa_core.telemetry.opentelemetry
|
|
@@ -162,13 +195,38 @@ import urllib3
|
|
|
162
195
|
import urllib3.exceptions
|
|
163
196
|
import pickle
|
|
164
197
|
import bosa_connectors
|
|
165
|
-
import
|
|
166
|
-
import
|
|
167
|
-
import
|
|
198
|
+
import aip_agents.utils.datetime.is_valid_date_string
|
|
199
|
+
import aip_agents.utils.datetime.next_day_iso
|
|
200
|
+
import aip_agents.tools.memory_search.MEMORY_SEARCH_TOOL_NAME
|
|
201
|
+
import aip_agents.tools.memory_search.LongTermMemorySearchInput
|
|
202
|
+
import aip_agents.tools.memory_search.LongTermMemorySearchTool
|
|
203
|
+
import aip_agents.tools.memory_search.Mem0SearchInput
|
|
204
|
+
import aip_agents.tools.memory_search.Mem0SearchTool
|
|
205
|
+
import aip_agents.tools.memory_search.MemoryConfig
|
|
168
206
|
import a2a.client
|
|
207
|
+
import zoneinfo
|
|
208
|
+
import zoneinfo.ZoneInfo
|
|
209
|
+
import zoneinfo.ZoneInfoNotFoundError
|
|
169
210
|
import langchain_core.messages.tool
|
|
170
211
|
import re
|
|
171
|
-
import
|
|
172
|
-
import
|
|
173
|
-
import
|
|
174
|
-
import aip_agents.utils.
|
|
212
|
+
import re.Pattern
|
|
213
|
+
import gllm_core.utils.logger_manager
|
|
214
|
+
import aip_agents.utils.metadata.schemas.Activity
|
|
215
|
+
import aip_agents.utils.metadata.schemas.ActivityDataType
|
|
216
|
+
import aip_agents.utils.metadata.schemas.Thinking
|
|
217
|
+
import aip_agents.utils.metadata.activity_narrative.DELEGATE_PREFIX
|
|
218
|
+
import aip_agents.utils.metadata.activity_narrative.HITL_DECISION_MESSAGES
|
|
219
|
+
import aip_agents.utils.metadata.activity_narrative.HITL_PENDING_DESCRIPTION
|
|
220
|
+
import aip_agents.utils.metadata.activity_narrative.HITL_PENDING_TITLE
|
|
221
|
+
import aip_agents.utils.metadata.activity_narrative.ActivityNarrativeBuilder
|
|
222
|
+
import aip_agents.utils.metadata.activity_narrative._format_tool_or_subagent_name
|
|
223
|
+
import aip_agents.utils.metadata.create_tool_activity_info
|
|
224
|
+
import aip_agents.utils.name_preprocessor.BaseNamePreprocessor
|
|
225
|
+
import gllm_privacy
|
|
226
|
+
import gllm_privacy.pii_detector
|
|
227
|
+
import gllm_privacy.pii_detector.anonymizer
|
|
228
|
+
import gllm_privacy.pii_detector.constants
|
|
229
|
+
import gllm_privacy.pii_detector.recognizer
|
|
230
|
+
import gllm_privacy.pii_detector.recognizer.gdplabs_ner_api_remote_recognizer
|
|
231
|
+
import gllm_privacy.pii_detector.utils
|
|
232
|
+
import gllm_privacy.pii_detector.utils.deanonymizer_mapping
|