universal-mcp-agents 0.1.13__py3-none-any.whl → 0.1.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of universal-mcp-agents might be problematic. Click here for more details.

Files changed (49) hide show
  1. universal_mcp/agents/__init__.py +1 -1
  2. universal_mcp/agents/base.py +3 -0
  3. universal_mcp/agents/bigtool/__init__.py +1 -1
  4. universal_mcp/agents/bigtool/__main__.py +4 -3
  5. universal_mcp/agents/bigtool/agent.py +3 -2
  6. universal_mcp/agents/bigtool/graph.py +68 -31
  7. universal_mcp/agents/bigtool/prompts.py +2 -2
  8. universal_mcp/agents/bigtool/tools.py +17 -4
  9. universal_mcp/agents/builder/__main__.py +129 -28
  10. universal_mcp/agents/builder/builder.py +149 -161
  11. universal_mcp/agents/builder/helper.py +71 -0
  12. universal_mcp/agents/builder/prompts.py +94 -160
  13. universal_mcp/agents/codeact0/__init__.py +2 -1
  14. universal_mcp/agents/codeact0/agent.py +13 -5
  15. universal_mcp/agents/codeact0/langgraph_agent.py +14 -0
  16. universal_mcp/agents/codeact0/llm_tool.py +1 -2
  17. universal_mcp/agents/codeact0/playbook_agent.py +353 -0
  18. universal_mcp/agents/codeact0/prompts.py +126 -41
  19. universal_mcp/agents/codeact0/sandbox.py +43 -32
  20. universal_mcp/agents/codeact0/state.py +27 -3
  21. universal_mcp/agents/codeact0/tools.py +180 -0
  22. universal_mcp/agents/codeact0/utils.py +89 -75
  23. universal_mcp/agents/shared/__main__.py +44 -0
  24. universal_mcp/agents/shared/prompts.py +49 -98
  25. universal_mcp/agents/shared/tool_node.py +160 -176
  26. universal_mcp/agents/utils.py +71 -0
  27. universal_mcp/applications/ui/app.py +2 -2
  28. {universal_mcp_agents-0.1.13.dist-info → universal_mcp_agents-0.1.15.dist-info}/METADATA +3 -3
  29. universal_mcp_agents-0.1.15.dist-info/RECORD +50 -0
  30. universal_mcp/agents/codeact0/usecases/1-unsubscribe.yaml +0 -4
  31. universal_mcp/agents/codeact0/usecases/10-reddit2.yaml +0 -10
  32. universal_mcp/agents/codeact0/usecases/11-github.yaml +0 -13
  33. universal_mcp/agents/codeact0/usecases/2-reddit.yaml +0 -27
  34. universal_mcp/agents/codeact0/usecases/2.1-instructions.md +0 -81
  35. universal_mcp/agents/codeact0/usecases/2.2-instructions.md +0 -71
  36. universal_mcp/agents/codeact0/usecases/3-earnings.yaml +0 -4
  37. universal_mcp/agents/codeact0/usecases/4-maps.yaml +0 -41
  38. universal_mcp/agents/codeact0/usecases/5-gmailreply.yaml +0 -8
  39. universal_mcp/agents/codeact0/usecases/6-contract.yaml +0 -6
  40. universal_mcp/agents/codeact0/usecases/7-overnight.yaml +0 -14
  41. universal_mcp/agents/codeact0/usecases/8-sheets_chart.yaml +0 -25
  42. universal_mcp/agents/codeact0/usecases/9-learning.yaml +0 -9
  43. universal_mcp/agents/planner/__init__.py +0 -51
  44. universal_mcp/agents/planner/__main__.py +0 -28
  45. universal_mcp/agents/planner/graph.py +0 -85
  46. universal_mcp/agents/planner/prompts.py +0 -14
  47. universal_mcp/agents/planner/state.py +0 -11
  48. universal_mcp_agents-0.1.13.dist-info/RECORD +0 -63
  49. {universal_mcp_agents-0.1.13.dist-info → universal_mcp_agents-0.1.15.dist-info}/WHEEL +0 -0
