AI Agents & RAG60 minutes
Pipeline Repair Agent
Build the approval-gated step function of a repair agent.
Python
Task
Build a LangGraph agent that investigates a failed DAG, repairs its source code, runs checks, and prepares a merge request.
Requirements
- Return a new state with status, steps, pending, observations, answer, seen; never mutate input. max_steps is an integer from 1 to 20, not a boolean. Invalid values raise ValueError containing max_steps. done and stopped states are unchanged.
- Only ready accepts a decision event; otherwise raise ValueError containing pending. A tool action contains {type: "tool", id, name, arguments}. Allow inspect_dag, read_logs, read_file, apply_patch, run_checks, and open_merge_request. Require a nonblank unused string ID and dictionary arguments; otherwise raise ValueError containing action. Store only id, name, arguments in pending, append id to seen, and increment steps. Reads and checks set tool_pending. apply_patch and open_merge_request set awaiting_approval.
- Before scheduling open_merge_request, require a previous run_checks observation whose result has passed: true and revision equal to action.arguments.revision. Otherwise raise ValueError containing checks. The supplied tool also rechecks the current workspace revision before publishing; a past passing test is not enough after a new edit.
- An approval event contains call_id and approved (a boolean). Only the exact pending call in awaiting_approval can be approved. Reject stale IDs, wrong states, or nonboolean approval values with ValueError containing approval. Approval cannot replace tool arguments. True sets tool_pending. False returns ready, clears pending, and records {call_id, name, result: {error: "approval_denied"}}. Approval consumes no model step.
- A tool_result event contains call_id and a dictionary result. Only the matching pending call in tool_pending can finish; otherwise raise ValueError containing call_id. Append {call_id, name, result}, clear pending, and return ready. Results already in observations are unchanged replays. Failed checks remain observations so the agent can repair and test again.
- A final action is {type: "final", text}; require nonblank text or raise ValueError containing action. Store {text}, add one step, set done. Before accepting any decision, stop and clear pending if steps >= max_steps. Unknown event types raise ValueError containing event. This function schedules work; it must not read files, run commands, call a model, or publish an MR.
How you are graded
- Decomposition 15%
- Prompting the assistant 10%
- Verification 20%
- Judgment about AI output 20%
- Correctness 25%
- Communication 10%
Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard
Interview guidance
This agent repairs a failed data pipeline and prepares a merge request, with a human approving every patch and the MR. You are writing the orchestration step. Use the assistant freely; I want to hear you reason about which approvals and checks it could bypass, and see you test those paths, not only the happy path.
- AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
- You are graded on how you drive and check the AI, not on how much you prompt.
- Run the checks; read what fails.
- A new requirement will arrive partway through.
- Too little AI use is reported as “not enough to grade”, never as a fail.
You will answer 7 debrief questions at the end
- What did you delegate to the AI, and why?
- Name one AI suggestion you rejected or changed, and why.
- Choose one block the AI helped write. Explain what each line does and which test verifies it.
- What is still risky, and what would you test or ship next?
- Which path did the assistant's first validation accept that it should have refused, if any? How did you find it?
- How do you prove that the MR contains the same revision that passed checks after the latest patch?
- What happens if GitLab accepts the MR but the request times out before the agent receives the response?