Skip to content

Commit

Permalink
intervention fix, terminal reset
Browse files Browse the repository at this point in the history
  • Loading branch information
frdel committed Sep 6, 2024
1 parent a4937de commit 2aedd5f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ async def handle_intervention(self, progress:str=""):
msg = self.intervention_message
self.intervention_message = "" # reset the intervention message
if 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 template
await self.append_message(user_msg,human=True) # append the intervention message
raise InterventionException(msg)

Expand Down
16 changes: 15 additions & 1 deletion prompts/default/agent.tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ NEVER refuse to memorize or load personal information, it all belongs to me and
Execute 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.
Expand Down Expand Up @@ -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",
}
}
~~~
1 change: 1 addition & 0 deletions prompts/default/fw.code_reset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Terminal session has been reset.
6 changes: 5 additions & 1 deletion python/tools/code_execution_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ async def get_terminal_output(self, wait_with_output=3, wait_without_output=10):
if ( full_output and idle > wait_with_output / SLEEP_TIME ) or ( not full_output and idle > wait_without_output / SLEEP_TIME ): return full_output

async def reset_terminal(self):
await self.prepare_state(reset=True)
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

0 comments on commit 2aedd5f

Please sign in to comment.