@@ -1,173 +1,107 @@
1
- AGENT_BUILDER_INSTRUCTIONS = r"""
2
- You are a specialized Agent Generation AI, tasked with creating intelligent, effective, and context-aware AI agents based on user requests.
3
-
4
- When given a user's request, immediately follow this structured process:
5
-
6
- # 1. Intent Breakdown
7
- - Clearly identify the primary goal the user wants the agent to achieve.
8
- - Recognize any special requirements, constraints, formatting requests, or interaction rules.
9
- - Summarize your understanding briefly to ensure alignment with user intent.
10
-
11
- # 2. Agent Profile Definition
12
- - **Name (2-4 words)**: Concise, clear, and memorable name reflecting core functionality.
13
- - **Description (1-2 sentences)**: Captures the unique value and primary benefit to users.
14
- - **Expertise**: Precise domain-specific expertise area. Avoid vague or overly general titles.
15
- - **Instructions**: Compose detailed, highly actionable system instructions that directly command the agent's behavior. Respond in markdown as this text will be rendered in a rich text editor. Write instructions as clear imperatives, without preamble, assuming the agent identity is already established externally.
16
- - **Schedule**: If the user specifies a schedule, you should also provide a cron expression for the agent to run on. The schedule should be in a proper cron expression and nothing more. Do not respond with any other information or explain your reasoning for the schedule, otherwise this will cause a parsing error that is undesirable.
17
-
18
- ## ROLE & RESPONSIBILITY
19
- - Clearly state the agent's primary mission, e.g., "Your primary mission is...", "Your core responsibility is...".
20
- - Outline the exact tasks it handles, specifying expected input/output clearly.
21
-
22
- ## INTERACTION STYLE
23
- - Define exactly how to communicate with users: tone, format, response structure.
24
- - Include explicit commands, e.g., "Always wrap responses in \`\`\`text\`\`\` blocks.", "Never add greetings or meta-information.", "Always provide outputs in user's requested languages."
25
-
26
- ## OUTPUT FORMATTING RULES
27
- - Clearly specify formatting standards required by the user (e.g., JSON, plain text, markdown).
28
- - Include explicit examples to illustrate correct formatting.
29
-
30
- ## LIMITATIONS & CONSTRAINTS
31
- - Explicitly define boundaries of the agent's capabilities.
32
- - Clearly state what the agent must never do or say.
33
- - Include exact phrases for declining requests outside scope.
34
-
35
- ## REAL-WORLD EXAMPLES
36
- Provide two explicit interaction examples showing:
37
- - User's typical request.
38
- - Final agent response demonstrating perfect compliance.
39
-
40
- Create an agent that feels thoughtfully designed, intelligent, and professionally reliable, perfectly matched to the user's original intent.
41
- """
42
-
43
-
44
- TASK_SYNTHESIS_PROMPT = r"""
45
- # ROLE & GOAL
46
- You are a 'Task Synthesizer' AI. Your sole purpose is to combine an original user task and a subsequent modification request into a single, complete, and coherent new task. This new task must be a standalone instruction that accurately reflects the user's final intent and can be used to configure a new AI agent from scratch.
47
-
48
- # CORE PRINCIPLES
49
- 1. **Preserve All Details:** You must retain all specific, unmodified details from the original task (e.g., email addresses, subjects, search queries, file names).
50
- 2. **Seamless Integration:** The user's modification must be integrated perfectly into the original task's context, replacing or adding information as required.
51
- 3. **Clarity and Directness:** The final task should be a direct command, phrased as if it were the user's very first request.
52
- 4. **Strict Output Format:** Your output MUST BE ONLY the new synthesized task string. Do not include any preamble, explanation, or quotation marks.
53
-
54
- ---
55
- # EXAMPLES
56
-
57
- **EXAMPLE 1: Changing the application for an email task**
58
-
59
- **Original Task:**
60
- "Send an email to manoj@agentr.dev with the subject 'Hello' and body 'This is a test of the Gmail agent.' from my Gmail account"
61
-
62
- **Modification Request:**
63
- "Please use my Outlook account for this instead of Gmail."
64
-
65
- **New Synthesized Task:**
66
- Send an email to manoj@agentr.dev with the subject 'Hello' and body 'This is a test of the Outlook agent.' from my Outlook account
67
-
68
- ---
69
- **EXAMPLE 2: Modifying the scope and source for a calendar task**
70
-
71
- **Original Task:**
72
- "Show me events from today's Google Calendar"
73
-
74
- **Modification Request:**
75
- "Actually, I need to see the whole week, not just today. And can you check my Microsoft 365 calendar?"
76
-
77
- **New Synthesized Task:**
78
- Show me events for the whole week from my Microsoft 365 calendar
79
-
80
- ---
81
- **EXAMPLE 3: Changing the target and tool for a web search task**
82
-
83
- **Original Task:**
84
- "Find the best restaurants in Goa using exa web search"
85
-
86
- **Modification Request:**
87
- "Could you look for hotels instead of restaurants, and please use Perplexity for it."
88
-
89
- **New Synthesized Task:**
90
- Find the best hotels in Goa using Perplexity.
1
+ import json
91
2
 
92
- ---
93
- **EXAMPLE 4: Altering the final action of a multi-step task**
3
+ from universal_mcp.types import ToolConfig
94
4
 
95
- **Original Task:**
96
- "search reddit for posts on elon musk and then post a meme on him on linkedin"
97
5
 
98
- **Modification Request:**
99
- "Let's not post anything. Just find the posts and then summarize the key points into a text file for me."
6
+ def _build_prompt(
7
+ user_task: str | None = None,
8
+ conversation_history: list[dict] | None = None,
9
+ existing_instructions: str | None = None,
10
+ modification_request: str | None = None,
11
+ tool_config: ToolConfig | None = None,
12
+ ) -> str:
13
+ """Dynamically builds a cohesive and effective prompt for the LLM based on the provided inputs."""
100
14
 
101
- **New Synthesized Task:**
102
- search reddit for posts on elon musk and then summarize the key points into a text file
15
+ core_prompt = r"""
16
+ You are a master AI Agent Architect. Your purpose is to design and define highly effective AI agents by interpreting user requests and generating a precise agent profile in JSON format.
103
17
 
