Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
AI, ML & LLMSeniorSpecialistTroubleshooting

An agent keeps rerunning the same failing test and editing the same line. How do you diagnose it and stop it from looping?

Answer

Confirm the loop in the trace: the same tool with the same arguments, the same error and repeated edits to one file. Then find why the feedback does not help: an unhelpful error message, a wrong test, an environment problem such as a missing service, or a wrong hypothesis the agent never revisits. Fix the harness on two levels: hard limits on turns, time, tokens or cost, and a loop detector that injects a 'step back and re-read the failure' message after repeated identical calls or edits, then stops and hands over to a person with a summary. Add the case to the evaluation set.

Strong answer includes

  • confirms the repetition from traces instead of guessing
  • looks for why the feedback is uninformative, including test and environment causes
  • adds hard budgets plus a loop detector that redirects and then stops
  • hands over to a person with a summary and keeps the case for evaluation

Practical example

A trace shows twelve edits to `checkout.py` with the same `ConnectionRefusedError` each time. The test needs a local payment stub that never started, so no code change could fix it. The team makes the start script check the stub, and the harness now stops after three identical failures with the message 'environment error, not a code error: check service stubs'.

#agent-harness#agent-loop#triage#ai-qa

Sources

What is asked in a Harness Engineer interview?Outcome School · Round-by-round harness-engineer interview: the agent loop, stopping criteria, loop detection, self-correction through tests, evaluating harness changes and designing a team harnessAI Agent & Agentic AI Interview Questions with Answerslabuladong · Frequently asked agent-engineering interview questions, including harness engineering, coding agents, loop termination and agent evaluationImproving Deep Agents with harness engineeringLangChain · Harness-only changes with a fixed model on Terminal Bench 2.0: verification before finishing, loop detection, time budgets and the risk of overfitting harness changes