DefaultAgent
Understanding the control flow
Check out the control flow guide for a visual explanation of the agent's control flow following this picture:
minisweagent.agents.default.AgentConfig
dataclass
AgentConfig(
system_template: str = "You are a helpful assistant that can do anything.",
instance_template: str = "Your task: {{task}}. Please reply with a single shell command in triple backticks. To finish, the first line of the output of the shell command must be 'MINI_SWE_AGENT_FINAL_OUTPUT'.",
timeout_template: str = "The last command <command>{{action['action']}}</command> timed out and has been killed.\nThe output of the command was:\n <output>\n{{output}}\n</output>\nPlease try another command and make sure to avoid those requiring interactive input.",
format_error_template: str = "Please always provide EXACTLY ONE action in triple backticks.",
action_observation_template: str = "Observation: {{output}}",
step_limit: int = 0,
cost_limit: float = 3.0,
)
system_template
class-attribute
instance-attribute
system_template: str = (
"You are a helpful assistant that can do anything."
)
instance_template
class-attribute
instance-attribute
instance_template: str = "Your task: {{task}}. Please reply with a single shell command in triple backticks. To finish, the first line of the output of the shell command must be 'MINI_SWE_AGENT_FINAL_OUTPUT'."
timeout_template
class-attribute
instance-attribute
timeout_template: str = "The last command <command>{{action['action']}}</command> timed out and has been killed.\nThe output of the command was:\n <output>\n{{output}}\n</output>\nPlease try another command and make sure to avoid those requiring interactive input."
format_error_template
class-attribute
instance-attribute
format_error_template: str = "Please always provide EXACTLY ONE action in triple backticks."
action_observation_template
class-attribute
instance-attribute
action_observation_template: str = "Observation: {{output}}"
step_limit
class-attribute
instance-attribute
step_limit: int = 0
cost_limit
class-attribute
instance-attribute
cost_limit: float = 3.0
minisweagent.agents.default.DefaultAgent
DefaultAgent(
model: Model,
env: Environment,
*,
config_class: Callable = AgentConfig,
**kwargs,
)
Source code in src/minisweagent/agents/default.py
59 60 61 62 63 |
|
config
instance-attribute
config = config_class(**kwargs)
messages
instance-attribute
messages: list[dict] = []
model
instance-attribute
model = model
env
instance-attribute
env = env
render_template
render_template(template: str, **kwargs) -> str
Source code in src/minisweagent/agents/default.py
65 66 67 |
|
add_message
add_message(role: str, content: str)
Source code in src/minisweagent/agents/default.py
69 70 |
|
run
run(task: str) -> tuple[str, str]
Run step() until agent is finished. Return exit status & message
Source code in src/minisweagent/agents/default.py
72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
step
step() -> dict
Query the LM, execute the action, return the observation.
Source code in src/minisweagent/agents/default.py
86 87 88 |
|
query
query() -> dict
Query the model and return the response.
Source code in src/minisweagent/agents/default.py
90 91 92 93 94 95 96 |
|
get_observation
get_observation(response: dict) -> dict
Execute the action and return the observation.
Source code in src/minisweagent/agents/default.py
98 99 100 101 102 103 |
|
parse_action
parse_action(response: dict) -> dict
Parse the action from the message. Returns the action.
Source code in src/minisweagent/agents/default.py
105 106 107 108 109 110 |
|
execute_action
execute_action(action: dict) -> dict
Source code in src/minisweagent/agents/default.py
112 113 114 115 116 117 118 119 120 121 122 123 |
|
has_finished
has_finished(output: dict[str, str])
Raises Submitted exception with final output if the agent has finished its task.
Source code in src/minisweagent/agents/default.py
125 126 127 128 129 |
|
minisweagent.agents.default.NonTerminatingException
Bases: Exception
Raised for conditions that can be handled by the agent.
minisweagent.agents.default.TerminatingException
Bases: Exception
Raised for conditions that terminate the agent.