Skip to content

Commit 29f4051

Browse files
committed
Instructions for lab 17
1 parent e986e2a commit 29f4051

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def run(session_id, job_id):
225225
agent = orchestrator_agent
226226
while user_input != 'bye':
227227
result = Runner.run_sync(agent, user_input, session=session, max_turns=20)
228+
agent = result.last_agent
228229
print(result.final_output)
229230
user_input = input("User: ")
230231

labs/17-debugging.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Lab 17: Debugging
2+
3+
When we run the agent, we see that it only asks one question about a skill. Then it goes on to the next skill.
4+
5+
In this lab, we are going to use `mitmproxy` to see what exactly open ai agents SDK is doing, and use that to debug our agent.
6+
7+
## Setting up mitmproxy
8+
9+
1. Install `mitmproxy` - https://www.mitmproxy.org/
10+
1. Then, open terminal and run this command: `pip install -U certifi`
11+
1. If you are on windows, additionally run `pip install -U python-certifi-win32`
12+
1. Open a terminal and run `mitmweb` to start the web interface
13+
1. Configure the proxy settings to point to host `127.0.0.1` and port `8080`. In windows this is in `Settings -> Network & Internet -> Proxy -> Manual Proxy Setup`
14+
1. Open the browser and go to `http://mitm.it`
15+
1. Follow the instructions there to configure the certificates for your operating system
16+
1. Go to any site like `https://www.google.com`. It should show the page on the browser
17+
1. You should be able to see the flow on the mitm dashboard
18+
19+
## High Level Overview
20+
21+
This is how the system is supposed to behave:
22+
23+
Orchestrator Agent
24+
- Extract Skills
25+
- User to say "start"
26+
- Get next skill to evaluate
27+
- Hand off to Evaluator Agent
28+
29+
Evaluator Agent
30+
- get question from tool
31+
- Ask question
32+
- User to answer
33+
- check answer from tool
34+
- Repeat for question 2 and 3
35+
- Hand off to Orchestrator Agent
36+
37+
Orchestrator Agent
38+
- Update database with evaluation result
39+
- Repeat for skill 2 and 3
40+
- Return `{"status": "done"}`
41+
42+
1. Start `mitmproxy`
43+
1. Run the agent
44+
1. See the requests that Agents SDK is making to the API
45+
1. Identify what is going wrong
46+
1. Fix the code
47+
1. Run the agent
48+
49+
## Hints
50+
51+
### What is the problem in the code?
52+
53+
<details>
54+
<summary>Answer</summary>
55+
56+
If you see the request in mitmproxy you will notice that when the evaluation agent asks the question and the user replies, the code is running the orchestrator agent with the answer.
57+
58+
The answer is supposed to be processed by the evaluator agent
59+
</details>
60+
61+
### How do I make the fix?
62+
63+
<details>
64+
<summary>Answer</summary>
65+
66+
Add the line `agent = result.last_agent` after the `run_sync` call. This will ensure that the next time we will continue conversation with the agent that replied previously
67+
68+
```python
69+
result = Runner.run_sync(agent, user_input, session=session, max_turns=20)
70+
agent = result.last_agent
71+
```
72+
</details>

0 commit comments

Comments
 (0)