agentex-sdk 0.8.1__py3-none-any.whl → 0.9.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.
- agentex/_base_client.py +134 -11
- agentex/_models.py +16 -1
- agentex/_types.py +9 -0
- agentex/_version.py +1 -1
- agentex/lib/cli/commands/agents.py +141 -73
- agentex/lib/cli/commands/init.py +13 -2
- agentex/lib/cli/handlers/agent_handlers.py +130 -12
- agentex/lib/cli/templates/sync-openai-agents/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/sync-openai-agents/Dockerfile-uv.j2 +42 -0
- agentex/lib/cli/templates/sync-openai-agents/Dockerfile.j2 +43 -0
- agentex/lib/cli/templates/sync-openai-agents/README.md.j2 +313 -0
- agentex/lib/cli/templates/sync-openai-agents/dev.ipynb.j2 +167 -0
- agentex/lib/cli/templates/sync-openai-agents/environments.yaml.j2 +53 -0
- agentex/lib/cli/templates/sync-openai-agents/manifest.yaml.j2 +115 -0
- agentex/lib/cli/templates/sync-openai-agents/project/acp.py.j2 +137 -0
- agentex/lib/cli/templates/sync-openai-agents/pyproject.toml.j2 +32 -0
- agentex/lib/cli/templates/sync-openai-agents/requirements.txt.j2 +5 -0
- agentex/lib/cli/templates/sync-openai-agents/test_agent.py.j2 +70 -0
- agentex/lib/sdk/config/environment_config.py +113 -73
- agentex/lib/sdk/config/validation.py +62 -61
- {agentex_sdk-0.8.1.dist-info → agentex_sdk-0.9.0.dist-info}/METADATA +1 -1
- {agentex_sdk-0.8.1.dist-info → agentex_sdk-0.9.0.dist-info}/RECORD +25 -14
- {agentex_sdk-0.8.1.dist-info → agentex_sdk-0.9.0.dist-info}/licenses/LICENSE +1 -1
- {agentex_sdk-0.8.1.dist-info → agentex_sdk-0.9.0.dist-info}/WHEEL +0 -0
- {agentex_sdk-0.8.1.dist-info → agentex_sdk-0.9.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
node \
|
|
19
|
+
npm \
|
|
20
|
+
&& apt-get clean \
|
|
21
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
22
|
+
|
|
23
|
+
RUN uv pip install --system --upgrade pip setuptools wheel
|
|
24
|
+
|
|
25
|
+
ENV UV_HTTP_TIMEOUT=1000
|
|
26
|
+
|
|
27
|
+
# Copy just the requirements file to optimize caching
|
|
28
|
+
COPY {{ project_path_from_build_root }}/requirements.txt /app/{{ project_path_from_build_root }}/requirements.txt
|
|
29
|
+
|
|
30
|
+
WORKDIR /app/{{ project_path_from_build_root }}
|
|
31
|
+
|
|
32
|
+
# Install the required Python packages
|
|
33
|
+
RUN uv pip install --system -r requirements.txt
|
|
34
|
+
|
|
35
|
+
# Copy the project code
|
|
36
|
+
COPY {{ project_path_from_build_root }}/project /app/{{ project_path_from_build_root }}/project
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Set environment variables
|
|
40
|
+
ENV PYTHONPATH=/app
|
|
41
|
+
|
|
42
|
+
# Run the agent using uvicorn
|
|
43
|
+
CMD ["uvicorn", "project.acp:acp", "--host", "0.0.0.0", "--port", "8000"]
|
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
├── dev.ipynb # Development notebook for testing
|
|
64
|
+
{% if use_uv %}
|
|
65
|
+
└── pyproject.toml # Dependencies (uv)
|
|
66
|
+
{% else %}
|
|
67
|
+
└── requirements.txt # Dependencies (pip)
|
|
68
|
+
{% endif %}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
|
|
73
|
+
### 1. Customize Message Handlers
|
|
74
|
+
- Modify the handlers in `acp.py` to implement your agent's logic
|
|
75
|
+
- Add your own tools and capabilities
|
|
76
|
+
- Implement custom response generation
|
|
77
|
+
|
|
78
|
+
### 2. Test Your Agent with the Development Notebook
|
|
79
|
+
Use the included `dev.ipynb` Jupyter notebook to test your agent interactively:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Start Jupyter notebook (make sure you have jupyter installed)
|
|
83
|
+
jupyter notebook dev.ipynb
|
|
84
|
+
|
|
85
|
+
# Or use VS Code to open the notebook directly
|
|
86
|
+
code dev.ipynb
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The notebook includes:
|
|
90
|
+
- **Setup**: Connect to your local AgentEx backend
|
|
91
|
+
- **Non-streaming tests**: Send messages and get complete responses
|
|
92
|
+
- **Streaming tests**: Test real-time streaming responses
|
|
93
|
+
- **Task management**: Optional task creation and management
|
|
94
|
+
|
|
95
|
+
The notebook automatically uses your agent name (`{{ agent_name }}`) and provides examples for both streaming and non-streaming message handling.
|
|
96
|
+
|
|
97
|
+
### 3. Manage Dependencies
|
|
98
|
+
|
|
99
|
+
{% if use_uv %}
|
|
100
|
+
You chose **uv** for package management. Here's how to work with dependencies:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Add new dependencies
|
|
104
|
+
agentex uv add requests openai anthropic
|
|
105
|
+
|
|
106
|
+
# Install/sync dependencies
|
|
107
|
+
agentex uv sync
|
|
108
|
+
|
|
109
|
+
# Run commands with uv
|
|
110
|
+
uv run agentex agents run --manifest manifest.yaml
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Benefits of uv:**
|
|
114
|
+
- Faster dependency resolution and installation
|
|
115
|
+
- Better dependency isolation
|
|
116
|
+
- Modern Python packaging standards
|
|
117
|
+
|
|
118
|
+
{% else %}
|
|
119
|
+
You chose **pip** for package management. Here's how to work with dependencies:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Edit requirements.txt manually to add dependencies
|
|
123
|
+
echo "requests" >> requirements.txt
|
|
124
|
+
echo "openai" >> requirements.txt
|
|
125
|
+
|
|
126
|
+
# Install dependencies
|
|
127
|
+
pip install -r requirements.txt
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Benefits of pip:**
|
|
131
|
+
- Familiar workflow for most Python developers
|
|
132
|
+
- Simple requirements.txt management
|
|
133
|
+
- Wide compatibility
|
|
134
|
+
{% endif %}
|
|
135
|
+
|
|
136
|
+
### 4. Configure Credentials
|
|
137
|
+
Options:
|
|
138
|
+
1. Add any required credentials to your manifest.yaml via the `env` section
|
|
139
|
+
2. Export them in your shell: `export OPENAI_API_KEY=...`
|
|
140
|
+
3. For local development, create a `.env.local` file in the project directory
|
|
141
|
+
|
|
142
|
+
## Local Development
|
|
143
|
+
|
|
144
|
+
### 1. Start the Agentex Backend
|
|
145
|
+
```bash
|
|
146
|
+
# Navigate to the backend directory
|
|
147
|
+
cd agentex
|
|
148
|
+
|
|
149
|
+
# Start all services using Docker Compose
|
|
150
|
+
make dev
|
|
151
|
+
|
|
152
|
+
# Optional: In a separate terminal, use lazydocker for a better UI (everything should say "healthy")
|
|
153
|
+
lzd
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 3. Run Your Agent
|
|
157
|
+
```bash
|
|
158
|
+
# From this directory
|
|
159
|
+
export ENVIRONMENT=development && agentex agents run --manifest manifest.yaml
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 4. Interact with Your Agent
|
|
163
|
+
|
|
164
|
+
**Option 1: Web UI (Recommended)**
|
|
165
|
+
```bash
|
|
166
|
+
# Start the local web interface
|
|
167
|
+
cd agentex-web
|
|
168
|
+
make dev
|
|
169
|
+
|
|
170
|
+
# Then open http://localhost:3000 in your browser to chat with your agent
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Option 2: CLI (Deprecated)**
|
|
174
|
+
```bash
|
|
175
|
+
# Submit a task via CLI
|
|
176
|
+
agentex tasks submit --agent {{ agent_name }} --task "Your task here"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Development Tips
|
|
180
|
+
|
|
181
|
+
### Environment Variables
|
|
182
|
+
- Set environment variables in project/.env for any required credentials
|
|
183
|
+
- Or configure them in the manifest.yaml under the `env` section
|
|
184
|
+
- The `.env` file is automatically loaded in development mode
|
|
185
|
+
|
|
186
|
+
### Local Testing
|
|
187
|
+
- Use `export ENVIRONMENT=development` before running your agent
|
|
188
|
+
- This enables local service discovery and debugging features
|
|
189
|
+
- Your agent will automatically connect to locally running services
|
|
190
|
+
|
|
191
|
+
### Sync ACP Considerations
|
|
192
|
+
- Responses must be immediate (no long-running operations)
|
|
193
|
+
- Use streaming for longer responses
|
|
194
|
+
- Keep processing lightweight and fast
|
|
195
|
+
- Consider caching for frequently accessed data
|
|
196
|
+
|
|
197
|
+
### Debugging
|
|
198
|
+
- Check agent logs in the terminal where you ran the agent
|
|
199
|
+
- Use the web UI to inspect task history and responses
|
|
200
|
+
- Monitor backend services with `lzd` (LazyDocker)
|
|
201
|
+
- Test response times and optimize for speed
|
|
202
|
+
|
|
203
|
+
### To build the agent Docker image locally (normally not necessary):
|
|
204
|
+
|
|
205
|
+
1. Build the agent image:
|
|
206
|
+
```bash
|
|
207
|
+
agentex agents build --manifest manifest.yaml
|
|
208
|
+
```
|
|
209
|
+
{% if use_uv %}
|
|
210
|
+
```bash
|
|
211
|
+
# Build with uv
|
|
212
|
+
agentex agents build --manifest manifest.yaml --push
|
|
213
|
+
```
|
|
214
|
+
{% else %}
|
|
215
|
+
```bash
|
|
216
|
+
# Build with pip
|
|
217
|
+
agentex agents build --manifest manifest.yaml --push
|
|
218
|
+
```
|
|
219
|
+
{% endif %}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
## Advanced Features
|
|
223
|
+
|
|
224
|
+
### Streaming Responses
|
|
225
|
+
Handle long responses with streaming:
|
|
226
|
+
|
|
227
|
+
```python
|
|
228
|
+
# In project/acp.py
|
|
229
|
+
@acp.on_message_send
|
|
230
|
+
async def handle_message_send(params: SendMessageParams):
|
|
231
|
+
# For streaming responses
|
|
232
|
+
async def stream_response():
|
|
233
|
+
for chunk in generate_response_chunks():
|
|
234
|
+
yield TaskMessageUpdate(
|
|
235
|
+
content=chunk,
|
|
236
|
+
is_complete=False
|
|
237
|
+
)
|
|
238
|
+
yield TaskMessageUpdate(
|
|
239
|
+
content="",
|
|
240
|
+
is_complete=True
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
return stream_response()
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Custom Response Logic
|
|
247
|
+
Add sophisticated response generation:
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
# In project/acp.py
|
|
251
|
+
@acp.on_message_send
|
|
252
|
+
async def handle_message_send(params: SendMessageParams):
|
|
253
|
+
# Analyze input
|
|
254
|
+
user_message = params.content.content
|
|
255
|
+
|
|
256
|
+
# Generate response
|
|
257
|
+
response = await generate_intelligent_response(user_message)
|
|
258
|
+
|
|
259
|
+
return TextContent(
|
|
260
|
+
author=MessageAuthor.AGENT,
|
|
261
|
+
content=response
|
|
262
|
+
)
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Integration with External Services
|
|
266
|
+
{% if use_uv %}
|
|
267
|
+
```bash
|
|
268
|
+
# Add service clients
|
|
269
|
+
agentex uv add httpx requests-oauthlib
|
|
270
|
+
|
|
271
|
+
# Add AI/ML libraries
|
|
272
|
+
agentex uv add openai anthropic transformers
|
|
273
|
+
|
|
274
|
+
# Add fast processing libraries
|
|
275
|
+
agentex uv add numpy pandas
|
|
276
|
+
```
|
|
277
|
+
{% else %}
|
|
278
|
+
```bash
|
|
279
|
+
# Add to requirements.txt
|
|
280
|
+
echo "httpx" >> requirements.txt
|
|
281
|
+
echo "openai" >> requirements.txt
|
|
282
|
+
echo "numpy" >> requirements.txt
|
|
283
|
+
pip install -r requirements.txt
|
|
284
|
+
```
|
|
285
|
+
{% endif %}
|
|
286
|
+
|
|
287
|
+
## Troubleshooting
|
|
288
|
+
|
|
289
|
+
### Common Issues
|
|
290
|
+
|
|
291
|
+
1. **Agent not appearing in web UI**
|
|
292
|
+
- Check if agent is running on port 8000
|
|
293
|
+
- Verify `ENVIRONMENT=development` is set
|
|
294
|
+
- Check agent logs for errors
|
|
295
|
+
|
|
296
|
+
2. **Slow response times**
|
|
297
|
+
- Profile your message handling code
|
|
298
|
+
- Consider caching expensive operations
|
|
299
|
+
- Optimize database queries and API calls
|
|
300
|
+
|
|
301
|
+
3. **Dependency issues**
|
|
302
|
+
{% if use_uv %}
|
|
303
|
+
- Run `agentex uv sync` to ensure all dependencies are installed
|
|
304
|
+
{% else %}
|
|
305
|
+
- Run `pip install -r requirements.txt`
|
|
306
|
+
- Check if all dependencies are correctly listed in requirements.txt
|
|
307
|
+
{% endif %}
|
|
308
|
+
|
|
309
|
+
4. **Port conflicts**
|
|
310
|
+
- Check if another service is using port 8000
|
|
311
|
+
- Use `lsof -i :8000` to find conflicting processes
|
|
312
|
+
|
|
313
|
+
Happy building with Sync ACP! 🚀⚡
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": null,
|
|
6
|
+
"id": "36834357",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [],
|
|
9
|
+
"source": [
|
|
10
|
+
"from agentex import Agentex\n",
|
|
11
|
+
"\n",
|
|
12
|
+
"client = Agentex(base_url=\"http://localhost:5003\")"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"cell_type": "code",
|
|
17
|
+
"execution_count": null,
|
|
18
|
+
"id": "d1c309d6",
|
|
19
|
+
"metadata": {},
|
|
20
|
+
"outputs": [],
|
|
21
|
+
"source": [
|
|
22
|
+
"AGENT_NAME = \"{{ agent_name }}\""
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"cell_type": "code",
|
|
27
|
+
"execution_count": null,
|
|
28
|
+
"id": "9f6e6ef0",
|
|
29
|
+
"metadata": {},
|
|
30
|
+
"outputs": [],
|
|
31
|
+
"source": [
|
|
32
|
+
"# # (Optional) Create a new task. If you don't create a new task, each message will be sent to a new task. The server will create the task for you.\n",
|
|
33
|
+
"\n",
|
|
34
|
+
"# import uuid\n",
|
|
35
|
+
"\n",
|
|
36
|
+
"# TASK_ID = str(uuid.uuid4())[:8]\n",
|
|
37
|
+
"\n",
|
|
38
|
+
"# rpc_response = client.agents.rpc_by_name(\n",
|
|
39
|
+
"# agent_name=AGENT_NAME,\n",
|
|
40
|
+
"# method=\"task/create\",\n",
|
|
41
|
+
"# params={\n",
|
|
42
|
+
"# \"name\": f\"{TASK_ID}-task\",\n",
|
|
43
|
+
"# \"params\": {}\n",
|
|
44
|
+
"# }\n",
|
|
45
|
+
"# )\n",
|
|
46
|
+
"\n",
|
|
47
|
+
"# task = rpc_response.result\n",
|
|
48
|
+
"# print(task)"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"cell_type": "code",
|
|
53
|
+
"execution_count": null,
|
|
54
|
+
"id": "b03b0d37",
|
|
55
|
+
"metadata": {},
|
|
56
|
+
"outputs": [],
|
|
57
|
+
"source": [
|
|
58
|
+
"# Test non streaming response\n",
|
|
59
|
+
"from agentex.types import TextContent\n",
|
|
60
|
+
"\n",
|
|
61
|
+
"# The response is expected to be a list of TaskMessage objects, which is a union of the following types:\n",
|
|
62
|
+
"# - TextContent: A message with just text content \n",
|
|
63
|
+
"# - DataContent: A message with JSON-serializable data content\n",
|
|
64
|
+
"# - ToolRequestContent: A message with a tool request, which contains a JSON-serializable request to call a tool\n",
|
|
65
|
+
"# - ToolResponseContent: A message with a tool response, which contains response object from a tool call in its content\n",
|
|
66
|
+
"\n",
|
|
67
|
+
"# When processing the message/send response, if you are expecting more than TextContent, such as DataContent, ToolRequestContent, or ToolResponseContent, you can process them as well\n",
|
|
68
|
+
"\n",
|
|
69
|
+
"rpc_response = client.agents.send_message(\n",
|
|
70
|
+
" agent_name=AGENT_NAME,\n",
|
|
71
|
+
" params={\n",
|
|
72
|
+
" \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Hello what can you do?\"},\n",
|
|
73
|
+
" \"stream\": False\n",
|
|
74
|
+
" }\n",
|
|
75
|
+
")\n",
|
|
76
|
+
"\n",
|
|
77
|
+
"if not rpc_response or not rpc_response.result:\n",
|
|
78
|
+
" raise ValueError(\"No result in response\")\n",
|
|
79
|
+
"\n",
|
|
80
|
+
"# Extract and print just the text content from the response\n",
|
|
81
|
+
"for task_message in rpc_response.result:\n",
|
|
82
|
+
" content = task_message.content\n",
|
|
83
|
+
" if isinstance(content, TextContent):\n",
|
|
84
|
+
" text = content.content\n",
|
|
85
|
+
" print(text)\n"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"cell_type": "code",
|
|
90
|
+
"execution_count": null,
|
|
91
|
+
"id": "79688331",
|
|
92
|
+
"metadata": {},
|
|
93
|
+
"outputs": [],
|
|
94
|
+
"source": [
|
|
95
|
+
"# Test streaming response\n",
|
|
96
|
+
"from agentex.types.task_message_update import StreamTaskMessageDelta, StreamTaskMessageFull\n",
|
|
97
|
+
"from agentex.types.text_delta import TextDelta\n",
|
|
98
|
+
"\n",
|
|
99
|
+
"\n",
|
|
100
|
+
"# The result object of message/send will be a TaskMessageUpdate which is a union of the following types:\n",
|
|
101
|
+
"# - StreamTaskMessageStart: \n",
|
|
102
|
+
"# - An indicator that a streaming message was started, doesn't contain any useful content\n",
|
|
103
|
+
"# - StreamTaskMessageDelta: \n",
|
|
104
|
+
"# - A delta of a streaming message, contains the text delta to aggregate\n",
|
|
105
|
+
"# - StreamTaskMessageDone: \n",
|
|
106
|
+
"# - An indicator that a streaming message was done, doesn't contain any useful content\n",
|
|
107
|
+
"# - StreamTaskMessageFull: \n",
|
|
108
|
+
"# - A non-streaming message, there is nothing to aggregate, since this contains the full message, not deltas\n",
|
|
109
|
+
"\n",
|
|
110
|
+
"# Whenn processing StreamTaskMessageDelta, if you are expecting more than TextDeltas, such as DataDelta, ToolRequestDelta, or ToolResponseDelta, you can process them as well\n",
|
|
111
|
+
"# Whenn processing StreamTaskMessageFull, if you are expecting more than TextContent, such as DataContent, ToolRequestContent, or ToolResponseContent, you can process them as well\n",
|
|
112
|
+
"\n",
|
|
113
|
+
"for agent_rpc_response_chunk in client.agents.send_message_stream(\n",
|
|
114
|
+
" agent_name=AGENT_NAME,\n",
|
|
115
|
+
" params={\n",
|
|
116
|
+
" \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Hello what can you do?\"},\n",
|
|
117
|
+
" \"stream\": True\n",
|
|
118
|
+
" }\n",
|
|
119
|
+
"):\n",
|
|
120
|
+
" # We know that the result of the message/send when stream is set to True will be a TaskMessageUpdate\n",
|
|
121
|
+
" task_message_update = agent_rpc_response_chunk.result\n",
|
|
122
|
+
" # Print oly the text deltas as they arrive or any full messages\n",
|
|
123
|
+
" if isinstance(task_message_update, StreamTaskMessageDelta):\n",
|
|
124
|
+
" delta = task_message_update.delta\n",
|
|
125
|
+
" if isinstance(delta, TextDelta):\n",
|
|
126
|
+
" print(delta.text_delta, end=\"\", flush=True)\n",
|
|
127
|
+
" else:\n",
|
|
128
|
+
" print(f\"Found non-text {type(task_message)} object in streaming message.\")\n",
|
|
129
|
+
" elif isinstance(task_message_update, StreamTaskMessageFull):\n",
|
|
130
|
+
" content = task_message_update.content\n",
|
|
131
|
+
" if isinstance(content, TextContent):\n",
|
|
132
|
+
" print(content.content)\n",
|
|
133
|
+
" else:\n",
|
|
134
|
+
" print(f\"Found non-text {type(task_message)} object in full message.\")\n"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"cell_type": "code",
|
|
139
|
+
"execution_count": null,
|
|
140
|
+
"id": "c5e7e042",
|
|
141
|
+
"metadata": {},
|
|
142
|
+
"outputs": [],
|
|
143
|
+
"source": []
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"metadata": {
|
|
147
|
+
"kernelspec": {
|
|
148
|
+
"display_name": ".venv",
|
|
149
|
+
"language": "python",
|
|
150
|
+
"name": "python3"
|
|
151
|
+
},
|
|
152
|
+
"language_info": {
|
|
153
|
+
"codemirror_mode": {
|
|
154
|
+
"name": "ipython",
|
|
155
|
+
"version": 3
|
|
156
|
+
},
|
|
157
|
+
"file_extension": ".py",
|
|
158
|
+
"mimetype": "text/x-python",
|
|
159
|
+
"name": "python",
|
|
160
|
+
"nbconvert_exporter": "python",
|
|
161
|
+
"pygments_lexer": "ipython3",
|
|
162
|
+
"version": "3.12.9"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"nbformat": 4,
|
|
166
|
+
"nbformat_minor": 5
|
|
167
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Agent Environment Configuration
|
|
2
|
+
# ------------------------------
|
|
3
|
+
# This file defines environment-specific settings for your agent.
|
|
4
|
+
# This DIFFERS from the manifest.yaml file in that it is used to program things that are ONLY per environment.
|
|
5
|
+
|
|
6
|
+
# ********** EXAMPLE **********
|
|
7
|
+
# schema_version: "v1" # This is used to validate the file structure and is not used by the agentex CLI
|
|
8
|
+
# environments:
|
|
9
|
+
# dev:
|
|
10
|
+
# auth:
|
|
11
|
+
# principal:
|
|
12
|
+
# user_id: "1234567890"
|
|
13
|
+
# user_name: "John Doe"
|
|
14
|
+
# user_email: "john.doe@example.com"
|
|
15
|
+
# user_role: "admin"
|
|
16
|
+
# user_permissions: "read, write, delete"
|
|
17
|
+
# helm_overrides: # This is used to override the global helm values.yaml file in the agentex-agent helm charts
|
|
18
|
+
# replicas: 3
|
|
19
|
+
# resources:
|
|
20
|
+
# requests:
|
|
21
|
+
# cpu: "1000m"
|
|
22
|
+
# memory: "2Gi"
|
|
23
|
+
# limits:
|
|
24
|
+
# cpu: "2000m"
|
|
25
|
+
# memory: "4Gi"
|
|
26
|
+
# env:
|
|
27
|
+
# - name: LOG_LEVEL
|
|
28
|
+
# value: "DEBUG"
|
|
29
|
+
# - name: ENVIRONMENT
|
|
30
|
+
# value: "staging"
|
|
31
|
+
# kubernetes:
|
|
32
|
+
# # OPTIONAL - Otherwise it will be derived from separately. However, this can be used to override the derived
|
|
33
|
+
# # namespace and deploy it with in the same namespace that already exists for a separate agent.
|
|
34
|
+
# namespace: "team-{{agent_name}}"
|
|
35
|
+
# ********** END EXAMPLE **********
|
|
36
|
+
|
|
37
|
+
schema_version: "v1" # This is used to validate the file structure and is not used by the agentex CLI
|
|
38
|
+
environments:
|
|
39
|
+
dev:
|
|
40
|
+
auth:
|
|
41
|
+
principal:
|
|
42
|
+
user_id: # TODO: Fill in
|
|
43
|
+
account_id: # TODO: Fill in
|
|
44
|
+
helm_overrides:
|
|
45
|
+
replicaCount: 2
|
|
46
|
+
resources:
|
|
47
|
+
requests:
|
|
48
|
+
cpu: "500m"
|
|
49
|
+
memory: "1Gi"
|
|
50
|
+
limits:
|
|
51
|
+
cpu: "1000m"
|
|
52
|
+
memory: "2Gi"
|
|
53
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
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: [] # Update with your 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: {} # Update with your environment variables
|
|
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
|
+
imagePullSecrets: [] # Update with your image pull secret names
|
|
100
|
+
# - name: my-registry-secret
|
|
101
|
+
|
|
102
|
+
# Global deployment settings that apply to all clusters
|
|
103
|
+
# These can be overridden in cluster-specific environments (environments.yaml)
|
|
104
|
+
global:
|
|
105
|
+
# Default replica count
|
|
106
|
+
replicaCount: 1
|
|
107
|
+
|
|
108
|
+
# Default resource requirements
|
|
109
|
+
resources:
|
|
110
|
+
requests:
|
|
111
|
+
cpu: "500m"
|
|
112
|
+
memory: "1Gi"
|
|
113
|
+
limits:
|
|
114
|
+
cpu: "1000m"
|
|
115
|
+
memory: "2Gi"
|