Skip to content

Commit 83b158b

Browse files
committed
Merge branch 'main' into stas/trace-agentex-source
2 parents 17257bb + 1074a2a commit 83b158b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6555
-312
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
permissions:
4343
contents: read
4444
id-token: write
45-
runs-on: depot-ubuntu-24.04
45+
runs-on: ${{ github.repository == 'stainless-sdks/agentex-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
4646
steps:
4747
- uses: actions/checkout@v4
4848

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.4.10"
2+
".": "0.4.12"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 34
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-4e747d1e081a07dcd47f7aaed0a8fc18c748658d4c8875f793daf4850e74b47c.yml
3-
openapi_spec_hash: 3a159d7dc86cae47945e678009a197be
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-6eec9554350594d13aa61f6d3c384a54cbaba95481ee06c228a9d0a0aefaeda8.yml
3+
openapi_spec_hash: 63770414d1be9807d9b7ebbef0ae9fee
44
config_hash: aeabb3a919ad2763f5d0f41961a2520a

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Changelog
22

3+
## 0.4.12 (2025-09-08)
4+
5+
Full Changelog: [v0.4.11...v0.4.12](https://github.com/scaleapi/agentex-python/compare/v0.4.11...v0.4.12)
6+
7+
### ⚠ BREAKING CHANGES
8+
9+
* task_cancel now requires explicit agent_name/agent_id parameter to identify which agent owns the task being cancelled
10+
11+
### Bug Fixes
12+
13+
* task cancellation architectural bug ([f9a72a9](https://github.com/scaleapi/agentex-python/commit/f9a72a94f96afe86d3cc80f4f85ea368279d4517))
14+
15+
## 0.4.11 (2025-09-04)
16+
17+
Full Changelog: [v0.4.10...v0.4.11](https://github.com/scaleapi/agentex-python/compare/v0.4.10...v0.4.11)
18+
19+
### Features
20+
21+
* Guardrail support ([e3e9bf9](https://github.com/scaleapi/agentex-python/commit/e3e9bf9dd6cf16b9a783638690d4a31914be8139))
22+
* improve future compat with pydantic v3 ([f0d8624](https://github.com/scaleapi/agentex-python/commit/f0d86244065c88bb2777db8fabeb1921e7e01116))
23+
* multiple guardrails ([ea8f98a](https://github.com/scaleapi/agentex-python/commit/ea8f98a973ba486e854cf14528a88eb73a203cf8))
24+
* **templates:** add custom activity timeout guidance for temporal agents ([7658256](https://github.com/scaleapi/agentex-python/commit/765825680132677ea0351f2a9410f472ee754906))
25+
* **types:** replace List[str] with SequenceNotStr in params ([f319781](https://github.com/scaleapi/agentex-python/commit/f3197818637574cd92b2c1f710679155eddf5af7))
26+
27+
28+
### Bug Fixes
29+
30+
* Adding new example for guardrails instead of using 10_agentic ([15dc44b](https://github.com/scaleapi/agentex-python/commit/15dc44b333a977564c9974cc089d5ef578840714))
31+
* avoid newer type syntax ([6b5c82a](https://github.com/scaleapi/agentex-python/commit/6b5c82aab9ebcf755575b641aced2b77a13a71c3))
32+
33+
34+
### Chores
35+
36+
* **internal:** add Sequence related utils ([496034d](https://github.com/scaleapi/agentex-python/commit/496034db4d6cba361c1f392a4bb86f6ab057e878))
37+
* **internal:** change ci workflow machines ([7445d94](https://github.com/scaleapi/agentex-python/commit/7445d94cb860f92911ec97ecd951149557956c6a))
38+
* **internal:** move mypy configurations to `pyproject.toml` file ([e96cd34](https://github.com/scaleapi/agentex-python/commit/e96cd34629d5ea173446c3184fbfe28bd2b370a0))
39+
* **internal:** update pyright exclude list ([d952430](https://github.com/scaleapi/agentex-python/commit/d952430ab4cbc41bca06010bbcfea3eeb022073e))
40+
341
## 0.4.10 (2025-08-24)
442

543
Full Changelog: [v0.4.9...v0.4.10](https://github.com/scaleapi/agentex-python/compare/v0.4.9...v0.4.10)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 requirements file to optimize caching
32+
COPY 010_agent_chat/requirements.txt /app/requirements.txt
33+
34+
WORKDIR /app/
35+
36+
# Install the required Python packages
37+
RUN uv pip install --system -r requirements.txt
38+
39+
# Copy the project code
40+
COPY 010_agent_chat/project /app/project
41+
42+
# Run the ACP server using uvicorn
43+
CMD ["uvicorn", "project.acp:acp", "--host", "0.0.0.0", "--port", "8000"]
44+
45+
# When we deploy the worker, we will replace the CMD with the following
46+
# CMD ["python", "-m", "run_worker"]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# [Agentic] Agent Chat with Guardrails
2+
3+
This tutorial demonstrates how to implement streaming multiturn tool-enabled chat with input and output guardrails using Temporal workflows in AgentEx agents.
4+
5+
## Overview
6+
7+
This example extends the basic agent chat functionality by adding guardrails that can filter both user inputs and AI outputs. This is useful for content moderation, compliance, or preventing certain topics from being discussed.
8+
9+
## Guardrails
10+
11+
### Input Guardrails
12+
- **Spaghetti Guardrail**: Blocks any mention of "spaghetti" in user messages
13+
- **Soup Guardrail**: Blocks any mention of "soup" in user messages
14+
15+
### Output Guardrails
16+
- **Pizza Guardrail**: Prevents the AI from mentioning "pizza" in responses
17+
- **Sushi Guardrail**: Prevents the AI from mentioning "sushi" in responses
18+
19+
## Testing the Guardrails
20+
21+
To see the guardrails in action:
22+
23+
1. **Test Input Guardrails:**
24+
- Try: "Tell me about spaghetti"
25+
- Try: "What's your favorite soup?"
26+
- The guardrails will block these messages before they reach the AI
27+
28+
2. **Test Output Guardrails:**
29+
- Ask: "What are popular Italian foods?" (may trigger pizza guardrail)
30+
- Ask: "What are popular Japanese foods?" (may trigger sushi guardrail)
31+
- The AI may generate responses containing these words, but the guardrails will block them
32+
33+
## Implementation Details
34+
35+
The guardrails are implemented as functions that:
36+
- Check the input/output for specific content
37+
- Return a `GuardrailFunctionOutput` with:
38+
- `tripwire_triggered`: Whether to block the content
39+
- `output_info`: Metadata about the check
40+
- `rejection_message`: Custom message shown when content is blocked
41+
42+
See `workflow.py` for the complete implementation.

0 commit comments

Comments
 (0)