mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
* add replace-based block edit & preliminary test case fix
* further fix the insert behavior
* make edit only work on first occurence
* bump codeact version since we now use new edit agentskills
* update prompt for new agentskills
* update integration tests
* make run_infer.sh executable
* remove code block for edit_file
* update integration test for prompt changes
* default to not use hint for eval
* fix insert emptyfile bug
* throw value error when `to_replace` is empty
* make `_edit_or_insert_file` return string so we can try to fix some linter errors (best attempt)
* add todo
* update integration test
* fix sandbox test for this PR
* fix inserting with additional newline
* rename to edit_file_by_replace
* add back `edit_file_by_line`
* update prompt for new editing tool
* fix integration tests
* bump codeact version since there are more changes
* add back append file
* fix current line for append
* fix append unit tests
* change the location where we show edited line no to agent and fix tests
* update integration tests
* fix global window size affect by open_file bug
* fix global window size affect by open_file bug
* increase window size to 300
* add file beginning and ending marker to avoid looping
* expand the editor window to better display edit error for model
* refractor to breakdown edit to internal functions
* reduce window to 200
* move window to 100
* refractor to cleanup some logic into _calculate_window_bounds
* fix integration tests
* fix sandbox test on new prompt
* update demonstration with new changes
* fix integration
* initialize llm inside process_instance to circumvent "AttributeError: Can't pickle local object"
* update kwargs
* retry for internal server error
* fix max iteration
* override max iter from config
* fix integration tests
* remove edit file by line
* fix integration tests
* add instruction to avoid hanging
* Revert "add instruction to avoid hanging"
This reverts commit 06fd2c5938.
* handle content policy violation error
* fix integration tests
* fix typo in prompt - the window is 100
* update all integration tests
---------
Co-authored-by: Graham Neubig <neubig@gmail.com>
Co-authored-by: Xingyao Wang <xingyao@all-hands.dev>
OpenDevin Architecture
This directory contains the core components of OpenDevin.
This diagram provides an overview of the roles of each component and how they communicate and collaborate.
Classes
The key classes in OpenDevin 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
- Event: an Action or Observeration
- 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 OpenDevin 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 OpenDevin.
flowchart LR
Agent--Actions-->AgentController
AgentController--State-->Agent
AgentController--Actions-->EventStream
EventStream--Observations-->AgentController
Runtime--Observations-->EventStream
EventStream--Actions-->Runtime
Frontend--Actions-->EventStream
Runtime
The Runtime class is abstract, and has a few different implementations:
- We have a LocalRuntime, which runs commands and edits files directly on the user's machine
- We have a DockerRuntime, which runs commands inside of a docker sandbox, and edits files directly on the user's machine
- We have an E2BRuntime, which uses e2b.dev containers to sandbox file and command operations