|
| 1 | +# {{ agent_name }} - AgentEx Async OpenAI Agents SDK Agent |
| 2 | + |
| 3 | +This template builds an **asynchronous** (non-Temporal) agent built on the |
| 4 | +**OpenAI Agents SDK**, delivered through the unified harness surface on AgentEx: |
| 5 | +- Defines an OpenAI Agents SDK `Agent` (with an example weather tool) inline in |
| 6 | + `acp.py` |
| 7 | +- Wraps the SDK run in an `OpenAITurn` |
| 8 | +- Delivers canonical `StreamTaskMessage*` events via `UnifiedEmitter.auto_send_turn` |
| 9 | + (the async Redis push path), so the UI receives output in real time |
| 10 | +- Tracing integration to SGP / AgentEx |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- An `OPENAI_API_KEY` in your environment (or a `LITELLM_API_KEY`, which is |
| 15 | + copied to `OPENAI_API_KEY` for LiteLLM-proxy compatibility) |
| 16 | + |
| 17 | +## Running the Agent |
| 18 | + |
| 19 | +```bash |
| 20 | +agentex agents run --manifest manifest.yaml |
| 21 | +``` |
| 22 | + |
| 23 | +## Project Structure |
| 24 | + |
| 25 | +``` |
| 26 | +{{ project_name }}/ |
| 27 | +├── project/ |
| 28 | +│ ├── __init__.py |
| 29 | +│ └── acp.py # ACP server, agent + tool definitions, event handlers |
| 30 | +├── Dockerfile |
| 31 | +├── manifest.yaml |
| 32 | +├── dev.ipynb |
| 33 | +{% if use_uv %} |
| 34 | +└── pyproject.toml |
| 35 | +{% else %} |
| 36 | +└── requirements.txt |
| 37 | +{% endif %} |
| 38 | +``` |
| 39 | + |
| 40 | +## Key Concepts |
| 41 | + |
| 42 | +### Async ACP with the harness |
| 43 | +The async ACP model streams events over Redis instead of an HTTP response. The |
| 44 | +`@acp.on_task_event_send` handler runs the OpenAI Agents SDK and pushes the |
| 45 | +harness events to the task stream. |
| 46 | + |
| 47 | +### The unified harness surface |
| 48 | +`OpenAITurn` + `UnifiedEmitter` are the unified harness surface. The turn |
| 49 | +normalizes the SDK's streamed run into canonical AgentEx events; the emitter |
| 50 | +traces and delivers them. |
| 51 | + |
| 52 | +## Development |
| 53 | + |
| 54 | +### 1. Add Your Own Tools |
| 55 | +Define new `@function_tool` functions in `project/acp.py` and add them to the |
| 56 | +agent's `tools=[...]` list in `create_agent()`. |
| 57 | + |
| 58 | +### 2. Customize the Agent |
| 59 | +Edit `MODEL_NAME` and `INSTRUCTIONS` in `project/acp.py` to change the model or |
| 60 | +system prompt. |
| 61 | + |
| 62 | +### 3. Configure Credentials |
| 63 | +Set your credentials via `manifest.yaml`, an exported environment variable, or a |
| 64 | +`.env` file in the project directory. |
| 65 | + |
| 66 | +### 4. Run Locally |
| 67 | +```bash |
| 68 | +export ENVIRONMENT=development && agentex agents run --manifest manifest.yaml |
| 69 | +``` |
0 commit comments