For code execution, the prompt pipeline runs the generated script, captures any syntax/compile errors from stderr, and passes them back to the model with the instruction to fix the code, repeating this self-correction loop until the script runs successfully.
res = run_sandbox(code_payload)
if res.exit_code != 0: # 3. Feed error back fixed_code = call_llm(f""" Code crashed with error: {res.stderr} Fix this code: {code_payload} """) # 4. Re-run res_retry = run_sandbox(fixed_code)
Claude is highly efficient at reading tracebacks, identifying the exact line index and patching dependencies correctly.