agentex-sdk 0.1.0a6__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.
Files changed (289) hide show
  1. agentex/__init__.py +103 -0
  2. agentex/_base_client.py +1992 -0
  3. agentex/_client.py +506 -0
  4. agentex/_compat.py +219 -0
  5. agentex/_constants.py +14 -0
  6. agentex/_exceptions.py +108 -0
  7. agentex/_files.py +123 -0
  8. agentex/_models.py +829 -0
  9. agentex/_qs.py +150 -0
  10. agentex/_resource.py +43 -0
  11. agentex/_response.py +830 -0
  12. agentex/_streaming.py +333 -0
  13. agentex/_types.py +219 -0
  14. agentex/_utils/__init__.py +57 -0
  15. agentex/_utils/_logs.py +25 -0
  16. agentex/_utils/_proxy.py +65 -0
  17. agentex/_utils/_reflection.py +42 -0
  18. agentex/_utils/_resources_proxy.py +24 -0
  19. agentex/_utils/_streams.py +12 -0
  20. agentex/_utils/_sync.py +86 -0
  21. agentex/_utils/_transform.py +447 -0
  22. agentex/_utils/_typing.py +151 -0
  23. agentex/_utils/_utils.py +422 -0
  24. agentex/_version.py +4 -0
  25. agentex/lib/.keep +4 -0
  26. agentex/lib/__init__.py +0 -0
  27. agentex/lib/adk/__init__.py +41 -0
  28. agentex/lib/adk/_modules/__init__.py +0 -0
  29. agentex/lib/adk/_modules/acp.py +247 -0
  30. agentex/lib/adk/_modules/agent_task_tracker.py +176 -0
  31. agentex/lib/adk/_modules/agents.py +77 -0
  32. agentex/lib/adk/_modules/events.py +141 -0
  33. agentex/lib/adk/_modules/messages.py +285 -0
  34. agentex/lib/adk/_modules/state.py +291 -0
  35. agentex/lib/adk/_modules/streaming.py +75 -0
  36. agentex/lib/adk/_modules/tasks.py +124 -0
  37. agentex/lib/adk/_modules/tracing.py +194 -0
  38. agentex/lib/adk/providers/__init__.py +9 -0
  39. agentex/lib/adk/providers/_modules/__init__.py +0 -0
  40. agentex/lib/adk/providers/_modules/litellm.py +232 -0
  41. agentex/lib/adk/providers/_modules/openai.py +416 -0
  42. agentex/lib/adk/providers/_modules/sgp.py +85 -0
  43. agentex/lib/adk/utils/__init__.py +5 -0
  44. agentex/lib/adk/utils/_modules/__init__.py +0 -0
  45. agentex/lib/adk/utils/_modules/templating.py +94 -0
  46. agentex/lib/cli/__init__.py +0 -0
  47. agentex/lib/cli/commands/__init__.py +0 -0
  48. agentex/lib/cli/commands/agents.py +328 -0
  49. agentex/lib/cli/commands/init.py +227 -0
  50. agentex/lib/cli/commands/main.py +33 -0
  51. agentex/lib/cli/commands/secrets.py +169 -0
  52. agentex/lib/cli/commands/tasks.py +118 -0
  53. agentex/lib/cli/commands/uv.py +133 -0
  54. agentex/lib/cli/handlers/__init__.py +0 -0
  55. agentex/lib/cli/handlers/agent_handlers.py +160 -0
  56. agentex/lib/cli/handlers/cleanup_handlers.py +186 -0
  57. agentex/lib/cli/handlers/deploy_handlers.py +351 -0
  58. agentex/lib/cli/handlers/run_handlers.py +452 -0
  59. agentex/lib/cli/handlers/secret_handlers.py +670 -0
  60. agentex/lib/cli/templates/default/.dockerignore.j2 +43 -0
  61. agentex/lib/cli/templates/default/Dockerfile-uv.j2 +42 -0
  62. agentex/lib/cli/templates/default/Dockerfile.j2 +42 -0
  63. agentex/lib/cli/templates/default/README.md.j2 +193 -0
  64. agentex/lib/cli/templates/default/deploy/example.yaml.j2 +55 -0
  65. agentex/lib/cli/templates/default/manifest.yaml.j2 +116 -0
  66. agentex/lib/cli/templates/default/project/acp.py.j2 +29 -0
  67. agentex/lib/cli/templates/default/pyproject.toml.j2 +33 -0
  68. agentex/lib/cli/templates/default/requirements.txt.j2 +5 -0
  69. agentex/lib/cli/templates/deploy/Screenshot 2025-03-19 at 10.36.57/342/200/257AM.png +0 -0
  70. agentex/lib/cli/templates/deploy/example.yaml.j2 +55 -0
  71. agentex/lib/cli/templates/sync/.dockerignore.j2 +43 -0
  72. agentex/lib/cli/templates/sync/Dockerfile-uv.j2 +42 -0
  73. agentex/lib/cli/templates/sync/Dockerfile.j2 +42 -0
  74. agentex/lib/cli/templates/sync/README.md.j2 +293 -0
  75. agentex/lib/cli/templates/sync/deploy/example.yaml.j2 +55 -0
  76. agentex/lib/cli/templates/sync/manifest.yaml.j2 +116 -0
  77. agentex/lib/cli/templates/sync/project/acp.py.j2 +26 -0
  78. agentex/lib/cli/templates/sync/pyproject.toml.j2 +33 -0
  79. agentex/lib/cli/templates/sync/requirements.txt.j2 +5 -0
  80. agentex/lib/cli/templates/temporal/.dockerignore.j2 +43 -0
  81. agentex/lib/cli/templates/temporal/Dockerfile-uv.j2 +48 -0
  82. agentex/lib/cli/templates/temporal/Dockerfile.j2 +48 -0
  83. agentex/lib/cli/templates/temporal/README.md.j2 +316 -0
  84. agentex/lib/cli/templates/temporal/deploy/example.yaml.j2 +55 -0
  85. agentex/lib/cli/templates/temporal/manifest.yaml.j2 +137 -0
  86. agentex/lib/cli/templates/temporal/project/acp.py.j2 +30 -0
  87. agentex/lib/cli/templates/temporal/project/run_worker.py.j2 +33 -0
  88. agentex/lib/cli/templates/temporal/project/workflow.py.j2 +66 -0
  89. agentex/lib/cli/templates/temporal/pyproject.toml.j2 +34 -0
  90. agentex/lib/cli/templates/temporal/requirements.txt.j2 +5 -0
  91. agentex/lib/cli/utils/cli_utils.py +14 -0
  92. agentex/lib/cli/utils/credential_utils.py +103 -0
  93. agentex/lib/cli/utils/exceptions.py +6 -0
  94. agentex/lib/cli/utils/kubectl_utils.py +135 -0
  95. agentex/lib/cli/utils/kubernetes_secrets_utils.py +185 -0
  96. agentex/lib/core/__init__.py +0 -0
  97. agentex/lib/core/adapters/__init__.py +0 -0
  98. agentex/lib/core/adapters/llm/__init__.py +1 -0
  99. agentex/lib/core/adapters/llm/adapter_litellm.py +46 -0
  100. agentex/lib/core/adapters/llm/adapter_sgp.py +55 -0
  101. agentex/lib/core/adapters/llm/port.py +24 -0
  102. agentex/lib/core/adapters/streams/adapter_redis.py +128 -0
  103. agentex/lib/core/adapters/streams/port.py +50 -0
  104. agentex/lib/core/clients/__init__.py +1 -0
  105. agentex/lib/core/clients/temporal/__init__.py +0 -0
  106. agentex/lib/core/clients/temporal/temporal_client.py +181 -0
  107. agentex/lib/core/clients/temporal/types.py +47 -0
  108. agentex/lib/core/clients/temporal/utils.py +56 -0
  109. agentex/lib/core/services/__init__.py +0 -0
  110. agentex/lib/core/services/adk/__init__.py +0 -0
  111. agentex/lib/core/services/adk/acp/__init__.py +0 -0
  112. agentex/lib/core/services/adk/acp/acp.py +210 -0
  113. agentex/lib/core/services/adk/agent_task_tracker.py +85 -0
  114. agentex/lib/core/services/adk/agents.py +43 -0
  115. agentex/lib/core/services/adk/events.py +61 -0
  116. agentex/lib/core/services/adk/messages.py +164 -0
  117. agentex/lib/core/services/adk/providers/__init__.py +0 -0
  118. agentex/lib/core/services/adk/providers/litellm.py +256 -0
  119. agentex/lib/core/services/adk/providers/openai.py +723 -0
  120. agentex/lib/core/services/adk/providers/sgp.py +99 -0
  121. agentex/lib/core/services/adk/state.py +120 -0
  122. agentex/lib/core/services/adk/streaming.py +262 -0
  123. agentex/lib/core/services/adk/tasks.py +69 -0
  124. agentex/lib/core/services/adk/tracing.py +36 -0
  125. agentex/lib/core/services/adk/utils/__init__.py +0 -0
  126. agentex/lib/core/services/adk/utils/templating.py +58 -0
  127. agentex/lib/core/temporal/__init__.py +0 -0
  128. agentex/lib/core/temporal/activities/__init__.py +207 -0
  129. agentex/lib/core/temporal/activities/activity_helpers.py +37 -0
  130. agentex/lib/core/temporal/activities/adk/__init__.py +0 -0
  131. agentex/lib/core/temporal/activities/adk/acp/__init__.py +0 -0
  132. agentex/lib/core/temporal/activities/adk/acp/acp_activities.py +86 -0
  133. agentex/lib/core/temporal/activities/adk/agent_task_tracker_activities.py +76 -0
  134. agentex/lib/core/temporal/activities/adk/agents_activities.py +35 -0
  135. agentex/lib/core/temporal/activities/adk/events_activities.py +50 -0
  136. agentex/lib/core/temporal/activities/adk/messages_activities.py +94 -0
  137. agentex/lib/core/temporal/activities/adk/providers/__init__.py +0 -0
  138. agentex/lib/core/temporal/activities/adk/providers/litellm_activities.py +71 -0
  139. agentex/lib/core/temporal/activities/adk/providers/openai_activities.py +210 -0
  140. agentex/lib/core/temporal/activities/adk/providers/sgp_activities.py +42 -0
  141. agentex/lib/core/temporal/activities/adk/state_activities.py +85 -0
  142. agentex/lib/core/temporal/activities/adk/streaming_activities.py +33 -0
  143. agentex/lib/core/temporal/activities/adk/tasks_activities.py +48 -0
  144. agentex/lib/core/temporal/activities/adk/tracing_activities.py +55 -0
  145. agentex/lib/core/temporal/activities/adk/utils/__init__.py +0 -0
  146. agentex/lib/core/temporal/activities/adk/utils/templating_activities.py +41 -0
  147. agentex/lib/core/temporal/services/__init__.py +0 -0
  148. agentex/lib/core/temporal/services/temporal_task_service.py +69 -0
  149. agentex/lib/core/temporal/types/__init__.py +0 -0
  150. agentex/lib/core/temporal/types/workflow.py +5 -0
  151. agentex/lib/core/temporal/workers/__init__.py +0 -0
  152. agentex/lib/core/temporal/workers/worker.py +162 -0
  153. agentex/lib/core/temporal/workflows/workflow.py +26 -0
  154. agentex/lib/core/tracing/__init__.py +5 -0
  155. agentex/lib/core/tracing/processors/agentex_tracing_processor.py +117 -0
  156. agentex/lib/core/tracing/processors/sgp_tracing_processor.py +119 -0
  157. agentex/lib/core/tracing/processors/tracing_processor_interface.py +40 -0
  158. agentex/lib/core/tracing/trace.py +311 -0
  159. agentex/lib/core/tracing/tracer.py +70 -0
  160. agentex/lib/core/tracing/tracing_processor_manager.py +62 -0
  161. agentex/lib/environment_variables.py +87 -0
  162. agentex/lib/py.typed +0 -0
  163. agentex/lib/sdk/__init__.py +0 -0
  164. agentex/lib/sdk/config/__init__.py +0 -0
  165. agentex/lib/sdk/config/agent_config.py +61 -0
  166. agentex/lib/sdk/config/agent_manifest.py +219 -0
  167. agentex/lib/sdk/config/build_config.py +35 -0
  168. agentex/lib/sdk/config/deployment_config.py +117 -0
  169. agentex/lib/sdk/config/local_development_config.py +56 -0
  170. agentex/lib/sdk/config/project_config.py +103 -0
  171. agentex/lib/sdk/fastacp/__init__.py +3 -0
  172. agentex/lib/sdk/fastacp/base/base_acp_server.py +406 -0
  173. agentex/lib/sdk/fastacp/fastacp.py +74 -0
  174. agentex/lib/sdk/fastacp/impl/agentic_base_acp.py +72 -0
  175. agentex/lib/sdk/fastacp/impl/sync_acp.py +109 -0
  176. agentex/lib/sdk/fastacp/impl/temporal_acp.py +97 -0
  177. agentex/lib/sdk/fastacp/tests/README.md +297 -0
  178. agentex/lib/sdk/fastacp/tests/conftest.py +307 -0
  179. agentex/lib/sdk/fastacp/tests/pytest.ini +10 -0
  180. agentex/lib/sdk/fastacp/tests/run_tests.py +227 -0
  181. agentex/lib/sdk/fastacp/tests/test_base_acp_server.py +450 -0
  182. agentex/lib/sdk/fastacp/tests/test_fastacp_factory.py +344 -0
  183. agentex/lib/sdk/fastacp/tests/test_integration.py +477 -0
  184. agentex/lib/sdk/state_machine/__init__.py +6 -0
  185. agentex/lib/sdk/state_machine/noop_workflow.py +21 -0
  186. agentex/lib/sdk/state_machine/state.py +10 -0
  187. agentex/lib/sdk/state_machine/state_machine.py +189 -0
  188. agentex/lib/sdk/state_machine/state_workflow.py +16 -0
  189. agentex/lib/sdk/utils/__init__.py +0 -0
  190. agentex/lib/sdk/utils/messages.py +223 -0
  191. agentex/lib/types/__init__.py +0 -0
  192. agentex/lib/types/acp.py +94 -0
  193. agentex/lib/types/agent_configs.py +79 -0
  194. agentex/lib/types/agent_results.py +29 -0
  195. agentex/lib/types/credentials.py +34 -0
  196. agentex/lib/types/fastacp.py +61 -0
  197. agentex/lib/types/files.py +13 -0
  198. agentex/lib/types/json_rpc.py +49 -0
  199. agentex/lib/types/llm_messages.py +354 -0
  200. agentex/lib/types/task_message_updates.py +171 -0
  201. agentex/lib/types/tracing.py +34 -0
  202. agentex/lib/utils/__init__.py +0 -0
  203. agentex/lib/utils/completions.py +131 -0
  204. agentex/lib/utils/console.py +14 -0
  205. agentex/lib/utils/io.py +29 -0
  206. agentex/lib/utils/iterables.py +14 -0
  207. agentex/lib/utils/json_schema.py +23 -0
  208. agentex/lib/utils/logging.py +31 -0
  209. agentex/lib/utils/mcp.py +17 -0
  210. agentex/lib/utils/model_utils.py +46 -0
  211. agentex/lib/utils/parsing.py +15 -0
  212. agentex/lib/utils/regex.py +6 -0
  213. agentex/lib/utils/temporal.py +13 -0
  214. agentex/py.typed +0 -0
  215. agentex/resources/__init__.py +103 -0
  216. agentex/resources/agents.py +707 -0
  217. agentex/resources/events.py +294 -0
  218. agentex/resources/messages/__init__.py +33 -0
  219. agentex/resources/messages/batch.py +271 -0
  220. agentex/resources/messages/messages.py +492 -0
  221. agentex/resources/spans.py +557 -0
  222. agentex/resources/states.py +544 -0
  223. agentex/resources/tasks.py +615 -0
  224. agentex/resources/tracker.py +384 -0
  225. agentex/types/__init__.py +56 -0
  226. agentex/types/acp_type.py +7 -0
  227. agentex/types/agent.py +29 -0
  228. agentex/types/agent_list_params.py +13 -0
  229. agentex/types/agent_list_response.py +10 -0
  230. agentex/types/agent_rpc_by_name_params.py +21 -0
  231. agentex/types/agent_rpc_params.py +51 -0
  232. agentex/types/agent_rpc_params1.py +21 -0
  233. agentex/types/agent_rpc_response.py +20 -0
  234. agentex/types/agent_rpc_result.py +90 -0
  235. agentex/types/agent_task_tracker.py +34 -0
  236. agentex/types/data_content.py +30 -0
  237. agentex/types/data_content_param.py +31 -0
  238. agentex/types/data_delta.py +14 -0
  239. agentex/types/event.py +29 -0
  240. agentex/types/event_list_params.py +22 -0
  241. agentex/types/event_list_response.py +10 -0
  242. agentex/types/message_author.py +7 -0
  243. agentex/types/message_create_params.py +18 -0
  244. agentex/types/message_list_params.py +14 -0
  245. agentex/types/message_list_response.py +10 -0
  246. agentex/types/message_style.py +7 -0
  247. agentex/types/message_update_params.py +18 -0
  248. agentex/types/messages/__init__.py +8 -0
  249. agentex/types/messages/batch_create_params.py +16 -0
  250. agentex/types/messages/batch_create_response.py +10 -0
  251. agentex/types/messages/batch_update_params.py +16 -0
  252. agentex/types/messages/batch_update_response.py +10 -0
  253. agentex/types/shared/__init__.py +3 -0
  254. agentex/types/shared/task_message_update.py +83 -0
  255. agentex/types/span.py +36 -0
  256. agentex/types/span_create_params.py +40 -0
  257. agentex/types/span_list_params.py +12 -0
  258. agentex/types/span_list_response.py +10 -0
  259. agentex/types/span_update_params.py +37 -0
  260. agentex/types/state.py +25 -0
  261. agentex/types/state_create_params.py +16 -0
  262. agentex/types/state_list_params.py +16 -0
  263. agentex/types/state_list_response.py +10 -0
  264. agentex/types/state_update_params.py +16 -0
  265. agentex/types/task.py +23 -0
  266. agentex/types/task_delete_by_name_response.py +8 -0
  267. agentex/types/task_delete_response.py +8 -0
  268. agentex/types/task_list_response.py +10 -0
  269. agentex/types/task_message.py +33 -0
  270. agentex/types/task_message_content.py +16 -0
  271. agentex/types/task_message_content_param.py +17 -0
  272. agentex/types/task_message_delta.py +16 -0
  273. agentex/types/text_content.py +53 -0
  274. agentex/types/text_content_param.py +54 -0
  275. agentex/types/text_delta.py +14 -0
  276. agentex/types/tool_request_content.py +36 -0
  277. agentex/types/tool_request_content_param.py +37 -0
  278. agentex/types/tool_request_delta.py +18 -0
  279. agentex/types/tool_response_content.py +36 -0
  280. agentex/types/tool_response_content_param.py +36 -0
  281. agentex/types/tool_response_delta.py +18 -0
  282. agentex/types/tracker_list_params.py +16 -0
  283. agentex/types/tracker_list_response.py +10 -0
  284. agentex/types/tracker_update_params.py +19 -0
  285. agentex_sdk-0.1.0a6.dist-info/METADATA +426 -0
  286. agentex_sdk-0.1.0a6.dist-info/RECORD +289 -0
  287. agentex_sdk-0.1.0a6.dist-info/WHEEL +4 -0
  288. agentex_sdk-0.1.0a6.dist-info/entry_points.txt +2 -0
  289. agentex_sdk-0.1.0a6.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,42 @@
