Spaces:
Runtime error
Runtime error
Commit
·
ff6d640
1
Parent(s):
0c6229a
Add application files
Browse files
mcp/agents/autonomous_agent_hf.py
CHANGED
|
@@ -178,14 +178,27 @@ You have access to MCP (Model Context Protocol) tools that let you:
|
|
| 178 |
- Send emails and manage email threads
|
| 179 |
- Schedule meetings and generate calendar invites
|
| 180 |
|
| 181 |
-
|
| 182 |
-
1. Researching companies using web search
|
| 183 |
-
2. Saving important company data and facts
|
| 184 |
-
3. Creating prospect profiles
|
| 185 |
-
4. Managing communications
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
# Initialize conversation
|
| 191 |
messages = [
|
|
@@ -580,9 +593,6 @@ When you have completed the task, provide a summary of what you accomplished."""
|
|
| 580 |
import re
|
| 581 |
tool_calls = []
|
| 582 |
|
| 583 |
-
# First strip thinking tags for tool call parsing
|
| 584 |
-
text_clean = strip_thinking(text)
|
| 585 |
-
|
| 586 |
def extract_json_objects(text):
|
| 587 |
"""Extract all JSON objects from text, handling nested braces"""
|
| 588 |
objects = []
|
|
@@ -608,8 +618,14 @@ When you have completed the task, provide a summary of what you accomplished."""
|
|
| 608 |
i += 1
|
| 609 |
return objects
|
| 610 |
|
| 611 |
-
#
|
| 612 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 613 |
logger.info(f"Found {len(all_json_objects)} JSON objects in response")
|
| 614 |
|
| 615 |
# Process each JSON object and infer tool
|
|
|
|
| 178 |
- Send emails and manage email threads
|
| 179 |
- Schedule meetings and generate calendar invites
|
| 180 |
|
| 181 |
+
CRITICAL: You MUST call tools to save data. Do NOT just describe what you would do - actually call the tools!
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
+
TOOL CALL FORMAT - You must output valid JSON for each tool call:
|
| 184 |
+
```json
|
| 185 |
+
{"prospect_id": "prospect_1", "company_id": "company_1", "company_name": "Acme Corp", "company_domain": "acme.com", "fit_score": 85}
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
Example workflow:
|
| 189 |
+
1. Call search_web to find companies
|
| 190 |
+
2. For EACH company found, call save_prospect with JSON parameters
|
| 191 |
+
3. For EACH contact, call save_contact with JSON like:
|
| 192 |
+
{"contact_id": "contact_1", "company_id": "company_1", "email": "[email protected]", "first_name": "John", "last_name": "Smith", "title": "CEO"}
|
| 193 |
+
4. Call send_email to draft outreach
|
| 194 |
+
|
| 195 |
+
IMPORTANT RULES:
|
| 196 |
+
- ALWAYS use tool calls with proper JSON parameters - never just describe the action
|
| 197 |
+
- Use realistic email formats: [email protected]
|
| 198 |
+
- Each tool call must have all required fields
|
| 199 |
+
- Do NOT hallucinate or make up contact details without calling save_contact tool
|
| 200 |
+
|
| 201 |
+
After completing tool calls, provide a brief summary."""
|
| 202 |
|
| 203 |
# Initialize conversation
|
| 204 |
messages = [
|
|
|
|
| 593 |
import re
|
| 594 |
tool_calls = []
|
| 595 |
|
|
|
|
|
|
|
|
|
|
| 596 |
def extract_json_objects(text):
|
| 597 |
"""Extract all JSON objects from text, handling nested braces"""
|
| 598 |
objects = []
|
|
|
|
| 618 |
i += 1
|
| 619 |
return objects
|
| 620 |
|
| 621 |
+
# IMPORTANT: Search BOTH raw text AND stripped text for JSON objects
|
| 622 |
+
# Qwen3 may put tool calls inside <think> tags
|
| 623 |
+
all_json_objects = extract_json_objects(text) # Search raw first
|
| 624 |
+
|
| 625 |
+
# Also search stripped version in case JSON is outside think tags
|
| 626 |
+
text_clean = strip_thinking(text)
|
| 627 |
+
if text_clean != text:
|
| 628 |
+
all_json_objects.extend(extract_json_objects(text_clean))
|
| 629 |
logger.info(f"Found {len(all_json_objects)} JSON objects in response")
|
| 630 |
|
| 631 |
# Process each JSON object and infer tool
|