Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit ff086e9

Browse files
authored
set agent system prompt in agent config (#85)
1 parent 2611165 commit ff086e9

8 files changed

Lines changed: 30 additions & 19 deletions

File tree

examples/atomic/IOAgent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ def main():
2121
"agent_class": "FunctionCallingAgent",
2222
"meta_data":{},
2323
"tool_names": ["read_file", "write_to_file", "generate_and_download_image"],
24-
"agent_description": "Read or write content from/to a file, or generate and save an image using text input",
25-
"parameter_description": "The task description detailing what to read, write, or generate. This can include file operations or image generation requests."
24+
"system_prompt": "You are an ai agent, Read or write content from/to a file, or generate and save an image using text input",
25+
"agent_description": None,
26+
"parameter_description": None,
2627
}
2728

2829
system_config = {

examples/composite/MasterAgent.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def main():
2626
"model_name": "gpt-4o-mini",
2727
"tool_choice": "auto"
2828
},
29-
"tool_names": ["read_file", "write_to_file", "generate_and_download_image"], # Changed from "write_file" to "write_to_file"
29+
"tool_names": ["read_file", "write_to_file", "generate_and_download_image"],
30+
"system_prompt": "You are an AI agent. Read or write content from/to a file, or generate and save an image using text input",
3031
"agent_description": "Read or write content from/to a file, or generate and save an image using text input",
3132
"parameter_description": "The task description detailing what to read, write, or generate. This can include file operations or image generation requests."
3233
}
@@ -36,7 +37,8 @@ def main():
3637
"type": "atomic",
3738
"agent_class": "FunctionCallingAgent",
3839
"meta_data": {},
39-
"tool_names": ["retrieve_db"], # Changed from "write_file" to "write_to_file"
40+
"tool_names": ["retrieve_db"],
41+
"system_prompt": "You are an AI agent. Use a database retrieval agent to fetch information based on a given query.",
4042
"agent_description": "Use a database retrieval agent to fetch information based on a given query.",
4143
"parameter_description": "The query to be processed by the database retrieval agent."
4244
}
@@ -46,7 +48,8 @@ def main():
4648
"type": "atomic",
4749
"agent_class": "FunctionCallingAgent",
4850
"meta_data": {},
49-
"tool_names": ["retrieve_file"], # Changed from "write_file" to "write_to_file"
51+
"tool_names": ["retrieve_file"],
52+
"system_prompt": "You are an AI agent. Retrieve information from local documents to answer questions or perform tasks.",
5053
"agent_description": "Retrieve information from local documents to answer questions or perform tasks.",
5154
"parameter_description": "The task description specifying the local file and the question to be answered. specify this in natural language"
5255
}
@@ -56,7 +59,8 @@ def main():
5659
"type": "atomic",
5760
"agent_class": "FunctionCallingAgent",
5861
"meta_data": {},
59-
"tool_names": ["bing_search", "scrape"], # Changed from "write_file" to "write_to_file"
62+
"tool_names": ["bing_search", "scrape"],
63+
"system_prompt": "You are an AI agent. Perform a search using API and return the searched results.",
6064
"agent_description": "Perform a search using API and return the searched results.",
6165
"parameter_description": "The task description describing what to read or write."
6266
}
@@ -66,7 +70,8 @@ def main():
6670
"type": "atomic",
6771
"agent_class": "FunctionCallingAgent",
6872
"meta_data": {},
69-
"tool_names": ["execute_shell_command", "run_python_script"], # Changed from "write_file" to "write_to_file"
73+
"tool_names": ["execute_shell_command", "run_python_script"],
74+
"system_prompt": "You are an AI agent. Execute some script in a subprocess, either run a bash script, or run a python script ",
7075
"agent_description": "Execute some script in a subprocess, either run a bash script, or run a python script ",
7176
"parameter_description": "The task description describing what to execute in the subprocess."
7277
}
@@ -82,6 +87,7 @@ def main():
8287
file_retrieval_agent_config,
8388
db_retrieval_agent_config
8489
],
90+
"system_prompt": "You are an AI agent, Use a smart research assistant to look up information using multiple sources including web search, database retrieval, and local file retrieval.",
8591
"agent_description": "Use a smart research assistant to look up information using multiple sources including web search, database retrieval, and local file retrieval.",
8692
"parameter_description": "The task description specifying the information source (web search, database, local file) and the question to be answered. specify this in natural language"
8793
}
@@ -97,6 +103,7 @@ def main():
97103
exec_agent_config,
98104
io_agent_config,
99105
],
106+
"system_prompt": "You are an AI agent that leverage tools and sub agents",
100107
"agent_description": None,
101108
"parameter_description": None
102109
}

examples/new_tool/add_function_example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def calculate(operation, num1, num2):
5151
"meta_data": {},
5252
"tool_names": ["read_file", "write_to_file", "generate_and_download_image"],
5353
"self_defined_tools": [new_tool],
54-
"agent_description": "test ai agent",
55-
"parameter_description": "test ai agent"
54+
"system_prompt": "You are an ai agent, we want to test using some tools",
55+
"agent_description": None,
56+
"parameter_description": None
5657
}
5758

