OpenHands 4998b5de32 Fix issue #5559: The turn limit should be measured from the last user interaction (#5560) 11 bulan lalu
..
agenthub ad822a31e1 Fix issue #5591: Clean up unused code (#5592) 11 bulan lalu
controller 4998b5de32 Fix issue #5559: The turn limit should be measured from the last user interaction (#5560) 11 bulan lalu
core b295f5775c Revert "Fix issue #5609: Use litellm's modify_params with default True" (#5631) 11 bulan lalu
events 6a6ce5f3ee Fix issue #5478: Add color to the line next to "Ran a XXX Command" based on return value (#5483) 1 tahun lalu
linter 97f3249205 Move linter and diff utils to openhands-aci (#5020) 1 tahun lalu
llm b295f5775c Revert "Fix issue #5609: Use litellm's modify_params with default True" (#5631) 11 bulan lalu
memory ac5190c283 Add voyage ai embeddings (#5547) 1 tahun lalu
resolver 6de177521f Fix issue #5450: In openhands-resolver.yml, request code review from the person who initiated the workflow (#5451) 1 tahun lalu
runtime e0b231092a feat: support directly stream logs from container to stdout in debug mode (#5408) 11 bulan lalu
security 871c544b74 fix: asyncio issues with security analyzer + enable security analyzer in cli (#5356) 1 tahun lalu
server dd79acdae1 Fix vscode url fetch regression (#5632) 11 bulan lalu
storage c7d89713e8 Feat socket io (#5056) 1 tahun lalu
utils 2fb45d410d Fix: Making the logs quieter (#5525) 1 tahun lalu
README.md dc0a1f3940 Fix wrong doc url (#3531) 1 tahun lalu
__init__.py ceb60b9a37 Prioritize version from pyproject.toml (#5412) 1 tahun lalu
py.typed 6ce77e157b Fix pypi build (#3548) 1 tahun lalu

README.md

OpenHands Architecture

This directory contains the core components of OpenHands.

This diagram provides an overview of the roles of each component and how they communicate and collaborate. OpenHands System Architecture Diagram (July 4, 2024)

Classes

The key classes in OpenHands are:

  • LLM: brokers all interactions with large language models. Works with any underlying completion model, thanks to LiteLLM.
  • Agent: responsible for looking at the current State, and producing an Action that moves one step closer toward the end-goal.
  • AgentController: initializes the Agent, manages State, and drive the main loop that pushes the Agent forward, step by step
  • State: represents the current state of the Agent's task. Includes things like the current step, a history of recent events, the Agent's long-term plan, etc
  • EventStream: a central hub for Events, where any component can publish Events, or listen for Events published by other components
    • Event: an Action or Observeration
      • Action: represents a request to e.g. edit a file, run a command, or send a message
      • Observation: represents information collected from the environment, e.g. file contents or command output
  • Runtime: responsible for performing Actions, and sending back Observations
    • Sandbox: the part of the runtime responsible for running commands, e.g. inside of Docker
  • Server: brokers OpenHands sessions over HTTP, e.g. to drive the frontend
    • Session: holds a single EventStream, a single AgentController, and a single Runtime. Generally represents a single task (but potentially including several user prompts)
    • SessionManager: keeps a list of active sessions, and ensures requests are routed to the correct Session

Control Flow

Here's the basic loop (in pseudocode) that drives agents.

while True:
  prompt = agent.generate_prompt(state)
  response = llm.completion(prompt)
  action = agent.parse_response(response)
  observation = runtime.run(action)
  state = state.update(action, observation)

In reality, most of this is achieved through message passing, via the EventStream. The EventStream serves as the backbone for all communication in OpenHands.

flowchart LR
  Agent--Actions-->AgentController
  AgentController--State-->Agent
  AgentController--Actions-->EventStream
  EventStream--Observations-->AgentController
  Runtime--Observations-->EventStream
  EventStream--Actions-->Runtime
  Frontend--Actions-->EventStream

Runtime

Please refer to the documentation to learn more about Runtime.