OpenHands Agent Loop: run() and step()

OpenHands Agent Loop: run() and step() A workflow diagram generated by Archify. 01 / LocalConversation 02 / Agent.step 03 / Tool execution EX / Recovery + policy Intake + guard Context + model Act + observe send_message() · MessageEvent + skills · LocalConversation › Intake + guard send_message() MessageEvent + skills run() iteration · status, stuck, budget · LocalConversation › Intake + guard · state lock run() iteration status, stuck, budget state lock FINISHED · stop hooks may veto · LocalConversation › Act + observe FINISHED stop hooks may veto Unmatched actions? · confirmed batch first · Agent.step › Intake + guard Unmatched actions? confirmed batch first Condense view · prepare_llm_messages · Agent.step › Context + model Condense view prepare_llm_messages llm.generate() · messages + tool schemas · Agent.step › Context + model llm.generate() messages + tool schemas classify_response · tools / text / empty · Agent.step › Act + observe classify_response tools / text / empty ActionEvent · parse, normalize, validate · Tool execution › Act + observe ActionEvent parse, normalize, validate Execute batch · ObservationEvent / error · Tool execution › Act + observe Execute batch ObservationEvent / error Condensation event · step returns early · Recovery + policy › Context + model Condensation event step returns early Error mapping · nudge or CondensationRequest · Recovery + policy › Context + model Error mapping nudge or CondensationRequest Await confirmation · WAITING_FOR_CONFIRMATION · Recovery + policy › Act + observe Await confirmation WAITING_FOR_CONFIRMATION text tool calls over budget View finish tool agent.step() raises none needs OK Legend Agent logic Policy Tool action Cloud service External system