Interactive
See also
- This agent subclass builds on top of the default agent, make sure to read that first.
- This class powers the
mini
command line tool, see usage for more details.
minisweagent.agents.interactive
A small generalization of the default agent that puts the user in the loop.
There are three modes: - human: commands issued by the user are executed immediately - confirm: commands issued by the LM but not whitelisted are confirmed by the user - yolo: commands issued by the LM are executed immediately without confirmation
console
module-attribute
console = Console(highlight=False)
prompt_session
module-attribute
prompt_session = PromptSession(
history=FileHistory(
global_config_dir / "interactive_history.txt"
)
)
InteractiveAgentConfig
dataclass
InteractiveAgentConfig(
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,
mode: Literal["human", "confirm", "yolo"] = "confirm",
whitelist_actions: list[str] = list(),
confirm_exit: bool = True,
)
Bases: AgentConfig
mode
class-attribute
instance-attribute
mode: Literal['human', 'confirm', 'yolo'] = 'confirm'
Whether to confirm actions.
whitelist_actions
class-attribute
instance-attribute
whitelist_actions: list[str] = field(default_factory=list)
Never confirm actions that match these regular expressions.
confirm_exit
class-attribute
instance-attribute
confirm_exit: bool = True
If the agent wants to finish, do we ask for confirmation from user?
InteractiveAgent
InteractiveAgent(*args, **kwargs)
Bases: DefaultAgent
Source code in src/minisweagent/agents/interactive.py
38 39 40 |
|
cost_last_confirmed
instance-attribute
cost_last_confirmed = 0.0
add_message
add_message(role: str, content: str)
Source code in src/minisweagent/agents/interactive.py
42 43 44 45 46 47 48 49 50 51 52 53 |
|
query
query() -> dict
Source code in src/minisweagent/agents/interactive.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
step
step() -> dict
Source code in src/minisweagent/agents/interactive.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
execute_action
execute_action(action: dict) -> dict
Source code in src/minisweagent/agents/interactive.py
91 92 93 94 95 |
|
should_ask_confirmation
should_ask_confirmation(action: str) -> bool
Source code in src/minisweagent/agents/interactive.py
97 98 |
|
ask_confirmation
ask_confirmation() -> None
Source code in src/minisweagent/agents/interactive.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
has_finished
has_finished(output: dict[str, str])
Source code in src/minisweagent/agents/interactive.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|