Skip to content

Commit

Permalink
logs, prompt, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
frdel committed Jun 11, 2024
1 parent e958167 commit c7abcab
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

## Nice features to have
- Output is very clean, colorful, and readable; nothing is hidden.
- The same colorful output you see in the terminal is automatically saved to HTML file in **logs/** folder for every session.
- Agent output is streamed in real-time, allowing the user to read along and intervene at any time.
- No coding is required, only prompting and communication skills.
- With a solid system prompt, the framework is reliable even with small models, including precise tool usage.
Expand All @@ -56,6 +57,11 @@ If your agent fails to communicate properly, use tools, reason, use memory, find
Agent Zero is made to be used in an isolated virtual machine (for safety) with some tools preinstalled and configured.
If you cannot provide all the necessary conditions or API keys, just change the system prompt and tell your agent what operating system and tools are at its disposal. Nothing is hard-coded; if you do not tell your agent about a certain tool, it will not know about it and will not try to use it.

## Known problems
1. The system prompt sucks. You can do better. If you do, help me please :)
2. Input freeze on some Linux terminals - for some reason, sometimes the input field freezes on some terminal apps on linux when the window loses focus. Right now I have no clue why...
3. Claude models like to hallucinate when using tools. This can probebly be fixed in prompt, but for some reason, Claude models like to use multiple tools in a single message and not wait for output, they just make up their outputs right away. For now I have limited the tool usage to 1 tool per message, this helps a little.

## Ideal environment
- **Linux VM / docker container**: The perfect environment to run Agent Zero is a Debian-based Linux virtual machine or docker container with enhanced privileges or root access (to install packages and run terminal commands).
- **Python**: Python has to be installed on the system to run the framework and let the agent execute created Python scripts.
Expand Down
9 changes: 8 additions & 1 deletion agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ def process_message(self, msg: str):
self.append_message(msg_response, human=True)
PrintStyle(font_color="red", padding=True).print(msg_response)
finally:
user_message = files.read_file("./prompts/fw.msg_continue.md")
if self.get_last_message().type=="ai": #type: ignore
user_message = files.read_file("./prompts/fw.msg_continue.md")
PrintStyle(font_color="yellow", padding=False).print(user_message)

finally:
Agent.streaming_agent = None # unset current streamer

Expand All @@ -118,6 +121,10 @@ def append_message(self, msg: str, human: bool = False):
if message_type=="ai":
self.last_message = msg

def get_last_message(self):
if self.history:
return self.history[-1]

def cleanup_history(self,x, y):
if len(self.history) <= x + y:
return self.history
Expand Down
11 changes: 7 additions & 4 deletions prompts/agent.system.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Your role
- You are a fully autonomous, highly inteligent AI agent.
- You solve tasks and respond to questions by your user.
- You never lie or speculate about your actions, all of your actions need to be conducted by your tools.

# Communication to user
- Your messages are only visible to you for your thought process. Noone else can read them, do not use them as a response for user.
- Your messages are only visible to you for your thought process. No one else can read them.
- When you want to respond to user, use the speak_to_user tool.
- Never respond directly to the user, you must always use speak_to_user tool.

# Communication to subordinate
- When delegating new subtask to subordinate, use the 'reset' parameter set to True to reset subordinate's context and start fresh. When sending followup questions or instructions, do not set the flag to keep his previous context.
Expand All @@ -25,7 +27,8 @@
5. Completing the task
- Consolidate all subtasks and explain the status.
- Verify the result using your tools if possible (check created files etc.)
- Report back to your user using speak_to_user_tool, describe the result and provide all necessary information.
- If there is helpful information discovered during the solution, save it into your memory using memory_tool for later.
- Report back to your user using speak_to_user_tool, describe the result and provide all necessary information. Do not just output your response, you must use the tool for that.

# General operation manual
- Use your reasoning and process each problem in a step-by-step manner.
Expand All @@ -42,9 +45,9 @@

# Tool usage instructions
- Tools can be used to communicate with user and subordinate and to solve problems.
- To use a tool, include pair XML tags <tool$> and </tool$> in your response. Use with attribute "name" of the tool and potential other attributes the tool accepts. The main input data (message, code, question) for the tool goes between <tool$> and </tool$> tags. No escaping.
- To use a tool, include pair XML tags <tool$> and </tool$> in your response. Use with attribute "name" of the tool and potential other attributes the tool accepts. The main input data (message, code, question) for the tool goes between <tool$> and </tool$> tags. No escaping. Result will be sent to you in the next message.
- Only use tools provided in Available tools section, do not try to use any tool name you have not been instructed to.
- Do not use more than one tool per message. End your response and wait for response before using another tool. After you use a tool, end your response.
- Do not use more than one tool per message. End your response and wait for results.

## Tool usage generic example:
<tool$ name="speak_to_subordinate" reset="false">
Expand Down
7 changes: 3 additions & 4 deletions tools/helpers/print_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ def _add_padding_if_needed(self):
if not self.log_only:
print() # Print an empty line for padding
self._log_html("<br>")
if not PrintStyle.last_endline:
if not self.log_only:
print() # Add one more if last print was streamed
self._log_html("<br>")
self.padding_added = True

def _log_html(self, html):
Expand All @@ -99,6 +95,9 @@ def get(self, *args, sep=' ', **kwargs):

def print(self, *args, sep=' ', **kwargs):
self._add_padding_if_needed()
if not PrintStyle.last_endline:
print()
self._log_html("<br>")
plain_text, styled_text, html_text = self.get(*args, sep=sep, **kwargs)
if not self.log_only:
print(styled_text, end='\n', flush=True)
Expand Down

0 comments on commit c7abcab

Please sign in to comment.