solace-agent-mesh 1.0.8__py3-none-any.whl → 1.1.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.
Potentially problematic release.
This version of solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/agent/adk/adk_llm.txt +182 -42
- solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +171 -0
- solace_agent_mesh/agent/adk/callbacks.py +165 -104
- solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +0 -18
- solace_agent_mesh/agent/adk/models/models_llm.txt +104 -55
- solace_agent_mesh/agent/adk/runner.py +7 -5
- solace_agent_mesh/agent/adk/setup.py +11 -0
- solace_agent_mesh/agent/adk/stream_parser.py +8 -1
- solace_agent_mesh/agent/adk/tool_wrapper.py +10 -3
- solace_agent_mesh/agent/agent_llm.txt +355 -18
- solace_agent_mesh/agent/protocol/event_handlers.py +433 -296
- solace_agent_mesh/agent/protocol/protocol_llm.txt +54 -7
- solace_agent_mesh/agent/sac/app.py +1 -1
- solace_agent_mesh/agent/sac/component.py +212 -517
- solace_agent_mesh/agent/sac/sac_llm.txt +133 -63
- solace_agent_mesh/agent/testing/testing_llm.txt +25 -58
- solace_agent_mesh/agent/tools/peer_agent_tool.py +15 -11
- solace_agent_mesh/agent/tools/tools_llm.txt +234 -69
- solace_agent_mesh/agent/utils/artifact_helpers.py +35 -1
- solace_agent_mesh/agent/utils/utils_llm.txt +90 -105
- solace_agent_mesh/assets/docs/404.html +3 -3
- solace_agent_mesh/assets/docs/assets/js/{3d406171.7d02a73b.js → 3d406171.0b9eeed1.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/6e0db977.39a79ca9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{75384d09.ccd480c4.js → 75384d09.bf78fbdb.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/90dd9cf6.88f385ea.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/f284c35a.fb68323a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/main.a75ecc0d.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/runtime~main.458efb1d.js +1 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/migration-guides/a2a-upgrade-to-0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +105 -0
- solace_agent_mesh/assets/docs/docs/documentation/migration-guides/a2a-upgrade-to-0.3.0/a2a-technical-migration-map/index.html +53 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +8 -8
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +4 -4
- solace_agent_mesh/assets/docs/lunr-index-1756992446316.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/search-doc-1756992446316.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/assets/docs/sitemap.xml +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/add_cmd/web_add_agent_step.py +12 -3
- solace_agent_mesh/cli/commands/add_cmd/web_add_gateway_step.py +10 -14
- solace_agent_mesh/cli/commands/init_cmd/web_init_step.py +2 -15
- solace_agent_mesh/cli/commands/plugin_cmd/catalog_cmd.py +6 -2
- solace_agent_mesh/cli/utils.py +15 -0
- solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-DvlO62me.js → authCallback-BmF2l6vg.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{client-bp6u3qVZ.js → client-D881Dttc.js} +4 -4
- solace_agent_mesh/client/webui/frontend/static/assets/main-C0jZjYa8.js +699 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-CCeG324-.css +1 -0
- solace_agent_mesh/client/webui/frontend/static/auth-callback.html +2 -2
- solace_agent_mesh/client/webui/frontend/static/index.html +3 -3
- solace_agent_mesh/common/a2a/__init__.py +213 -0
- solace_agent_mesh/common/a2a/a2a_llm.txt +182 -0
- solace_agent_mesh/common/a2a/artifact.py +328 -0
- solace_agent_mesh/common/a2a/events.py +183 -0
- solace_agent_mesh/common/a2a/message.py +307 -0
- solace_agent_mesh/common/a2a/protocol.py +513 -0
- solace_agent_mesh/common/a2a/task.py +127 -0
- solace_agent_mesh/common/a2a/translation.py +653 -0
- solace_agent_mesh/common/a2a/types.py +54 -0
- solace_agent_mesh/common/a2a_spec/a2a.json +2576 -0
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +407 -0
- solace_agent_mesh/common/a2a_spec/schemas/agent_progress_update.json +18 -0
- solace_agent_mesh/common/a2a_spec/schemas/artifact_creation_progress.json +31 -0
- solace_agent_mesh/common/a2a_spec/schemas/llm_invocation.json +18 -0
- solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +235 -0
- solace_agent_mesh/common/a2a_spec/schemas/tool_invocation_start.json +26 -0
- solace_agent_mesh/common/a2a_spec/schemas/tool_result.json +25 -0
- solace_agent_mesh/common/agent_registry.py +1 -1
- solace_agent_mesh/common/common_llm.txt +192 -70
- solace_agent_mesh/common/data_parts.py +99 -0
- solace_agent_mesh/common/middleware/middleware_llm.txt +17 -17
- solace_agent_mesh/common/sac/__init__.py +0 -0
- solace_agent_mesh/common/sac/sac_llm.txt +71 -0
- solace_agent_mesh/common/sac/sam_component_base.py +252 -0
- solace_agent_mesh/common/services/providers/providers_llm.txt +51 -84
- solace_agent_mesh/common/services/services_llm.txt +206 -26
- solace_agent_mesh/common/utils/artifact_utils.py +29 -0
- solace_agent_mesh/common/utils/embeds/embeds_llm.txt +176 -80
- solace_agent_mesh/common/utils/utils_llm.txt +323 -42
- solace_agent_mesh/config_portal/backend/common.py +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/{_index-MqsrTd6g.js → _index-Bym6YkMd.js} +74 -24
- solace_agent_mesh/config_portal/frontend/static/client/assets/{components-B7lKcHVY.js → components-Rk0n-9cK.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/{entry.client-CEumGClk.js → entry.client-mvZjNKiz.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/{index-DSo1AH_7.js → index-DzNKzXrc.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-d845808d.js +1 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/{root-C4XmHinv.js → root-BWvk5-gF.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/index.html +3 -3
- solace_agent_mesh/core_a2a/core_a2a_llm.txt +10 -8
- solace_agent_mesh/core_a2a/service.py +20 -44
- solace_agent_mesh/gateway/base/app.py +27 -1
- solace_agent_mesh/gateway/base/base_llm.txt +177 -72
- solace_agent_mesh/gateway/base/component.py +294 -523
- solace_agent_mesh/gateway/gateway_llm.txt +299 -58
- solace_agent_mesh/gateway/http_sse/component.py +156 -183
- solace_agent_mesh/gateway/http_sse/components/components_llm.txt +29 -29
- solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +272 -36
- solace_agent_mesh/gateway/http_sse/main.py +8 -10
- solace_agent_mesh/gateway/http_sse/routers/agents.py +1 -1
- solace_agent_mesh/gateway/http_sse/routers/artifacts.py +18 -4
- solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +231 -5
- solace_agent_mesh/gateway/http_sse/routers/sessions.py +12 -7
- solace_agent_mesh/gateway/http_sse/routers/tasks.py +116 -169
- solace_agent_mesh/gateway/http_sse/services/agent_service.py +1 -1
- solace_agent_mesh/gateway/http_sse/services/services_llm.txt +89 -135
- solace_agent_mesh/gateway/http_sse/services/task_service.py +2 -5
- solace_agent_mesh/solace_agent_mesh_llm.txt +362 -0
- solace_agent_mesh/templates/gateway_component_template.py +149 -98
- {solace_agent_mesh-1.0.8.dist-info → solace_agent_mesh-1.1.0.dist-info}/METADATA +5 -4
- {solace_agent_mesh-1.0.8.dist-info → solace_agent_mesh-1.1.0.dist-info}/RECORD +143 -126
- solace_agent_mesh/assets/docs/assets/js/f284c35a.731836ad.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/main.6dba4a66.js +0 -2
- solace_agent_mesh/assets/docs/assets/js/runtime~main.6415ad00.js +0 -1
- solace_agent_mesh/assets/docs/lunr-index-1756153049706.json +0 -1
- solace_agent_mesh/assets/docs/search-doc-1756153049706.json +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-BCpII1-0.css +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-BucUdn9m.js +0 -673
- solace_agent_mesh/common/a2a_protocol.py +0 -564
- solace_agent_mesh/common/client/__init__.py +0 -4
- solace_agent_mesh/common/client/card_resolver.py +0 -21
- solace_agent_mesh/common/client/client.py +0 -85
- solace_agent_mesh/common/client/client_llm.txt +0 -133
- solace_agent_mesh/common/server/__init__.py +0 -4
- solace_agent_mesh/common/server/server.py +0 -122
- solace_agent_mesh/common/server/server_llm.txt +0 -169
- solace_agent_mesh/common/server/task_manager.py +0 -291
- solace_agent_mesh/common/server/utils.py +0 -28
- solace_agent_mesh/common/types.py +0 -411
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-28271392.js +0 -1
- /solace_agent_mesh/assets/docs/assets/js/{main.6dba4a66.js.LICENSE.txt → main.a75ecc0d.js.LICENSE.txt} +0 -0
- {solace_agent_mesh-1.0.8.dist-info → solace_agent_mesh-1.1.0.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-1.0.8.dist-info → solace_agent_mesh-1.1.0.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.0.8.dist-info → solace_agent_mesh-1.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,44 +1,34 @@
|
|
|
1
|
+
# DEVELOPER GUIDE for the directory: sac
|
|
2
|
+
|
|
1
3
|
## Quick Summary
|
|
2
4
|
The `sac` (Solace AI Connector) directory provides the core implementation for hosting a Google ADK (Agent Development Kit) agent within the Solace AI Connector framework. It acts as a bridge, enabling ADK agents to communicate using the A2A (Agent-to-Agent) protocol over Solace messaging. This allows for the creation of distributed, collaborative agent systems where agents can delegate tasks, share information, and work together to solve complex problems.
|
|
3
5
|
|
|
4
|
-
The main components are `SamAgentApp`, which handles the initial setup and configuration, and `SamAgentComponent`, which hosts the ADK agent instance, manages its lifecycle, and translates between the A2A protocol and the ADK's internal event model.
|
|
5
|
-
|
|
6
6
|
## Files Overview
|
|
7
|
-
- `__init__.py
|
|
8
|
-
- `app.py
|
|
9
|
-
- `component.py
|
|
10
|
-
- `patch_adk.py
|
|
11
|
-
- `task_execution_context.py
|
|
7
|
+
- `__init__.py` - Empty package marker file
|
|
8
|
+
- `app.py` - Custom SAC App class that automatically configures Solace subscriptions and broker settings for A2A communication
|
|
9
|
+
- `component.py` - Main SAC Component that hosts the ADK agent, manages its lifecycle, and handles all A2A protocol messaging
|
|
10
|
+
- `patch_adk.py` - Runtime patches for the Google ADK library to enhance or correct its behavior
|
|
11
|
+
- `task_execution_context.py` - State management class that encapsulates all runtime information for a single, in-flight A2A task
|
|
12
12
|
|
|
13
13
|
## Developer API Reference
|
|
14
14
|
|
|
15
|
-
---
|
|
16
|
-
### __init__.py
|
|
17
|
-
**Purpose:** A standard Python file that makes the `sac` directory a package, allowing its modules to be imported.
|
|
18
|
-
**Import:** This file is not meant to be imported from directly.
|
|
19
|
-
|
|
20
|
-
---
|
|
21
15
|
### app.py
|
|
22
|
-
**Purpose:** Provides a custom SAC
|
|
23
|
-
**Import:** `from
|
|
16
|
+
**Purpose:** Provides a custom SAC App class that simplifies the configuration of an A2A agent
|
|
17
|
+
**Import:** `from solace_agent_mesh.agent.sac.app import SamAgentApp`
|
|
24
18
|
|
|
25
19
|
**Classes:**
|
|
26
|
-
- `SamAgentApp(app_info: Dict[str, Any], **kwargs)` -
|
|
27
|
-
- `app_schema: Dict` -
|
|
20
|
+
- `SamAgentApp(app_info: Dict[str, Any], **kwargs)` - Custom App class for SAM Agent Host with namespace prefixing and automatic subscription generation
|
|
21
|
+
- `app_schema: Dict` - Class attribute defining comprehensive configuration schema for agent host validation
|
|
28
22
|
|
|
29
23
|
**Constants/Variables:**
|
|
30
|
-
- `info: Dict[str, str]` -
|
|
24
|
+
- `info: Dict[str, str]` - Metadata dictionary about the SamAgentApp class for SAC framework discovery
|
|
31
25
|
|
|
32
26
|
**Usage Examples:**
|
|
33
27
|
```python
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
# validates it against the app_schema, and passes the resulting configuration
|
|
37
|
-
# to the SamAgentApp constructor.
|
|
38
|
-
|
|
39
|
-
# --- Example agent-config.yaml ---
|
|
28
|
+
# SamAgentApp is typically instantiated by the SAC framework from YAML config
|
|
29
|
+
# Example agent-config.yaml:
|
|
40
30
|
# app:
|
|
41
|
-
# class_name:
|
|
31
|
+
# class_name: solace_agent_mesh.agent.sac.app.SamAgentApp
|
|
42
32
|
# app_config:
|
|
43
33
|
# namespace: "my-org/production"
|
|
44
34
|
# agent_name: "customer-support-agent"
|
|
@@ -50,56 +40,136 @@ The main components are `SamAgentApp`, which handles the initial setup and confi
|
|
|
50
40
|
# description: "An agent that can answer questions about customer accounts."
|
|
51
41
|
# agent_card_publishing:
|
|
52
42
|
# interval_seconds: 60
|
|
53
|
-
# agent_discovery:
|
|
54
|
-
# enabled: true
|
|
55
|
-
# inter_agent_communication:
|
|
56
|
-
# allow_list: ["*"]
|
|
57
|
-
# request_timeout_seconds: 45
|
|
58
43
|
# session_service:
|
|
59
44
|
# type: "memory"
|
|
60
|
-
# # ... other configuration parameters
|
|
61
45
|
```
|
|
62
46
|
|
|
63
|
-
---
|
|
64
47
|
### component.py
|
|
65
|
-
**Purpose:**
|
|
66
|
-
**Import:** `from
|
|
48
|
+
**Purpose:** Core component that hosts a Google ADK agent and bridges communication to A2A protocol
|
|
49
|
+
**Import:** `from solace_agent_mesh.agent.sac.component import SamAgentComponent`
|
|
67
50
|
|
|
68
51
|
**Classes:**
|
|
69
|
-
- `SamAgentComponent(**kwargs)` -
|
|
70
|
-
- `process_event(
|
|
71
|
-
- `handle_timer_event(
|
|
72
|
-
- `handle_cache_expiry_event(
|
|
73
|
-
- `finalize_task_success(
|
|
74
|
-
- `finalize_task_canceled(
|
|
75
|
-
- `finalize_task_error(
|
|
76
|
-
- `cleanup(
|
|
77
|
-
- `set_agent_specific_state(
|
|
78
|
-
- `get_agent_specific_state(
|
|
79
|
-
- `get_async_loop(
|
|
80
|
-
- `set_agent_system_instruction_string(
|
|
81
|
-
- `set_agent_system_instruction_callback(
|
|
82
|
-
- `get_gateway_id(
|
|
83
|
-
- `submit_a2a_task(
|
|
84
|
-
- `get_agent_context(
|
|
52
|
+
- `SamAgentComponent(**kwargs)` - Solace AI Connector component that hosts a Google ADK agent
|
|
53
|
+
- `process_event(event: Event) -> None` - Main entry point for all SAC framework events
|
|
54
|
+
- `handle_timer_event(timer_data: Dict[str, Any]) -> None` - Handles scheduled timer events for agent card publishing
|
|
55
|
+
- `handle_cache_expiry_event(cache_data: Dict[str, Any]) -> None` - Handles cache expiry events for peer agent timeouts
|
|
56
|
+
- `finalize_task_success(a2a_context: Dict) -> None` - Async method to finalize successful task completion
|
|
57
|
+
- `finalize_task_canceled(a2a_context: Dict) -> None` - Finalizes task as CANCELED
|
|
58
|
+
- `finalize_task_error(exception: Exception, a2a_context: Dict) -> None` - Async method to finalize failed tasks
|
|
59
|
+
- `cleanup() -> None` - Cleans up resources on component shutdown
|
|
60
|
+
- `set_agent_specific_state(key: str, value: Any) -> None` - Sets key-value pair in agent state dictionary
|
|
61
|
+
- `get_agent_specific_state(key: str, default: Optional[Any] = None) -> Any` - Retrieves value from agent state
|
|
62
|
+
- `get_async_loop() -> Optional[asyncio.AbstractEventLoop]` - Returns dedicated asyncio event loop
|
|
63
|
+
- `set_agent_system_instruction_string(instruction_string: str) -> None` - Sets static system prompt injection
|
|
64
|
+
- `set_agent_system_instruction_callback(callback_function: Callable) -> None` - Sets dynamic system prompt callback
|
|
65
|
+
- `get_gateway_id() -> str` - Returns unique identifier for agent host instance
|
|
66
|
+
- `submit_a2a_task(target_agent_name: str, a2a_message: A2AMessage, user_id: str, user_config: Dict[str, Any], sub_task_id: str) -> str` - Submits task to peer agent
|
|
67
|
+
- `get_agent_context() -> Dict[str, Any]` - Returns agent context for middleware interactions
|
|
85
68
|
|
|
86
69
|
**Constants/Variables:**
|
|
87
|
-
- `info: Dict` -
|
|
88
|
-
- `CORRELATION_DATA_PREFIX: str` -
|
|
89
|
-
- `HOST_COMPONENT_VERSION: str` -
|
|
70
|
+
- `info: Dict` - Metadata dictionary for SAC framework
|
|
71
|
+
- `CORRELATION_DATA_PREFIX: str` - Prefix for cache keys when tracking peer requests
|
|
72
|
+
- `HOST_COMPONENT_VERSION: str` - Version string of the host component
|
|
90
73
|
|
|
91
74
|
**Usage Examples:**
|
|
92
75
|
```python
|
|
93
|
-
#
|
|
94
|
-
|
|
95
|
-
# may need access to its state or methods.
|
|
76
|
+
# Custom initialization function example
|
|
77
|
+
from solace_agent_mesh.agent.sac.component import SamAgentComponent
|
|
96
78
|
|
|
97
|
-
# --- In a custom init module (e.g., my_agent_init.py) ---
|
|
98
|
-
import asyncio
|
|
99
|
-
from src.solace_agent_mesh.agent.sac.component import SamAgentComponent
|
|
100
|
-
from src.solace_agent_mesh.common.types import A2AMessage, TextPart
|
|
101
|
-
|
|
102
|
-
# This function would be configured in the agent's YAML config
|
|
103
79
|
def initialize_my_agent(host_component: SamAgentComponent, config: dict):
|
|
104
80
|
"""Custom initialization function for the agent."""
|
|
105
|
-
|
|
81
|
+
# Store database connection in agent state
|
|
82
|
+
db_connection = create_database_connection(config.get('db_url'))
|
|
83
|
+
host_component.set_agent_specific_state('db_connection', db_connection)
|
|
84
|
+
|
|
85
|
+
# Set custom system instruction
|
|
86
|
+
host_component.set_agent_system_instruction_string(
|
|
87
|
+
"You are a specialized customer service agent with access to our database."
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Tool accessing agent state
|
|
91
|
+
def my_custom_tool(host_component: SamAgentComponent, query: str) -> str:
|
|
92
|
+
"""Tool that uses stored database connection."""
|
|
93
|
+
db_connection = host_component.get_agent_specific_state('db_connection')
|
|
94
|
+
if db_connection:
|
|
95
|
+
return db_connection.execute_query(query)
|
|
96
|
+
return "Database not available"
|
|
97
|
+
|
|
98
|
+
# Scheduling async work from synchronous code
|
|
99
|
+
def schedule_background_task(host_component: SamAgentComponent):
|
|
100
|
+
"""Schedule async work on the component's event loop."""
|
|
101
|
+
loop = host_component.get_async_loop()
|
|
102
|
+
if loop:
|
|
103
|
+
asyncio.run_coroutine_threadsafe(my_async_task(), loop)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### patch_adk.py
|
|
107
|
+
**Purpose:** Contains runtime patches for the Google ADK library to enhance behavior
|
|
108
|
+
**Import:** `from solace_agent_mesh.agent.sac.patch_adk import patch_adk`
|
|
109
|
+
|
|
110
|
+
**Functions:**
|
|
111
|
+
- `patch_adk() -> None` - Applies all necessary patches to the ADK library
|
|
112
|
+
|
|
113
|
+
**Usage Examples:**
|
|
114
|
+
```python
|
|
115
|
+
from solace_agent_mesh.agent.sac.patch_adk import patch_adk
|
|
116
|
+
|
|
117
|
+
# Apply patches before using ADK
|
|
118
|
+
patch_adk()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### task_execution_context.py
|
|
122
|
+
**Purpose:** State management class for single, in-flight agent tasks
|
|
123
|
+
**Import:** `from solace_agent_mesh.agent.sac.task_execution_context import TaskExecutionContext`
|
|
124
|
+
|
|
125
|
+
**Classes:**
|
|
126
|
+
- `TaskExecutionContext(task_id: str, a2a_context: Dict[str, Any])` - Encapsulates runtime state for a single agent task
|
|
127
|
+
- `cancel() -> None` - Signals that the task should be cancelled
|
|
128
|
+
- `is_cancelled() -> bool` - Checks if cancellation event has been set
|
|
129
|
+
- `append_to_streaming_buffer(text: str) -> None` - Appends text to streaming buffer
|
|
130
|
+
- `flush_streaming_buffer() -> str` - Returns and clears streaming buffer content
|
|
131
|
+
- `get_streaming_buffer_content() -> str` - Returns buffer content without clearing
|
|
132
|
+
- `append_to_run_based_buffer(text: str) -> None` - Appends text to run-based response buffer
|
|
133
|
+
- `register_peer_sub_task(sub_task_id: str, correlation_data: Dict[str, Any]) -> None` - Adds peer sub-task tracking
|
|
134
|
+
- `claim_sub_task_completion(sub_task_id: str) -> Optional[Dict[str, Any]]` - Atomically retrieves and removes sub-task data
|
|
135
|
+
- `register_parallel_call_sent(invocation_id: str) -> None` - Registers new parallel tool call
|
|
136
|
+
- `handle_peer_timeout(sub_task_id: str, correlation_data: Dict, timeout_sec: int, invocation_id: str) -> bool` - Handles peer timeout
|
|
137
|
+
- `record_parallel_result(result: Dict, invocation_id: str) -> bool` - Records parallel tool call result
|
|
138
|
+
- `clear_parallel_invocation_state(invocation_id: str) -> None` - Removes completed invocation state
|
|
139
|
+
- `register_produced_artifact(filename: str, version: int) -> None` - Tracks newly created artifacts
|
|
140
|
+
- `add_artifact_signal(signal: Dict[str, Any]) -> None` - Adds artifact return signal
|
|
141
|
+
- `get_and_clear_artifact_signals() -> List[Dict[str, Any]]` - Retrieves and clears artifact signals
|
|
142
|
+
- `set_event_loop(loop: asyncio.AbstractEventLoop) -> None` - Stores event loop reference
|
|
143
|
+
- `get_event_loop() -> Optional[asyncio.AbstractEventLoop]` - Retrieves stored event loop
|
|
144
|
+
|
|
145
|
+
**Usage Examples:**
|
|
146
|
+
```python
|
|
147
|
+
from solace_agent_mesh.agent.sac.task_execution_context import TaskExecutionContext
|
|
148
|
+
|
|
149
|
+
# Create task context
|
|
150
|
+
a2a_context = {
|
|
151
|
+
"logical_task_id": "task-123",
|
|
152
|
+
"user_id": "user-456",
|
|
153
|
+
"session_id": "session-789"
|
|
154
|
+
}
|
|
155
|
+
task_context = TaskExecutionContext("task-123", a2a_context)
|
|
156
|
+
|
|
157
|
+
# Use streaming buffer
|
|
158
|
+
task_context.append_to_streaming_buffer("Hello ")
|
|
159
|
+
task_context.append_to_streaming_buffer("world!")
|
|
160
|
+
content = task_context.flush_streaming_buffer() # Returns "Hello world!"
|
|
161
|
+
|
|
162
|
+
# Track peer sub-tasks
|
|
163
|
+
correlation_data = {
|
|
164
|
+
"peer_agent_name": "math-agent",
|
|
165
|
+
"adk_function_call_id": "call-123"
|
|
166
|
+
}
|
|
167
|
+
task_context.register_peer_sub_task("sub-task-456", correlation_data)
|
|
168
|
+
|
|
169
|
+
# Handle completion
|
|
170
|
+
completed_data = task_context.claim_sub_task_completion("sub-task-456")
|
|
171
|
+
if completed_data:
|
|
172
|
+
print(f"Sub-task completed: {completed_data}")
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
# content_hash: 79c043cb89eecb2b6a6f05113ff223c5064861f1a537d8e832ebb2738f5801e8
|
|
@@ -1,90 +1,57 @@
|
|
|
1
1
|
## Quick Summary
|
|
2
|
-
|
|
3
|
-
The `testing` directory provides a suite of utilities designed to facilitate the testing of the A2A (Agent-to-Agent) framework. Its primary function is to offer tools that simplify debugging and validation of agent interactions during test runs, particularly for declarative tests.
|
|
2
|
+
The `testing` directory provides utilities for testing the A2A (Agent-to-Agent) framework, with a focus on debugging tools that help developers understand test failures by providing readable representations of agent event histories.
|
|
4
3
|
|
|
5
4
|
## Files Overview
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
5
|
+
- `__init__.py` - Package initialization file marking the directory as a Python module
|
|
6
|
+
- `debug_utils.py` - Debugging utilities including pretty-printing for A2A event history
|
|
7
|
+
- `testing_llm.txt` - Documentation file (not a code module)
|
|
9
8
|
|
|
10
9
|
## Developer API Reference
|
|
11
10
|
|
|
12
11
|
### debug_utils.py
|
|
13
|
-
|
|
14
|
-
**
|
|
15
|
-
|
|
16
|
-
**Import:** `from agent.testing.debug_utils import pretty_print_event_history`
|
|
12
|
+
**Purpose:** Provides debugging utilities for the declarative test framework, including a pretty-printer for A2A event history
|
|
13
|
+
**Import:** `from solace_agent_mesh.agent.testing.debug_utils import pretty_print_event_history`
|
|
17
14
|
|
|
18
15
|
**Functions:**
|
|
19
|
-
|
|
20
|
-
- `pretty_print_event_history(event_history: List[Dict[str, Any]], max_string_length: int = 200) -> None`
|
|
21
|
-
Formats and prints a list of A2A event payloads to the console in a structured, readable format. It intelligently parses different event types (status updates, final responses, errors) and truncates long strings to keep the output concise. This is invaluable for quickly diagnosing why a test failed by inspecting the sequence of events leading up to the failure.
|
|
16
|
+
- `pretty_print_event_history(event_history: List[Dict[str, Any]], max_string_length: int = 200) -> None` - Formats and prints a list of A2A event payloads for debugging, intelligently parsing different event types and truncating long strings for readability
|
|
22
17
|
|
|
23
18
|
**Usage Examples:**
|
|
24
|
-
|
|
25
19
|
```python
|
|
26
|
-
#
|
|
27
|
-
from agent.testing.debug_utils import pretty_print_event_history
|
|
20
|
+
# Import the debugging utility
|
|
21
|
+
from solace_agent_mesh.agent.testing.debug_utils import pretty_print_event_history
|
|
28
22
|
from typing import List, Dict, Any
|
|
29
23
|
|
|
30
|
-
# Example
|
|
31
|
-
|
|
24
|
+
# Example: Debug a failed test by printing event history
|
|
25
|
+
event_history: List[Dict[str, Any]] = [
|
|
32
26
|
{
|
|
33
27
|
"result": {
|
|
34
28
|
"status": {
|
|
35
29
|
"state": "EXECUTING",
|
|
36
30
|
"message": {
|
|
37
31
|
"parts": [
|
|
38
|
-
{"type": "text", "text": "
|
|
32
|
+
{"type": "text", "text": "Processing your request..."}
|
|
39
33
|
]
|
|
40
|
-
}
|
|
34
|
+
}
|
|
41
35
|
},
|
|
42
|
-
"final": False
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"result": {
|
|
47
|
-
"artifact": {
|
|
48
|
-
"name": "sales_report_q4.pdf",
|
|
49
|
-
"parts": [
|
|
50
|
-
{
|
|
51
|
-
"type": "file",
|
|
52
|
-
"file": {
|
|
53
|
-
"name": "sales_report_q4.pdf",
|
|
54
|
-
"mimeType": "application/pdf",
|
|
55
|
-
"uri": "file://path/to/sales_report_q4.pdf"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
36
|
+
"final": False
|
|
60
37
|
}
|
|
61
38
|
},
|
|
62
39
|
{
|
|
63
40
|
"error": {
|
|
64
|
-
"code": "
|
|
65
|
-
"message": "
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"result": {
|
|
70
|
-
"status": {
|
|
71
|
-
"state": "FAILED",
|
|
72
|
-
"message": {
|
|
73
|
-
"parts": [
|
|
74
|
-
{"type": "text", "text": "I encountered an error and could not complete the task."}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"sessionId": "task-12345",
|
|
41
|
+
"code": "TIMEOUT_ERROR",
|
|
42
|
+
"message": "Request timed out after 30 seconds"
|
|
79
43
|
}
|
|
80
44
|
}
|
|
81
45
|
]
|
|
82
46
|
|
|
83
|
-
#
|
|
84
|
-
|
|
85
|
-
pretty_print_event_history(sample_event_history, max_string_length=100)
|
|
47
|
+
# Print formatted event history for debugging
|
|
48
|
+
pretty_print_event_history(event_history)
|
|
86
49
|
|
|
87
|
-
#
|
|
88
|
-
|
|
50
|
+
# Print with custom string truncation length
|
|
51
|
+
pretty_print_event_history(event_history, max_string_length=100)
|
|
52
|
+
|
|
53
|
+
# Handle empty event history (when test fails before any events)
|
|
89
54
|
pretty_print_event_history([])
|
|
90
|
-
```
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
# content_hash: 890ba89aa47c5be30f5ec9cdbb4a05e9ee3bd022e56a56fcc4feea72aac653e8
|
|
@@ -10,15 +10,15 @@ from google.genai import types as adk_types
|
|
|
10
10
|
from pydantic import BaseModel, Field
|
|
11
11
|
from solace_ai_connector.common.log import log
|
|
12
12
|
|
|
13
|
-
from ...common.types import
|
|
14
|
-
|
|
15
|
-
TextPart,
|
|
16
|
-
FilePart,
|
|
13
|
+
from ...common.a2a.types import ContentPart
|
|
14
|
+
from a2a.types import (
|
|
17
15
|
AgentCard,
|
|
18
16
|
)
|
|
17
|
+
from ...common import a2a
|
|
19
18
|
from ...common.constants import DEFAULT_COMMUNICATION_TIMEOUT
|
|
20
19
|
from ...common.exceptions import MessageSizeExceededError
|
|
21
20
|
|
|
21
|
+
|
|
22
22
|
class ArtifactIdentifier(BaseModel):
|
|
23
23
|
"""Identifies a specific version of an artifact."""
|
|
24
24
|
|
|
@@ -140,7 +140,7 @@ class PeerAgentTool(BaseTool):
|
|
|
140
140
|
|
|
141
141
|
def _prepare_a2a_parts(
|
|
142
142
|
self, args: Dict[str, Any], tool_context: ToolContext
|
|
143
|
-
) -> List[
|
|
143
|
+
) -> List[ContentPart]:
|
|
144
144
|
"""
|
|
145
145
|
Prepares the A2A message parts from tool arguments.
|
|
146
146
|
"""
|
|
@@ -159,7 +159,7 @@ class PeerAgentTool(BaseTool):
|
|
|
159
159
|
f"Now please execute this task that was given to you:\n\n{task_description}"
|
|
160
160
|
)
|
|
161
161
|
|
|
162
|
-
return [
|
|
162
|
+
return [a2a.create_text_part(text=context_message)]
|
|
163
163
|
|
|
164
164
|
async def run_async(
|
|
165
165
|
self, *, args: Dict[str, Any], tool_context: ToolContext
|
|
@@ -231,8 +231,15 @@ class PeerAgentTool(BaseTool):
|
|
|
231
231
|
e,
|
|
232
232
|
)
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
a2a_metadata["sessionBehavior"] = "RUN_BASED"
|
|
235
|
+
a2a_metadata["parentTaskId"] = main_logical_task_id
|
|
236
|
+
a2a_metadata["function_call_id"] = tool_context.function_call_id
|
|
237
|
+
a2a_metadata["agent_name"] = self.target_agent_name
|
|
238
|
+
|
|
239
|
+
a2a_message = a2a.create_user_message(
|
|
240
|
+
parts=a2a_message_parts,
|
|
241
|
+
metadata=a2a_metadata,
|
|
242
|
+
context_id=original_task_context.get("contextId"),
|
|
236
243
|
)
|
|
237
244
|
|
|
238
245
|
correlation_data = {
|
|
@@ -259,12 +266,9 @@ class PeerAgentTool(BaseTool):
|
|
|
259
266
|
self.host_component.submit_a2a_task(
|
|
260
267
|
target_agent_name=self.target_agent_name,
|
|
261
268
|
a2a_message=a2a_message,
|
|
262
|
-
original_session_id=original_session_id,
|
|
263
|
-
main_logical_task_id=main_logical_task_id,
|
|
264
269
|
user_id=user_id,
|
|
265
270
|
user_config=user_config,
|
|
266
271
|
sub_task_id=sub_task_id,
|
|
267
|
-
function_call_id=tool_context.function_call_id,
|
|
268
272
|
)
|
|
269
273
|
except MessageSizeExceededError as e:
|
|
270
274
|
log.error(
|