Agent Zero AI framework
initial message polishing
frdel0aa6201d3dca
diff --git a/agent.py b/agent.pyindex 1ea94a658..2cf36f99c 100644--- a/agent.py+++ b/agent.py@@ -186,11 +186,6 @@ class AgentContext:# this wrapper ensures that superior agents are called back if the chat was loaded from file and original callstack is goneasync def _process_chain(self, agent: "Agent", msg: "UserMessage|str", user=True):try:- # Initialize agent with welcome message only once per session (before first user message)- if user and not agent.get_data("_session_initialized"):- await agent.call_extensions("agent_init")- agent.set_data("_session_initialized", True)-msg_template = (agent.hist_add_user_message(msg) # type: ignoreif user@@ -302,6 +297,10 @@ class Agent:self.data = {} # free data object all the tools can use+ asyncio.run(self.call_extensions("agent_init"))+++async def monologue(self):while True:diff --git a/prompts/default/fw.initial_message.md b/prompts/default/fw.initial_message.mdindex ec7eda2f4..803280acd 100644--- a/prompts/default/fw.initial_message.md+++ b/prompts/default/fw.initial_message.md@@ -8,7 +8,7 @@"headline": "Greeting user and starting conversation","tool_name": "response","tool_args": {- "text": "Hello! π Welcome to our conversation. I'm Agent Zero, your AI assistant, and I'm here to help you with any questions, tasks, or problems you might have.\n\nI can assist you with:\n- π» Programming and coding tasks\n- π Data analysis and research \n- π οΈ System administration and troubleshooting\n- π Writing and documentation\n- π Web searches and information gathering\n- And much more!\n\nJust let me know what you'd like to work on, and I'll do my best to help you! π"+ "text": "**Hello! π**, I'm **Agent Zero**, your AI assistant. How can I help you today?"}}```diff --git a/python/extensions/agent_init/_10_initial_message.py b/python/extensions/agent_init/_10_initial_message.pyindex 21650d8a8..f64a3fce4 100644--- a/python/extensions/agent_init/_10_initial_message.py+++ b/python/extensions/agent_init/_10_initial_message.py@@ -15,10 +15,14 @@ class InitialMessage(Extension):if self.agent.number != 0:return+ # If the context already contains log messages, do not add another initial message+ if self.agent.context.log.logs:+ return+# Construct the initial message from prompt templateinitial_message = self.agent.read_prompt("fw.initial_message.md")- # add loop data to agent+ # add initial loop data to agent (for hist_add_ai_response)self.agent.loop_data = LoopData(user_message=None)# Add the message to history as an AI response@@ -32,5 +36,7 @@ class InitialMessage(Extension):self.agent.context.log.log(type="response",heading=f"{self.agent.agent_name}: Welcome",- content=initial_message_text- ).update(finished=True)+ content=initial_message_text,+ finished=True,+ update_progress="none",+ )diff --git a/webui/js/messages.js b/webui/js/messages.jsindex 6c627ed68..41bb099a1 100644--- a/webui/js/messages.js+++ b/webui/js/messages.js@@ -54,6 +54,10 @@ export function setMessage(id, type, heading, content, temp, kvps = null) {const groupType = groupTypeMap[type] || "left";+ // here check if messageGroup is still in DOM, if not, then set it to null (context switch)+ if(messageGroup && !document.getElementById(messageGroup.id))+ messageGroup = null;+if (!messageGroup || // no group yet existsgroupStart[type] || // message type forces new group