Robert Brennan 94a8f58ece fix up logging in listen.py (#5145) há 1 ano atrás
..
agenthub 07b96cc8c9 docs: Add documentation on how to add new tools to codeact_agent (#5150) há 1 ano atrás
controller c9ed9b166b handle exceptions more explicitly (#4971) há 1 ano atrás
core 3a65b7b07d docs: add missing toml_file parameter description in get_llm_config_a… (#5147) há 1 ano atrás
events f55ddbed0e fix docker leak (#4970) há 1 ano atrás
linter 97f3249205 Move linter and diff utils to openhands-aci (#5020) há 1 ano atrás
llm 746722e1b5 style: remove extra newline in LLM wrapper function (#5149) há 1 ano atrás
memory eeb2342509 Refactor history/event stream (#3808) há 1 ano atrás
resolver 7f5022c8fe Refactor issue filtering (#5129) há 1 ano atrás
runtime cde7ce49be fix up lockup when long actions are run (#5144) há 1 ano atrás
security 436ecb80a3 Logger fixes for openhands-resolver (#4710) há 1 ano atrás
server 94a8f58ece fix up logging in listen.py (#5145) há 1 ano atrás
storage 641a15356f Better AWS S3 storage support (#4195) há 1 ano atrás
utils 97f3249205 Move linter and diff utils to openhands-aci (#5020) há 1 ano atrás
README.md dc0a1f3940 Fix wrong doc url (#3531) há 1 ano atrás
__init__.py 4405b109e3 Fix issue #4809: [Bug]: Model does not support image upload when usin… (#4810) há 1 ano atrás
py.typed 6ce77e157b Fix pypi build (#3548) há 1 ano atrás

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.