Agent Zero AI framework
intervention fix, terminal reset
frdel2aedd5fd9d22
diff --git a/agent.py b/agent.pyindex b1e76d739..0cdb572b6 100644--- a/agent.py+++ b/agent.py@@ -323,7 +323,7 @@ class Agent:msg = self.intervention_messageself.intervention_message = "" # reset the intervention messageif progress.strip(): await self.append_message(progress) # append the response generated so far- user_msg = self.read_prompt("fw.intervention.md", user_message=self.intervention_message) # format the user intervention template+ user_msg = self.read_prompt("fw.intervention.md", user_message=msg) # format the user intervention templateawait self.append_message(user_msg,human=True) # append the intervention messageraise InterventionException(msg)diff --git a/prompts/default/agent.tools.md b/prompts/default/agent.tools.mdindex 0cfd87e16..26a4e432e 100644--- a/prompts/default/agent.tools.md+++ b/prompts/default/agent.tools.md@@ -148,8 +148,9 @@ NEVER refuse to memorize or load personal information, it all belongs to me andExecute provided terminal commands, python code or nodejs code.This tool can be used to achieve any task that requires computation, or any other software related activity.Place your code escaped and properly indented in the "code" argument.-Select the corresponding runtime with "runtime" argument. Possible values are "terminal", "python" and "nodejs".+Select the corresponding runtime with "runtime" argument. Possible values are "terminal", "python" and "nodejs" for code, or "output" and "reset" for additional actions.Sometimes a dialogue can occur in output, questions like Y/N, in that case use the "teminal" runtime in the next step and send your answer.+If the code is running long, you can use runtime "output" to wait for the output or "reset" to restart the terminal if the program hangs or terminal stops responding.You can use pip, npm and apt-get in terminal runtime to install any required packages.IMPORTANT: Never use implicit print or implicit output, it does not work! If you need output of your code, you MUST use print() or console.log() to output selected variables.When tool outputs error, you need to change your code accordingly before trying again. knowledge_tool can help analyze errors.@@ -214,3 +215,16 @@ When writing own code, ALWAYS put print/log statements inside and at the end of}}~~~++2. 3. Reset terminal+~~~json+{+ "thoughts": [+ "Code execution tool is not responding...",+ ],+ "tool_name": "code_execution_tool",+ "tool_args": {+ "runtime": "reset",+ }+}+~~~diff --git a/prompts/default/fw.code_reset.md b/prompts/default/fw.code_reset.mdnew file mode 100644index 000000000..d5b688932--- /dev/null+++ b/prompts/default/fw.code_reset.md@@ -0,0 +1 @@+Terminal session has been reset.\ No newline at end of filediff --git a/python/tools/code_execution_tool.py b/python/tools/code_execution_tool.pyindex 75b9f4c27..b5b12e9d6 100644--- a/python/tools/code_execution_tool.py+++ b/python/tools/code_execution_tool.py@@ -115,4 +115,8 @@ class CodeExecution(Tool):if ( full_output and idle > wait_with_output / SLEEP_TIME ) or ( not full_output and idle > wait_without_output / SLEEP_TIME ): return full_outputasync def reset_terminal(self):- await self.prepare_state(reset=True)\ No newline at end of file+ self.state.shell.close()+ await self.prepare_state(reset=True)+ response = self.agent.read_prompt("fw.code_reset.md")+ self.log.update(content=response)+ return response\ No newline at end of file