Skip to content

Commit 442f6f2

Browse files
Revert x-request-id changes - out of scope
1 parent b4c898f commit 442f6f2

File tree

10 files changed

+3070
-1
lines changed

10 files changed

+3070
-1
lines changed
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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 030_header_test/requirements.txt /app/requirements.txt
27+
28+
WORKDIR /app/
29+
30+
# Install the required Python packages
31+
RUN uv pip install --system -r requirements.txt
32+
33+
# Copy the project code
34+
COPY 030_header_test/project /app/project
35+
36+
# Set environment variables
37+
ENV PYTHONPATH=/app
38+
39+
# Run the agent using uvicorn
40+
CMD ["uvicorn", "project.acp:acp", "--host", "0.0.0.0", "--port", "8000"]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Header Test Agent
2+
3+
This agent tests header forwarding from the AgentEx backend to the agent.
4+
5+
## Features
6+
7+
- Receives events with forwarded HTTP headers
8+
- Validates that custom headers (like auth keys) are properly forwarded
9+
- Logs header information for debugging
10+
11+
## Testing
12+
13+
The agent will log:
14+
- ✅ When headers are successfully received
15+
- ⚠️ When expected headers are missing
16+
- ❌ When no headers are forwarded at all
17+
18+
## Expected Headers
19+
20+
The agent looks for:
21+
- `x-test-auth-key`: Test authentication key
22+
- `x-custom-header`: Custom header for testing
23+
24+
All headers starting with `x-` should be forwarded (except security-sensitive ones filtered by the backend).
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Agent Manifest Configuration for Header Test Agent
2+
# ---------------------------
3+
4+
build:
5+
context:
6+
root: ../
7+
include_paths:
8+
- 030_header_test
9+
dockerfile: 030_header_test/Dockerfile
10+
dockerignore: 030_header_test/.dockerignore
11+
12+
local_development:
13+
agent:
14+
port: 8003
15+
host_address: host.docker.internal
16+
paths:
17+
acp: project/acp.py
18+
19+
agent:
20+
name: s030-header-test
21+
acp_type: agentic
22+
description: Test agent for validating header forwarding from backend to agent
23+
temporal:
24+
enabled: false
25+
26+
deployment:
27+
image:
28+
repository: ""
29+
tag: "latest"
30+
global:
31+
agent:
32+
name: "s030-header-test"
33+
description: "Test agent for validating header forwarding from backend to agent"
34+
replicaCount: 1
35+
resources:
36+
requests:
37+
cpu: "500m"
38+
memory: "1Gi"
39+
limits:
40+
cpu: "1000m"
41+
memory: "2Gi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Header test agent project
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from typing import Union, AsyncGenerator
2+
3+
from agentex.lib.types.acp import SendMessageParams, SendEventParams
4+
from agentex.lib.utils.logging import make_logger
5+
from agentex.types.task_message import TaskMessageContent
6+
from agentex.lib.sdk.fastacp.fastacp import FastACP
7+
from agentex.types.task_message_update import TaskMessageUpdate
8+
from agentex.types.task_message_content import TextContent
9+
10+
logger = make_logger(__name__)
11+
12+
13+
# Create an ACP server (agentic type to support event/send)
14+
from agentex.lib.types.fastacp import AgenticACPConfig
15+
16+
acp = FastACP.create(
17+
acp_type="agentic",
18+
config=AgenticACPConfig(type="base"),
19+
)
20+
21+
22+
@acp.on_message_send
23+
async def handle_message_send(
24+
params: SendMessageParams
25+
) -> Union[TaskMessageContent, AsyncGenerator[TaskMessageUpdate, None]]:
26+
"""Message handler - simple echo response"""
27+
message_text = ""
28+
if hasattr(params.content, 'content'):
29+
content_val = getattr(params.content, 'content', '')
30+
if isinstance(content_val, str):
31+
message_text = content_val
32+
33+
return TextContent(
34+
author="agent",
35+
content=f"Message received: {message_text}",
36+
)
37+
38+
39+
@acp.on_task_event_send
40+
async def handle_event_send(params: SendEventParams) -> None:
41+
"""Event handler that validates header forwarding"""
42+
logger.info(f"=== EVENT RECEIVED ===")
43+
logger.info(f"Event ID: {params.event.id}")
44+
logger.info(f"Task ID: {params.task.id}")
45+
logger.info(f"Agent ID: {params.agent.id}")
46+
47+
# Check if request headers were forwarded
48+
if params.request:
49+
logger.info(f"✅ Request headers present!")
50+
logger.info(f"Headers: {params.request}")
51+
52+
# Headers are nested in params.request['headers']
53+
headers = params.request.get('headers', {})
54+
55+
# Look for specific test headers
56+
if 'x-test-auth-key' in headers:
57+
logger.info(f"✅ Found x-test-auth-key: {headers['x-test-auth-key']}")
58+
else:
59+
logger.warning("⚠️ x-test-auth-key not found in request headers")
60+
61+
if 'x-custom-header' in headers:
62+
logger.info(f"✅ Found x-custom-header: {headers['x-custom-header']}")
63+
else:
64+
logger.warning("⚠️ x-custom-header not found in request headers")
65+
else:
66+
logger.error("❌ No request headers forwarded!")
67+
68+
logger.info(f"=== END EVENT ===")
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "s030-header-test"
7+
version = "0.1.0"
8+
description = "Test agent for validating header forwarding from backend to agent"
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
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
agentex-sdk
2+
scale-gp
3+
uvicorn[standard]

0 commit comments

Comments
 (0)