5859
system_config = {

examples/new_tool/add_llm_generated_function_example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ def main():
6666
"meta_data": {},
6767
"tool_names": ["read_file", "write_to_file", "generate_and_download_image"],
6868
"self_defined_tools": new_tools,
69-
"agent_description": "test ai agent",
70-
"parameter_description": "test ai agent"
69+
"system_prompt": "You are an ai agent, we want to test using some tools",
70+
"agent_description": None,
71+
"parameter_description": None
7172
}
7273

7374
system_config = {

litemultiagent/agents/agent_class/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@
5151
logger.error(f"Failed to initialize Supabase client: {e}")
5252

5353
class BaseAgent:
54-
def __init__(self, agent_name: str, agent_description, parameter_description, tools: List[Dict[str, Any]],
54+
def __init__(self, agent_name: str, system_prompt, agent_description, parameter_description, tools: List[Dict[str, Any]],
5555
available_tools: Dict[str, callable],
5656
meta_data):
5757
self.agent_name = agent_name
5858
self.tools = tools
5959
self.available_tools = available_tools
60-
self.messages = []
60+
self.messages = [{"role": "system", "content": system_prompt}]
6161
self.model_name = meta_data.get("model_name", None)
6262
self.tool_choice = meta_data.get("tool_choice", None)
6363
self.agent_description = agent_description

litemultiagent/agents/agent_type/atomic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class AtomicAgent:
7-
def __init__(self, agent_name: str, agent_description: str, parameter_description: str,
7+
def __init__(self, agent_name: str, system_prompt: str, agent_description: str, parameter_description: str,
88
tool_names: List[str], self_defined_tools, meta_data: Dict[str, Any],
99
agent_class: Type[BaseAgent]):
1010
tool_registry = ToolRegistry()
@@ -17,7 +17,7 @@ def __init__(self, agent_name: str, agent_description: str, parameter_descriptio
1717
available_tools[tool_name] = tool_registry.get_tool(tool_name).func
1818
tools.append(tool_registry.get_tool_description(tool_name))
1919

20-
self.agent = agent_class(agent_name, agent_description, parameter_description,
20+
self.agent = agent_class(agent_name, system_prompt, agent_description, parameter_description,
2121
tools, available_tools, meta_data)
2222

2323
def execute(self, task: str) -> str:

litemultiagent/agents/agent_type/composite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from litemultiagent.tools.registry import ToolRegistry, Tool
44

55
class CompositeAgent:
6-
def __init__(self, agent_name: str, agent_description: str, parameter_description: str,
6+
def __init__(self, agent_name: str, system_prompt: str, agent_description: str, parameter_description: str,
77
sub_agent_configs: List[Dict[str, Any]], tool_names: List[str], self_defined_tools, meta_data: Dict[str, Any],
88
agent_class: Type[BaseAgent]):
99
self.available_tools = {}
@@ -20,7 +20,7 @@ def __init__(self, agent_name: str, agent_description: str, parameter_descriptio
2020
self.sub_agents = self._build_sub_agents(sub_agent_configs)
2121
self._register_sub_agents_as_tools()
2222

23-
self.agent = agent_class(agent_name, agent_description, parameter_description,
23+
self.agent = agent_class(agent_name, system_prompt, agent_description, parameter_description,
2424
self.tools, self.available_tools, meta_data)
2525

2626
def set_shared_config(self, shared_config):

litemultiagent/core/agent_factory.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def create_agent(config: Dict[str, Any]) -> Union[AtomicAgent, CompositeAgent]:
1010
agent_type = config["type"]
1111
agent_name = config["name"]
1212
agent_class = config["agent_class"]
13+
system_prompt = config["system_prompt"]
1314
agent_description = config["agent_description"]
1415
parameter_description = config["parameter_description"]
1516
tool_names = config.get("tool_names", [])
@@ -28,11 +29,11 @@ def create_agent(config: Dict[str, Any]) -> Union[AtomicAgent, CompositeAgent]:
2829
selected_agent_class = agent_class_map[agent_class]
2930

3031
if agent_type == "atomic":
31-
return AtomicAgent(agent_name, agent_description, parameter_description,
32+
return AtomicAgent(agent_name, system_prompt, agent_description, parameter_description,
3233
tool_names, self_defined_tools, meta_data, selected_agent_class)
3334
elif agent_type == "composite":
3435
sub_agent_configs = config.get("sub_agents", [])
35-
return CompositeAgent(agent_name, agent_description, parameter_description,
36+
return CompositeAgent(agent_name, system_prompt, agent_description, parameter_description,
3637
sub_agent_configs, tool_names, self_defined_tools, meta_data, selected_agent_class)
3738
else:
3839
raise ValueError(f"Unknown agent type: {agent_type}")

0 commit comments

Comments
 (0)