The agent
folder contains the logic for handling model inference and facilitating their interaction with SWEEnv
.
The following documentation describing the purpose and classes of each file.
This file defines the Agent
class, which facilitates the interaction between an agent and the environment. The AgentConfig
and AgentArguments
data classes compile all arguments into a single file.
Agent
: Main class for handling model behavior + interaction with environment__init__
: Sets up model, assistant, configurations, and argumentsstate_command
: Getter for bash command for extracting env. statesetup
: Resets cost stats, initializes system message (+ demonstrations), and returns full list of bash commands to define within environment.forward
: Main inference call to model.forward_model
: Determines appropriate observation template, then makes inference call to modelforward_with_format_check
: Invokesforward_model
, with retry calls to handle blocked or malformed actions.forward_with_error_check
: Wrapsforward_with_format_check
with exception handling.
This file defines the abstraction for custom commands (non-native functions that are implemented in bash) that agents can invoke in swe-agent
environment. On top of the abstraction, helper functions to extract commands' documentation and compile .sh
files into separate Command
objects are provided. There are also fields for establishing the input/output of each action and control flow of actions via templates.
AssistantMetadata
: Defines templates for formatting input/output to sub-assistant callsCommand
: Defines fields of a custom commandControlMetadata
(WIP): Defines template fields that format the observations for the next agentforward
inference callgenerate_command_docs
: Extracts docstrings from each command to form comprehensive documentation.parse_command_file
: Converts bash file content to separateCommand
objects
This file defines the abstraction for running inference on API models. In addition, the BaseModel
abstraction also defines a set of cost-related fields for tracking instance-level and total expenses accumulated across a single model run.
AnthropicModel
: Handles inference + cost logging for Anthropic ModelsBedrockModel
: handles inference + cost logging for Amazon Bedrock-provided models (Anthropic Claude only)APIStats
: Cost tracking fields that are updated per model inferenceBaseModel
: Abstract class that defines the common logic for updating cost statsget_model
: Returns initialized[Anthropic|Bedrock|Human|OpenAI]Model
based on given arguments + commandsHumanModel
: Handles inference for human task workerModelArguments
: Model name, hyperparameter, and cost limit argumentsOpenAIModel
: Handles inference + cost logging for OpenAI models
This file defines the abstraction for parsing the output of the model inference. The Parsing
class is used to extract the relevant information from the model's output and format it into a response that can be used by the Agent
class.
Parsing
: Abstract class that defines the common logic for parsing model output
This file defines the abstraction for processing the history of the environment. The HistoryProcessor
class is used to extract the relevant information from the history of the environment and format it into a response that can be used by the Agent
class.
HistoryProcessor
: Abstract class that defines the common logic for processing the history of the environmentDefaultHistoryProcessor
: Default implementation ofHistoryProcessor
that processes the history of the environment
- To skip over a task instance, use the
skip
keyword - To submit for evaluation, use the
submit
keyword - To exit the
SWEEnv
environment, perform a keyboard interrupt (^ c
)