104
- ---
105
- # YOUR TASK
106
-
107
- Now, perform this synthesis for the following inputs.
108
-
109
- **Original Task:**
110
- {original_task}
111
-
112
- **Modification Request:**
113
- {modification_request}
114
-
115
- **New Synthesized Task:**
18
+ Your process is systematic and thorough. You will analyze all provided information to construct a complete and coherent agent definition.
116
19
  """
117
20
 
118
- AGENT_FROM_CONVERSATION_PROMPT = r"""
119
- # ROLE & GOAL
120
- You are a highly intelligent 'Agent Analyst' AI. Your sole purpose is to analyze a raw conversation transcript between a user and an AI assistant and a definitive list of tools the assistant used. From this data, you must synthesize a complete, reusable AI agent profile.
121
-
122
- # INPUTS
123
- 1. **Conversation History:** A transcript of the dialogue.
124
- 2. **Used Tools:** A definitive list of tool configurations (`{{app_id: [tool_names]}}`) that were successfully used to fulfill the user's requests in the conversation.
125
-
126
- # 1. Intent Breakdown
127
- - Clearly identify the primary goal the user wants the agent to achieve.
128
- - Recognize any special requirements, constraints, formatting requests, or interaction rules.
129
- - Summarize your understanding briefly to ensure alignment with user intent.
130
-
131
- # 2. Agent Profile Definition
132
- - **Name (2-4 words)**: Concise, clear, and memorable name reflecting core functionality.
133
- - **Description (1-2 sentences)**: Captures the unique value and primary benefit to users.
134
- - **Expertise**: Precise domain-specific expertise area. Avoid vague or overly general titles.
135
- - **Instructions**: Compose detailed, highly actionable system instructions that directly command the agent's behavior. Respond in markdown as this text will be rendered in a rich text editor. Write instructions as clear imperatives, without preamble, assuming the agent identity is already established externally.
136
- - **Schedule**: If the user specifies a schedule, you should also provide a cron expression for the agent to run on. The schedule should be in a proper cron expression and nothing more. Do not respond with any other information or explain your reasoning for the schedule, otherwise this will cause a parsing error that is undesirable.
137
-
138
- ## ROLE & RESPONSIBILITY
139
- - Clearly state the agent's primary mission, e.g., "Your primary mission is...", "Your core responsibility is...".
140
- - Outline the exact tasks it handles, specifying expected input/output clearly.
141
-
142
- ## INTERACTION STYLE
143
- - Define exactly how to communicate with users: tone, format, response structure.
144
- - Include explicit commands, e.g., "Always wrap responses in \`\`\`text\`\`\` blocks.", "Never add greetings or meta-information.", "Always provide outputs in user's requested languages."
145
-
146
- ## OUTPUT FORMATTING RULES
147
- - Clearly specify formatting standards required by the user (e.g., JSON, plain text, markdown).
148
- - Include explicit examples to illustrate correct formatting.
149
-
150
- ## LIMITATIONS & CONSTRAINTS
151
- - Explicitly define boundaries of the agent's capabilities.
152
- - Clearly state what the agent must never do or say.
153
- - Include exact phrases for declining requests outside scope.
154
-
155
- ## REAL-WORLD EXAMPLES
156
- Provide two explicit interaction examples showing:
157
- - User's typical request.
158
- - Final agent response demonstrating perfect compliance.
159
-
160
- Create an agent that feels thoughtfully designed, intelligent, and professionally reliable, perfectly matched to the user's original intent.
161
-
162
- # YOUR TASK
21
+ analysis_sections = ["\n# I. Analysis of Provided Inputs\n"]
22
+ analysis_sections.append("You are to analyze the following information to understand the user's requirements:\n")
23
+
24
+ if user_task:
25
+ analysis_sections.append(f"## Primary User Task:\n```\n{user_task}\n```\n")
26
+
27
+ if conversation_history:
28
+ analysis_sections.append(
29
+ "## Conversation History:\n"
30
+ "Pay special attention to the messages from the 'human' user. These are direct expressions of their needs and expectations for the agent's behavior. Include the user specific personal information like email-id or anything else which is personal in the agent's instruction.\n"
31
+ f"```json\n{json.dumps(conversation_history, indent=2)}\n```\n"
32
+ )
33
+
34
+ if existing_instructions:
35
+ analysis_sections.append(
36
+ "## Existing Agent Instructions:\n"
37
+ "This is the baseline definition for the current agent. Your task will be to modify this based on the user's new requests.\n"
38
+ f"```\n{existing_instructions}\n```\n"
39
+ )
40
+
41
+ if modification_request:
42
+ analysis_sections.append(
43
+ "## Modification Request:\n"
44
+ "The user wants to change the existing agent. You must incorporate these changes into the new agent definition.\n"
45
+ f"```\n{modification_request}\n```\n"
46
+ )
47
+
48
+ if tool_config:
49
+ analysis_sections.append(
50
+ "## Tool Configuration:\n"
51
+ "The agent has access to the following tools. The agent's instructions should reflect the appropriate use of these tools.\n"
52
+ f"```json\n{json.dumps(tool_config, indent=2)}\n```\n"
53
+ )
54
+
55
+ framework_prompt = r"""
56
+ # II. Agent Definition Framework
57
+
58
+ Based on your analysis, you will now define the agent's profile.
59
+
60
+ ## 1. Intent Synthesis
61
+ - **Primary Goal:** In a single sentence, what is the core objective of this agent?
62
+ - **Key Requirements & Constraints:** List any specific requirements, rules, or limitations the agent must adhere to.
63
+
64
+ ## 2. Agent Profile Generation
65
+ You will now construct the complete agent profile.
66
+
67
+ - **Name (2-4 words):** A concise and memorable name that reflects the agent's core function.
68
+ - **Description (1-2 sentences):** A clear and compelling summary of the agent's purpose and value.
69
+ - **Expertise:** A specific, well-defined area of expertise (e.g., "Python Code Generation and Debugging," not "Programming").
70
+ - **Instructions:**
71
+ - This is the most critical part of your output. Write a comprehensive set of system instructions for the agent.
72
+ - The instructions should contain all the necessary details for the agent to call the tools , use the information from the conversation history, and fulfill the user's primary task.
73
+ - The instructions should be written in markdown and be direct, actionable commands.
74
+ - Start with the user's primary task.
75
+ - Clearly define the agent's role and responsibilities.
76
+ - Provide explicit rules for its behavior and interaction style.
77
+ - If tools are provided, explain how and when the agent should use them.
78
+ - Specify the desired output format (e.g., JSON, markdown, plain text).
79
+ - **Schedule:**
80
+ - If the user specifies a schedule, provide a cron expression for when the agent should run.
81
+ - The output for the schedule should only be the cron expression itself (e.g., "0 9 * * *"). Do not add any explanatory text.
82
+ """
163
83
 
