Skip to content

Commit 815c14b

Browse files
committed
update README files
1 parent c157941 commit 815c14b

5 files changed

Lines changed: 159 additions & 56 deletions

File tree

openai_agents/README.md

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,66 +21,20 @@ This approach ensures that AI agent workflows are durable, observable, and can h
2121
- Required dependencies installed via `uv sync --group openai-agents`
2222
- OpenAI API key set as environment variable: `export OPENAI_API_KEY=your_key_here`
2323

24-
## Running the Examples
24+
## Examples
2525

26-
1. **Start the worker** (supports all samples):
27-
```bash
28-
uv run openai_agents/basic/run_worker.py
29-
```
26+
Each directory contains a complete example with its own README for detailed instructions:
3027

31-
2. **Run individual samples** in separate terminals:
28+
### [Basic Examples](./basic/README.md)
29+
Simple agent examples including a hello world agent and a tools-enabled agent that can access external APIs like weather services.
3230

33-
### Basic Agent Examples
31+
### [Agent Patterns](./agent_patterns/README.md)
32+
Advanced patterns for agent composition, including using agents as tools within other agents.
3433

35-
- **Hello World Agent** - Simple agent that responds in haikus:
36-
```bash
37-
uv run openai_agents/basic/run_hello_world_workflow.py
38-
```
34+
### [Research Bot](./research_bot/README.md)
35+
Multi-agent research system with specialized roles: a planner agent, search agent, and writer agent working together to conduct comprehensive research.
3936

40-
- **Tools Agent** - Agent with access to external tools (weather API):
41-
```bash
42-
uv run openai_agents/basic/run_tools_workflow.py
43-
```
44-
45-
### Agent Patterns
46-
47-
Start the worker:
48-
49-
```bash
50-
uv run openai_agents/agent_patterns/run_worker.py
51-
```
52-
53-
- **Agents as Tools** - Demonstrate using agents as tools within other agents:
54-
55-
```bash
56-
uv run openai_agents/agent_patterns/run_agents_as_tools_workflow.py
57-
```
58-
59-
### Advanced Multi-Agent Examples
60-
61-
- **Research Workflow** - Multi-agent research system with specialized roles:
62-
63-
Start the worker:
64-
65-
```bash
66-
uv run openai_agents/research_bot/run_worker.py
67-
```
68-
69-
```bash
70-
uv run openai_agents/research_bot/run_research_workflow.py
71-
```
72-
Features a planner agent, search agent, and writer agent working together.
73-
74-
- **Customer Service Workflow** - Customer service agent with escalation capabilities (interactive):
75-
76-
Start the worker:
77-
78-
```bash
79-
uv run openai_agents/customer_service/run_worker.py
80-
```
81-
82-
```bash
83-
uv run openai_agents/customer_service/run_customer_service_client.py --conversation-id my-conversation-123
84-
```
37+
### [Customer Service](./customer_service/README.md)
38+
Interactive customer service agent with escalation capabilities, demonstrating conversational workflows.
8539