1
+ # syntax=docker/dockerfile:1.3
2
+ FROM python:3.12-slim
3
+ COPY --from=ghcr.io/astral-sh/uv:0.6.4 /uv /uvx /bin/
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ htop \
8
+ vim \
9
+ curl \
10
+ tar \
11
+ python3-dev \
12
+ postgresql-client \
13
+ build-essential \
14
+ libpq-dev \
15
+ gcc \
16
+ cmake \
17
+ netcat-openbsd \
18
+ && apt-get clean \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ RUN uv pip install --system --upgrade pip setuptools wheel
22
+
23
+ ENV UV_HTTP_TIMEOUT=1000
24
+
25
+ # Copy just the pyproject.toml file to optimize caching
26
+ COPY {{ project_path_from_build_root }}/pyproject.toml /app/{{ project_path_from_build_root }}/pyproject.toml
27
+
28
+ WORKDIR /app/{{ project_path_from_build_root }}
29
+
30
+ # Install the required Python packages using uv
31
+ RUN uv pip install --system .
32
+
33
+ # Copy the project code
34
+ COPY {{ project_path_from_build_root }}/project /app/{{ project_path_from_build_root }}/project
35
+
36
+ WORKDIR /app/{{ project_path_from_build_root }}/project
37
+
38
+ # Set environment variables
39
+ ENV PYTHONPATH=/app
40
+
41
+ # Run the agent using uvicorn
42
+ CMD ["uvicorn", "acp:acp", "--host", "0.0.0.0", "--port", "8000"]
@@ -0,0 +1,42 @@
1
+ # syntax=docker/dockerfile:1.3
2
+ FROM python:3.12-slim
3
+ COPY --from=ghcr.io/astral-sh/uv:0.6.4 /uv /uvx /bin/
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ htop \
8
+ vim \
9
+ curl \
10
+ tar \
11
+ python3-dev \
12
+ postgresql-client \
13
+ build-essential \
14
+ libpq-dev \
15
+ gcc \
16
+ cmake \
17
+ netcat-openbsd \
18
+ && apt-get clean \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ RUN uv pip install --system --upgrade pip setuptools wheel
22
+
23
+ ENV UV_HTTP_TIMEOUT=1000
24
+
25
+ # Copy just the requirements file to optimize caching
26
+ COPY {{ project_path_from_build_root }}/requirements.txt /app/{{ project_path_from_build_root }}/requirements.txt
27
+
28
+ WORKDIR /app/{{ project_path_from_build_root }}
29
+
30
+ # Install the required Python packages
31
+ RUN uv pip install --system -r requirements.txt
32
+
33
+ # Copy the project code
34
+ COPY {{ project_path_from_build_root }}/project /app/{{ project_path_from_build_root }}/project
35
+
36
+ WORKDIR /app/{{ project_path_from_build_root }}/project
37
+
38
+ # Set environment variables
39
+ ENV PYTHONPATH=/app
40
+
41
+ # Run the agent using uvicorn
42
+ CMD ["uvicorn", "acp:acp", "--host", "0.0.0.0", "--port", "8000"]
@@ -0,0 +1,293 @@
1
+ # {{ agent_name }} - AgentEx Sync ACP Template
2
+
3
+ This is a starter template for building synchronous agents with the AgentEx framework. It provides a basic implementation of the Agent 2 Client Protocol (ACP) with immediate response capabilities to help you get started quickly.
4
+
5
+ ## What You'll Learn
6
+
7
+ - **Tasks**: A task is a grouping mechanism for related messages. Think of it as a conversation thread or a session.
8
+ - **Messages**: Messages are communication objects within a task. They can contain text, data, or instructions.
9
+ - **Sync ACP**: Synchronous Agent Communication Protocol that requires immediate responses
10
+ - **Message Handling**: How to process and respond to messages in real-time
11
+
12
+ ## Running the Agent
13
+
14
+ 1. Run the agent locally:
15
+ ```bash
16
+ agentex agents run --manifest manifest.yaml
17
+ ```
18
+
19
+ The agent will start on port 8000 and respond immediately to any messages it receives.
20
+
21
+ ## What's Inside
22
+
23
+ This template:
24
+ - Sets up a basic sync ACP server
25
+ - Handles incoming messages with immediate responses
26
+ - Provides a foundation for building real-time agents
27
+ - Can include streaming support for long responses
28
+
29
+ ## Next Steps
30
+
31
+ For more advanced agent development, check out the AgentEx tutorials:
32
+
33
+ - **Tutorials 00-08**: Learn about building synchronous agents with ACP
34
+ - **Tutorials 09-10**: Learn how to use Temporal to power asynchronous agents
35
+ - Tutorial 09: Basic Temporal workflow setup
36
+ - Tutorial 10: Advanced Temporal patterns and best practices
37
+
38
+ These tutorials will help you understand:
39
+ - How to handle long-running tasks
40
+ - Implementing state machines
41
+ - Managing complex workflows
42
+ - Best practices for async agent development
43
+
44
+ ## The Manifest File
45
+
46
+ The `manifest.yaml` file is your agent's configuration file. It defines:
47
+ - How your agent should be built and packaged
48
+ - What files are included in your agent's Docker image
49
+ - Your agent's name and description
50
+ - Local development settings (like the port your agent runs on)
51
+
52
+ This file is essential for both local development and deployment of your agent.
53
+
54
+ ## Project Structure
55
+
56
+ ```
57
+ {{ project_name }}/
58
+ ├── project/ # Your agent's code
59
+ │ ├── __init__.py
60
+ │ └── acp.py # ACP server and event handlers
61
+ ├── Dockerfile # Container definition
62
+ ├── manifest.yaml # Deployment config
63
+ {% if use_uv %}
64
+ └── pyproject.toml # Dependencies (uv)
65
+ {% else %}
66
+ └── requirements.txt # Dependencies (pip)
67
+ {% endif %}
68
+ ```
69
+
70
+ ## Development
71
+
72
+ ### 1. Customize Message Handlers
73
+ - Modify the handlers in `acp.py` to implement your agent's logic
74
+ - Add your own tools and capabilities
75
+ - Implement custom response generation
76
+
77
+ ### 2. Manage Dependencies
78
+
79
+ {% if use_uv %}
80
+ You chose **uv** for package management. Here's how to work with dependencies:
81
+
82
+ ```bash
83
+ # Add new dependencies
84
+ agentex uv add requests openai anthropic
85
+
86
+ # Install/sync dependencies
87
+ agentex uv sync
88
+
89
+ # Run commands with uv
90
+ uv run agentex agents run --manifest manifest.yaml
91
+ ```
92
+
93
+ **Benefits of uv:**
94
+ - Faster dependency resolution and installation
95
+ - Better dependency isolation
96
+ - Modern Python packaging standards
97
+
98
+ {% else %}
99
+ You chose **pip** for package management. Here's how to work with dependencies:
100
+
101
+ ```bash
102
+ # Edit requirements.txt manually to add dependencies
103
+ echo "requests" >> requirements.txt
104
+ echo "openai" >> requirements.txt
105
+
106
+ # Install dependencies
107
+ pip install -r requirements.txt
108
+ ```
109
+
110
+ **Benefits of pip:**
111
+ - Familiar workflow for most Python developers
112
+ - Simple requirements.txt management
113
+ - Wide compatibility
114
+ {% endif %}
115
+
116
+ ### 3. Configure Credentials
117
+ Options:
118
+ 1. Add any required credentials to your manifest.yaml via the `env` section
119
+ 2. Export them in your shell: `export OPENAI_API_KEY=...`
120
+ 3. For local development, create a `.env.local` file in the project directory
121
+
122
+ ## Local Development
123
+
124
+ ### 1. Start the Agentex Backend
125
+ ```bash
126
+ # Navigate to the backend directory
127
+ cd agentex
128
+
129
+ # Start all services using Docker Compose
130
+ make dev
131
+
132
+ # Optional: In a separate terminal, use lazydocker for a better UI (everything should say "healthy")
133
+ lzd
134
+ ```
135
+
136
+ ### 3. Run Your Agent
137
+ ```bash
138
+ # From this directory
139
+ export ENVIRONMENT=development && agentex agents run --manifest manifest.yaml
140
+ ```
141
+
142
+ ### 4. Interact with Your Agent
143
+
144
+ **Option 1: Web UI (Recommended)**
145
+ ```bash
146
+ # Start the local web interface
147
+ cd agentex-web
148
+ make dev
149
+
150
+ # Then open http://localhost:3000 in your browser to chat with your agent
151
+ ```
152
+
153
+ **Option 2: CLI (Deprecated)**
154
+ ```bash
155
+ # Submit a task via CLI
156
+ agentex tasks submit --agent {{ agent_name }} --task "Your task here"
157
+ ```
158
+
159
+ ## Development Tips
160
+
161
+ ### Environment Variables
162
+ - Set environment variables in project/.env for any required credentials
163
+ - Or configure them in the manifest.yaml under the `env` section
164
+ - The `.env` file is automatically loaded in development mode
165
+
166
+ ### Local Testing
167
+ - Use `export ENVIRONMENT=development` before running your agent
168
+ - This enables local service discovery and debugging features
169
+ - Your agent will automatically connect to locally running services
170
+
171
+ ### Sync ACP Considerations
172
+ - Responses must be immediate (no long-running operations)
173
+ - Use streaming for longer responses
174
+ - Keep processing lightweight and fast
175
+ - Consider caching for frequently accessed data
176
+
177
+ ### Debugging
178
+ - Check agent logs in the terminal where you ran the agent
179
+ - Use the web UI to inspect task history and responses
180
+ - Monitor backend services with `lzd` (LazyDocker)
181
+ - Test response times and optimize for speed
182
+
183
+ ### To build the agent Docker image locally (normally not necessary):
184
+
185
+ 1. Build the agent image:
186
+ ```bash
187
+ agentex agents build --manifest manifest.yaml
188
+ ```
189
+ {% if use_uv %}
190
+ ```bash
191
+ # Build with uv
192
+ agentex agents build --manifest manifest.yaml --push
193
+ ```
194
+ {% else %}
195
+ ```bash
196
+ # Build with pip
197
+ agentex agents build --manifest manifest.yaml --push
198
+ ```
199
+ {% endif %}
200
+
201
+
202
+ ## Advanced Features
203
+
204
+ ### Streaming Responses
205
+ Handle long responses with streaming:
206
+
207
+ ```python
208
+ # In project/acp.py
209
+ @acp.on_message_send
210
+ async def handle_message_send(params: SendMessageParams):
211
+ # For streaming responses
212
+ async def stream_response():
213
+ for chunk in generate_response_chunks():
214
+ yield TaskMessageUpdate(
215
+ content=chunk,
216
+ is_complete=False
217
+ )
218
+ yield TaskMessageUpdate(
219
+ content="",
220
+ is_complete=True
221
+ )
222
+
223
+ return stream_response()
224
+ ```
225
+
226
+ ### Custom Response Logic
227
+ Add sophisticated response generation:
228
+
229
+ ```python
230
+ # In project/acp.py
231
+ @acp.on_message_send
232
+ async def handle_message_send(params: SendMessageParams):
233
+ # Analyze input
234
+ user_message = params.content.content
235
+
236
+ # Generate response
237
+ response = await generate_intelligent_response(user_message)
238
+
239
+ return TextContent(
240
+ author=MessageAuthor.AGENT,
241
+ content=response
242
+ )
243
+ ```
244
+
245
+ ### Integration with External Services
246
+ {% if use_uv %}
247
+ ```bash
248
+ # Add service clients
249
+ agentex uv add httpx requests-oauthlib
250
+
251
+ # Add AI/ML libraries
252
+ agentex uv add openai anthropic transformers
253
+
254
+ # Add fast processing libraries
255
+ agentex uv add numpy pandas
256
+ ```
257
+ {% else %}
258
+ ```bash
259
+ # Add to requirements.txt
260
+ echo "httpx" >> requirements.txt
261
+ echo "openai" >> requirements.txt
262
+ echo "numpy" >> requirements.txt
263
+ pip install -r requirements.txt
264
+ ```
265
+ {% endif %}
266
+
267
+ ## Troubleshooting
268
+
269
+ ### Common Issues
270
+
271
+ 1. **Agent not appearing in web UI**
272
+ - Check if agent is running on port 8000
273
+ - Verify `ENVIRONMENT=development` is set
274
+ - Check agent logs for errors
275
+
276
+ 2. **Slow response times**
277
+ - Profile your message handling code
278
+ - Consider caching expensive operations
279
+ - Optimize database queries and API calls
280
+
281
+ 3. **Dependency issues**
282
+ {% if use_uv %}
283
+ - Run `agentex uv sync` to ensure all dependencies are installed
284
+ {% else %}
285
+ - Run `pip install -r requirements.txt`
286
+ - Check if all dependencies are correctly listed in requirements.txt
287
+ {% endif %}
288
+
289
+ 4. **Port conflicts**
290
+ - Check if another service is using port 8000
291
+ - Use `lsof -i :8000` to find conflicting processes
292
+
293
+ Happy building with Sync ACP! 🚀⚡
@@ -0,0 +1,55 @@
1
+ # Example Override Configuration
2
+ # =============================
3
+ # This file shows how to override deployment settings from the global defaults in manifest.yaml.
4
+ # You can create multiple override files for different environments (e.g., staging.yaml, prod.yaml, dev.yaml)
5
+ # Only specify values that differ from the global defaults in manifest.yaml
6
+
7
+ # Override image tag
8
+ # image:
9
+ # tag: "v1.2.3"
10
+
11
+ # Override replica count
12
+ # replicaCount: 2
13
+
14
+ # Environment-specific environment variables
15
+ # env:
16
+ # - name: LOG_LEVEL
17
+ # value: "DEBUG"
18
+ # - name: ENVIRONMENT
19
+ # value: "staging"
20
+
21
+ # Override resource requirements
22
+ # resources:
23
+ # requests:
24
+ # cpu: "250m"
25
+ # memory: "512Mi"
26
+ # limits:
27
+ # cpu: "500m"
28
+ # memory: "1Gi"
29
+
30
+ # Advanced: Additional helm chart value overrides
31
+ # Use this for any helm chart values not covered by the simple options above
32
+ # additional_overrides:
33
+ # autoscaling:
34
+ # enabled: true
35
+ # minReplicas: 2
36
+ # maxReplicas: 10
37
+ # targetCPUUtilizationPercentage: 70
38
+ #
39
+ # service:
40
+ # type: LoadBalancer
41
+ #
42
+ # ingress:
43
+ # enabled: true
44
+ # annotations:
45
+ # kubernetes.io/ingress.class: "nginx"
46
+ # hosts:
47
+ # - host: {{ agent_name }}.example.com
48
+ # paths:
49
+ # - path: /
50
+ # pathType: Prefix
51
+
52
+ # To use this configuration:
53
+ # 1. Copy this file to a new file (e.g., staging.yaml, prod.yaml)
54
+ # 2. Uncomment and modify the values you want to override
55
+ # 3. Deploy with: agentex agents deploy --cluster your-cluster --namespace your-namespace --override-file staging.yaml
@@ -0,0 +1,116 @@
1
+ # Agent Manifest Configuration
2
+ # ---------------------------
3
+ # This file defines how your agent should be built and deployed.
4
+
5
+ # Build Configuration
6
+ # ------------------
7
+ # The build config defines what gets packaged into your agent's Docker image.
8
+ # This same configuration is used whether building locally or remotely.
9
+ #
10
+ # When building:
11
+ # 1. All files from include_paths are collected into a build context
12
+ # 2. The context is filtered by dockerignore rules
13
+ # 3. The Dockerfile uses this context to build your agent's image
14
+ # 4. The image is pushed to a registry and used to run your agent
15
+ build:
16
+ context:
17
+ # Root directory for the build context
18
+ root: ../ # Keep this as the default root
19
+
20
+ # Paths to include in the Docker build context
21
+ # Must include:
22
+ # - Your agent's directory (your custom agent code)
23
+ # These paths are collected and sent to the Docker daemon for building
24
+ include_paths:
25
+ - {{ project_path_from_build_root }}
26
+
27
+ # Path to your agent's Dockerfile
28
+ # This defines how your agent's image is built from the context
29
+ # Relative to the root directory
30
+ dockerfile: {{ project_path_from_build_root }}/Dockerfile
31
+
32
+ # Path to your agent's .dockerignore
33
+ # Filters unnecessary files from the build context
34
+ # Helps keep build context small and builds fast
35
+ dockerignore: {{ project_path_from_build_root }}/.dockerignore
36
+
37
+
38
+ # Local Development Configuration
39
+ # -----------------------------
40
+ # Only used when running the agent locally
41
+ local_development:
42
+ agent:
43
+ port: 8000 # Port where your local ACP server is running
44
+ host_address: host.docker.internal # Host address for Docker networking (host.docker.internal for Docker, localhost for direct)
45
+
46
+ # File paths for local development (relative to this manifest.yaml)
47
+ paths:
48
+ # Path to ACP server file
49
+ # Examples:
50
+ # project/acp.py (standard)
51
+ # src/server.py (custom structure)
52
+ # ../shared/acp.py (shared across projects)
53
+ # /absolute/path/acp.py (absolute path)
54
+ acp: project/acp.py
55
+
56
+
57
+ # Agent Configuration
58
+ # -----------------
59
+ agent:
60
+ acp_type: sync
61
+ # Unique name for your agent
62
+ # Used for task routing and monitoring
63
+ name: {{ agent_name }}
64
+
65
+ # Description of what your agent does
66
+ # Helps with documentation and discovery
67
+ description: {{ description }}
68
+
69
+ # Temporal workflow configuration
70
+ # Set enabled: true to use Temporal workflows for long-running tasks
71
+ temporal:
72
+ enabled: false
73
+
74
+ # Optional: Credentials mapping
75
+ # Maps Kubernetes secrets to environment variables
76
+ # Common credentials include:
77
+ # credentials:
78
+ # - env_var_name: OPENAI_API_KEY
79
+ # secret_name: openai-api-key
80
+ # secret_key: api-key
81
+
82
+ # Optional: Set Environment variables for running your agent locally as well
83
+ # as for deployment later on
84
+ # env:
85
+ # OPENAI_API_KEY: "<YOUR_OPENAI_API_KEY_HERE>"
86
+ # OPENAI_BASE_URL: "<YOUR_OPENAI_BASE_URL_HERE>"
87
+ # OPENAI_ORG_ID: "<YOUR_OPENAI_ORG_ID_HERE>"
88
+
89
+
90
+ # Deployment Configuration
91
+ # -----------------------
92
+ # Configuration for deploying your agent to Kubernetes clusters
93
+ deployment:
94
+ # Container image configuration
95
+ image:
96
+ repository: "" # Update with your container registry
97
+ tag: "latest" # Default tag, should be versioned in production
98
+
99
+ # Global deployment settings that apply to all clusters
100
+ # These can be overridden in cluster-specific files (deploy/*.yaml)
101
+ global:
102
+ agent:
103
+ name: "{{ agent_name }}"
104
+ description: "{{ description }}"
105
+
106
+ # Default replica count
107
+ replicaCount: 1
108
+
109
+ # Default resource requirements
110
+ resources:
111
+ requests:
112
+ cpu: "500m"
113
+ memory: "1Gi"
114
+ limits:
115
+ cpu: "1000m"
116
+ memory: "2Gi"
@@ -0,0 +1,26 @@
1
+ from typing import AsyncGenerator, Union
2
+ from agentex.lib.sdk.fastacp.fastacp import FastACP
3
+ from agentex.lib.types.acp import SendMessageParams
4
+
5
+ from agentex.lib.types.task_message_updates import TaskMessageUpdate
6
+ from agentex.types.task_message_content import TaskMessageContent
7
+ from agentex.types.text_content import TextContent
8
+ from agentex.lib.utils.logging import make_logger
9
+
10
+ logger = make_logger(__name__)
11
+
12
+
13
+ # Create an ACP server
14
+ acp = FastACP.create(
15
+ acp_type="sync",
16
+ )
17
+
18
+ @acp.on_message_send
19
+ async def handle_message_send(
20
+ params: SendMessageParams
21
+ ) -> TaskMessageContent | list[TaskMessageContent] | AsyncGenerator[TaskMessageUpdate, None]:
22
+ """Default message handler with streaming support"""
23
+ return TextContent(
24
+ author="agent",
25
+ content=f"Hello! I've received your message. Here's a generic response, but in future tutorials we'll see how you can get me to intelligently respond to your message. This is what I heard you say: {params.content.content}",
26
+ )
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "{{ project_name }}"
7
+ version = "0.1.0"
8
+ description = "{{ description }}"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ dependencies = [
12
+ "agentex-sdk",
13
+ "scale-gp",
14
+ ]
15
+
16
+ [project.optional-dependencies]
17
+ dev = [
18
+ "pytest",
19
+ "black",
20
+ "isort",
21
+ "flake8",
22
+ ]
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["project"]
26
+
27
+ [tool.black]
28
+ line-length = 88
29
+ target-version = ['py312']
30
+
31
+ [tool.isort]
32
+ profile = "black"
33
+ line_length = 88
@@ -0,0 +1,5 @@
1
+ # Install agentex-sdk from local path
2
+ agentex-sdk
3
+
4
+ # Scale GenAI Platform Python SDK
5
+ scale-gp
@@ -0,0 +1,43 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Environments
24
+ .env**
25
+ .venv
26
+ env/
27
+ venv/
28
+ ENV/
29
+ env.bak/
30
+ venv.bak/
31
+
32
+ # IDE
33
+ .idea/
34
+ .vscode/
35
+ *.swp
36
+ *.swo
37
+
38
+ # Git
39
+ .git
40
+ .gitignore
41
+
42
+ # Misc
43
+ .DS_Store
@@ -0,0 +1,48 @@
1
+ # syntax=docker/dockerfile:1.3
2
+ FROM python:3.12-slim
3
+ COPY --from=ghcr.io/astral-sh/uv:0.6.4 /uv /uvx /bin/
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ htop \
8
+ vim \
9
+ curl \
10
+ tar \
11
+ python3-dev \
12
+ postgresql-client \
13
+ build-essential \
14
+ libpq-dev \
15
+ gcc \
16
+ cmake \
17
+ netcat-openbsd \
18
+ && apt-get clean \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Install tctl (Temporal CLI)
22
+ RUN curl -L https://github.com/temporalio/tctl/releases/download/v1.18.1/tctl_1.18.1_linux_arm64.tar.gz -o /tmp/tctl.tar.gz && \
23
+ tar -xzf /tmp/tctl.tar.gz -C /usr/local/bin && \
24
+ chmod +x /usr/local/bin/tctl && \
25
+ rm /tmp/tctl.tar.gz
26
+
27
+ RUN uv pip install --system --upgrade pip setuptools wheel
28
+
29
+ ENV UV_HTTP_TIMEOUT=1000
30
+
31
+ # Copy just the pyproject.toml file to optimize caching
32
+ COPY {{ project_path_from_build_root }}/pyproject.toml /app/{{ project_path_from_build_root }}/pyproject.toml
33
+
34
+ WORKDIR /app/{{ project_path_from_build_root }}
35
+
36
+ # Install the required Python packages using uv
37
+ RUN uv pip install --system .
38
+
39
+ # Copy the project code
40
+ COPY {{ project_path_from_build_root }}/project /app/{{ project_path_from_build_root }}/project
41
+
42
+ WORKDIR /app/{{ project_path_from_build_root }}/project
43
+
44
+ # Run the ACP server using uvicorn
45
+ CMD ["uvicorn", "acp:acp", "--host", "0.0.0.0", "--port", "8000"]
46
+
47
+ # When we deploy the worker, we will replace the CMD with the following
48
+ # CMD ["python", "-m", "run_worker"]