164
- Now, perform this analysis for the following inputs.
84
+ final_task_prompt = r"""
85
+ # III. Your Task
165
86
 
166
- **INPUT - Conversation History:**
167
- {conversation_history}
87
+ Generate a single JSON object that represents the complete agent profile. The JSON object should have the following structure:
168
88
 
169
- **INPUT - Used Tools:**
170
- {tool_config}
89
+ {
90
+ "name": "...",
91
+ "description": "...",
92
+ "expertise": "...",
93
+ "instructions": "...",
94
+ "schedule": "..."
95
+ }
171
96
 
172
97
  **YOUR JSON OUTPUT:**
173
98
  """
99
+
100
+ full_prompt = [
101
+ core_prompt,
102
+ "".join(analysis_sections),
103
+ framework_prompt,
104
+ final_task_prompt,
105
+ ]
106
+
107
+ return "\n".join(full_prompt)
@@ -1,3 +1,4 @@
1
1
  from .agent import CodeActAgent
2
+ from .playbook_agent import CodeActPlaybookAgent
2
3
 
3
- __all__ = ["CodeActAgent"]
4
+ __all__ = ["CodeActAgent", "CodeActPlaybookAgent"]
@@ -18,8 +18,9 @@ from universal_mcp.agents.codeact0.prompts import (
18
18
  )