8640

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Agent Patterns
2+
3+
Common agentic patterns extended with Temporal's durable execution capabilities.
4+
5+
*Adapted from [OpenAI Agents SDK agent patterns](https://github.com/openai/openai-agents-python/tree/main/examples/agent_patterns)*
6+
7+
## Running the Examples
8+
9+
First, start the worker (supports all patterns):
10+
```bash
11+
uv run openai_agents/agent_patterns/run_worker.py
12+
```
13+
14+
Then run individual examples in separate terminals:
15+
16+
## Deterministic Flows
17+
18+
**TODO**
19+
20+
A common tactic is to break down a task into a series of smaller steps. Each task can be performed by an agent, and the output of one agent is used as input to the next. For example, if your task was to generate a story, you could break it down into the following steps:
21+
22+
1. Generate an outline
23+
2. Generate the story
24+
3. Generate the ending
25+
26+
Each of these steps can be performed by an agent. The output of one agent is used as input to the next.
27+
28+
## Handoffs and Routing
29+
30+
**TODO**
31+
32+
In many situations, you have specialized sub-agents that handle specific tasks. You can use handoffs to route the task to the right agent.
33+
34+
For example, you might have a frontline agent that receives a request, and then hands off to a specialized agent based on the language of the request.
35+
36+
## Agents as Tools
37+
38+
The mental model for handoffs is that the new agent "takes over". It sees the previous conversation history, and owns the conversation from that point onwards. However, this is not the only way to use agents. You can also use agents as a tool - the tool agent goes off and runs on its own, and then returns the result to the original agent.
39+
40+
For example, you could model a translation task as tool calls instead: rather than handing over to the language-specific agent, you could call the agent as a tool, and then use the result in the next step. This enables things like translating multiple languages at once.
41+
42+
```bash
43+
uv run openai_agents/agent_patterns/run_agents_as_tools_workflow.py
44+
```
45+
46+
## LLM-as-a-Judge
47+
48+
**TODO**
49+
50+
LLMs can often improve the quality of their output if given feedback. A common pattern is to generate a response using a model, and then use a second model to provide feedback. You can even use a small model for the initial generation and a larger model for the feedback, to optimize cost.
51+
52+
For example, you could use an LLM to generate an outline for a story, and then use a second LLM to evaluate the outline and provide feedback. You can then use the feedback to improve the outline, and repeat until the LLM is satisfied with the outline.
53+
54+
## Parallelization
55+
56+
**TODO**
57+
58+
Running multiple agents in parallel is a common pattern. This can be useful for both latency (e.g. if you have multiple steps that don't depend on each other) and also for other reasons e.g. generating multiple responses and picking the best one.
59+
60+
## Guardrails
61+
62+
**TODO**
63+
64+
Related to parallelization, you often want to run input guardrails to make sure the inputs to your agents are valid. For example, if you have a customer support agent, you might want to make sure that the user isn't trying to ask for help with a math problem.
65+
66+
You can definitely do this without any special Agents SDK features by using parallelization, but we support a special guardrail primitive. Guardrails can have a "tripwire" - if the tripwire is triggered, the agent execution will immediately stop and a `GuardrailTripwireTriggered` exception will be raised.
67+
68+
This is really useful for latency: for example, you might have a very fast model that runs the guardrail and a slow model that runs the actual agent. You wouldn't want to wait for the slow model to finish, so guardrails let you quickly reject invalid inputs.

openai_agents/basic/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Basic Agent Examples
2+
3+
Simple examples to get started with OpenAI Agents SDK integrated with Temporal workflows.
4+
5+
*Adapted from [OpenAI Agents SDK basic examples](https://github.com/openai/openai-agents-python/tree/main/examples/basic)*
6+
7+
## Running the Examples
8+
9+
First, start the worker (supports all basic examples):
10+
```bash
11+
uv run openai_agents/basic/run_worker.py
12+
```
13+
14+
Then run individual examples in separate terminals:
15+
16+
### Hello World Agent
17+
```bash
18+
uv run openai_agents/basic/run_hello_world_workflow.py
19+
```
20+
21+
### Tools Agent
22+
Agent with access to external tools (weather API):
23+
```bash
24+
uv run openai_agents/basic/run_tools_workflow.py
25+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Customer Service
2+
3+
Interactive customer service agent with escalation capabilities, extended with Temporal's durable conversational workflows.
4+
5+
*Adapted from [OpenAI Agents SDK customer service](https://github.com/openai/openai-agents-python/tree/main/examples/customer_service)*
6+
7+
This example demonstrates how to build persistent, stateful conversations where each conversation maintains state across multiple interactions and can survive system restarts and failures.
8+
9+
## Running the Example
10+
11+
First, start the worker:
12+
```bash
13+
uv run openai_agents/customer_service/run_worker.py
14+
```
15+
16+
Then start a customer service conversation:
17+
```bash
18+
uv run openai_agents/customer_service/run_customer_service_client.py --conversation-id my-conversation-123
19+
```
20+
21+
You can start a new conversation with any unique conversation ID, or resume existing conversations by using the same conversation ID. The conversation state is persisted in the Temporal workflow, allowing you to resume conversations even after restarting the client.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Research Bot
2+
3+
Multi-agent research system with specialized roles, extended with Temporal's durable execution.
4+
5+
*Adapted from [OpenAI Agents SDK research bot](https://github.com/openai/openai-agents-python/tree/main/examples/research_bot)*
6+
7+
## Architecture
8+
9+
The flow is:
10+
11+
1. User enters their research topic
12+
2. `planner_agent` comes up with a plan to search the web for information. The plan is a list of search queries, with a search term and a reason for each query.
13+
3. For each search item, we run a `search_agent`, which uses the Web Search tool to search for that term and summarize the results. These all run in parallel.
14+
4. Finally, the `writer_agent` receives the search summaries, and creates a written report.
15+
16+
## Running the Example
17+
18+
First, start the worker:
19+
```bash
20+
uv run openai_agents/research_bot/run_worker.py
21+
```
22+
23+
Then run the research workflow:
24+
```bash
25+
uv run openai_agents/research_bot/run_research_workflow.py
26+
```
27+
28+
## Suggested Improvements
29+
30+
If you're building your own research bot, some ideas to add to this are:
31+
32+
1. Retrieval: Add support for fetching relevant information from a vector store. You could use the File Search tool for this.
33+
2. Image and file upload: Allow users to attach PDFs or other files, as baseline context for the research.
34+
3. More planning and thinking: Models often produce better results given more time to think. Improve the planning process to come up with a better plan, and add an evaluation step so that the model can choose to improve its results, search for more stuff, etc.
35+
4. Code execution: Allow running code, which is useful for data analysis.

0 commit comments

Comments
 (0)