One turn through SWE-agent
architecture node:
User input:
Representation at this boundary
Source modules
Loop map
One pass — problem statement → ACI assembly → prompt assembly →
LiteLLMModel.query() → action parse → heredoc guard + blocklist → SWEEnv.communicate() in the persistent container bash → observation into history. A synchronous while not step_output.done loop (agents.py:1240) — one model call, one command execution per step, and no step cap: the loop ends only on submit, exit, forfeit, error autosubmission, or cost/context/timeout limits.Per-attempt reviewer, not per-action —
RetryAgent.run() wraps whole DefaultAgent attempts with the environment hard-reset between them. A ScoreRetryLoop scores each submission 0–100ish with a reviewer LM (n_sample averaging) or a ChooserRetryLoop picks the best, retrying until accept / max_accepts / max_attempts / cost. Nothing ever scores or filters a single step — the name misleads, the code doesn't.Trajectory persistence —
save_trajectory() rewrites <instance_id>.traj every step: trajectory turns plus the full unprocessed history, info (submission, exit_status, model_stats, edited-files context, version hashes), replay_config, and the environment name. Partial runs stay inspectable and replayable; trajectories double as replay inputs and few-shot demonstrations. The next turn re-enters at step 3 with a rebuilt prompt.