OpenAI Agents SDK · Chapter 24 of 24
Interview round
By the end of this chapter you have answered five timed questions, one idea each, from across the whole lab: reading what a run did, stopping a loop that never ends, letting the server keep a conversation, a guardrail on one tool, and tools that each student sees or does not. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.
- Part: Production
- 5 tasks
- Python
- In the all labs plan
The first 2 chapters of OpenAI Agents SDK are free. This one comes with the all labs plan.
Why you need this
The helpdesk is live, and Shikhar is hiring a second AI engineer. Karthik runs the interviews. "Short problems, ten minutes each. I am not checking that you remember the SDK's names; the docs have them. I am checking that you know what each piece does inside, and that you look at what really reached the model before you guess." Kavita liked the idea so much that the round is now the last chapter of the lab.
Each question is one idea from an earlier chapter, with no hand-holding: the file has the goal, the check has the edge cases. Below is a refresher of each idea, with what an interviewer listens for. The answers are not here.
What you build: 5 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1 · interview question
Interview: trail.py, what the model asked for
Time yourself: 10 minutes. Write tool_trail(result): given a run's result, return every tool call and every handoff the model asked for during the run, in order, as a list of (name, arguments as a dictionary) tuples; an empty list when it called none.
The check runs its own agents (a triage that hands off to a fees desk, a desk asked about two students, and an agent with no tools) and compares your list with the calls in the lab model's log. The interviewer will ask: who ran these tools, the model or your code?
- Task 2 · interview question
Interview: loop_guard.py, a loop that never ends
Time yourself: 10 minutes. Write safe_answer(agent, question): run the agent on the question with at most 4 turns and return the final output; when the run is stopped for too many turns, return exactly Sorry, that is taking too long. Bhanu will call you. (the SORRY text in the starter). Catch only that error: a model that is down must still raise its own error.
The check gives you an agent on lab-chat-loopy (it asks for the same tool forever), one on lab-chat and one on lab-chat-down. The interviewer will ask: what stops a loop that never ends, and why is a limit not enough on its own?
- Task 3 · interview question
Interview: follow_up.py, where the conversation lives
Time yourself: 10 minutes. Write follow_up(agent, first, second): run the agent on the first message, then run it on the second as a follow-up that sends only the new message and the first run's last response id, so the server keeps the conversation. Return the second run's final output.
The check reads both requests from the lab model's log. The interviewer will ask: where does the conversation live now, and what happens when the server no longer has it?
- Task 4 · interview question
Interview: own_results.py, only your own results
Time yourself: 10 minutes. Write ask(student_id, message): run an agent for lab-chat named Academic desk, with the instructions You are Shikhar Classes' academic desk. Use the tools. and the student as the run's context (a dataclass Student with student_id), and return the final output. Its one tool, test_results(student_id), returns json.dumps of shikhar.test_results. A tool input guardrail on it lets a call for the student in the context run, and rejects any other call with exactly the REFUSAL text in the starter.
The check asks as S2033, for S2033's own result and for S2008's. The interviewer will ask: why a guardrail on the tool, and not a line in the instructions?
- Task 5 · interview question
Interview: hostel_only.py, tools per student
Time yourself: 10 minutes. Write ask(student_id, message): run an agent for lab-chat with the instructions You are Shikhar Classes' helpdesk assistant. Use the tools. and the student as the run's context (a dataclass Student with student_id), and return the final output. Two tools, each returning json.dumps of shikhar's function: fee_status(student_id) for every student, and find_hostel_beds(gender, ac) only for students with a hostel bed (shikhar.get_student's hostel_bed is not None).
The check asks four students, two with a hostel bed and two without, and reads which tools each request offered. The interviewer will ask: why do fewer tools help, and what does the model say to a student it can no longer look up beds for?
What you will learn
- How to work a timed question: say the plan, build the smallest thing that runs, then look at the requests.
- Five ideas again, at interview depth: a run's items (chapters 4, 6 and 8), max_turns (6 and 19), previous_response_id (14), tool guardrails (11) and tools per student (16).
More in Production
Build "Interview round" yourself
Shikhar Classes, a Kota coaching institute, answers parents and students on WhatsApp all day. You build its helpdesk assistant. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.
The first 2 chapters of OpenAI Agents SDK are free. This one comes with the all labs plan.