19
19
  from universal_mcp.agents.codeact0.sandbox import eval_unsafe, execute_ipython_cell
20
20
  from universal_mcp.agents.codeact0.state import CodeActState
21
- from universal_mcp.agents.codeact0.utils import filter_retry_on, inject_context
21
+ from universal_mcp.agents.codeact0.utils import inject_context, smart_truncate
22
22
  from universal_mcp.agents.llm import load_chat_model
23
+ from universal_mcp.agents.utils import filter_retry_on
23
24
 
24
25
 
25
26
  class CodeActAgent(BaseAgent):
@@ -63,9 +64,11 @@ class CodeActAgent(BaseAgent):
63
64
  raise ValueError("Tools are configured but no registry is provided")
64
65
  # Langchain tools are fine
65
66
  exported_tools = await self.registry.export_tools(self.tools_config, ToolFormat.LANGCHAIN)
66
- exported_tools.extend([smart_print, data_extractor, ai_classify, call_llm])
67
- self.processed_tools = [t if isinstance(t, StructuredTool) else create_tool(t) for t in exported_tools]
68
- self.instructions, self.tools_context = create_default_prompt(self.processed_tools, self.instructions)
67
+ additional_tools = [smart_print, data_extractor, ai_classify, call_llm]
68
+ additional_tools = [t if isinstance(t, StructuredTool) else create_tool(t) for t in additional_tools]
69
+ self.instructions, self.tools_context = create_default_prompt(
70
+ exported_tools, additional_tools, self.instructions
71
+ )
69
72
 
70
73
  def call_model(state: CodeActState) -> Command[Literal["sandbox"]]:
71
74
  messages = [{"role": "system", "content": self.instructions}] + state["messages"]
@@ -113,7 +116,12 @@ class CodeActAgent(BaseAgent):
113
116
  existing_context = state.get("context", {})
114
117
  context = {**existing_context, **add_context}
115
118
  # Execute the script in the sandbox
116
- output, new_context, new_add_context = self.eval_fn(code, context, previous_add_context)
119
+
120
+ output, new_context, new_add_context = self.eval_fn(
121
+ code, context, previous_add_context, 180
122
+ ) # default timeout 3 min
123
+ output = smart_truncate(output)
124
+
117
125
  return Command(
118
126
  goto="call_model",
119
127
  update={
@@ -0,0 +1,14 @@
1
+ from universal_mcp.agentr.registry import AgentrRegistry
2
+
3
+ from universal_mcp.agents.codeact0.playbook_agent import CodeActPlaybookAgent
4
+
5
+
6
+ async def agent():
7
+ agent_obj = CodeActPlaybookAgent(
8
+ name="CodeAct Agent",
9
+ instructions="Be very concise in your answers.",
10
+ model="anthropic:claude-4-sonnet-20250514",
11
+ tools=[],
12
+ registry=AgentrRegistry(),
13
+ )
14
+ return await agent_obj._build_graph()
@@ -5,7 +5,7 @@ from typing import Any, Literal, cast
5
5
  from langchain.chat_models import init_chat_model
6
6
  from langchain_openai import AzureChatOpenAI
7
7
 
8
- from universal_mcp.agents.codeact0.utils import get_message_text, light_copy
8
+ from universal_mcp.agents.codeact0.utils import get_message_text
9
9
 
10
10
  MAX_RETRIES = 3
11
11
 
@@ -27,7 +27,6 @@ def smart_print(data: Any) -> None:
27
27
  Args:
28
28
  data: Either a dictionary with string keys, or a list of such dictionaries
29
29
  """
30
- light_copy(data)
31
30
 
32
31
 
33
32
  def creative_writer(