DevKX commited on
Commit
720964a
Β·
1 Parent(s): 487b369

Added guardrail for task formatting

Browse files
crew/agents/data_access_agent.py CHANGED
@@ -104,7 +104,15 @@ class DataAccessAgent:
104
  " - `get_credit_score` (Financial Health)\n"
105
  " - `get_account_status` (Bank Standing)\n"
106
  " - `get_pr_status` (Government Verification)\n"
107
- "3. **Step 3 (The Report)**: Consolidate all 5 results into one JSON."
 
 
 
 
 
 
 
 
108
  ),
109
  llm=llm,
110
  verbose=True,
 
104
  " - `get_credit_score` (Financial Health)\n"
105
  " - `get_account_status` (Bank Standing)\n"
106
  " - `get_pr_status` (Government Verification)\n"
107
+ "3. **Step 3 (The Report)**: Consolidate all 5 results into one JSON.\n"
108
+
109
+ "### πŸ›‘ TOOL USAGE DECREE:\n"
110
+ "1. **INPUT IS PLAIN TEXT**: Your tool input must be a simple, continuous string. Do not use { } or [ ].\n"
111
+ "2. **NO NESTED KEYS**: Never use the word 'description' or 'query' inside your action input.\n"
112
+ "3. **TRANSLATE TO PROSE**: If you received JSON data from a coworker, describe that data in a sentence when passing it to the next person.\n"
113
+ "4. **CLEAN STRINGS**: Do not use backslashes (\), quotes inside quotes, or markdown (```) in tool calls."
114
+
115
+
116
  ),
117
  llm=llm,
118
  verbose=True,
crew/agents/loan_officer_agent.py CHANGED
@@ -93,11 +93,11 @@ class LoanOfficerSupervisor:
93
  "You are the Chief Loan Officer. You run the department.\n"
94
  "**Your superpower is DELEGATION based on INTELLIGENCE.**\n\n"
95
 
96
- "### πŸ›‘ CRITICAL TOOL RULES (PREVENT CRASHES):\n"
97
- "1. **PLAIN TEXT ONLY**: The input to the coworker must be a simple, natural sentence.\n"
98
- "2. β›” WRONG: {'task': 'Get the score'} (DO NOT USE CURLY BRACES)\n"
99
- "3. βœ… CORRECT: 'Get the credit score for ID 9982.' (Just a string)\n"
100
- "4. Do not try to format the output. Just ask the question.\n\n"
101
 
102
  "### TEAM ROSTER (Exact Names for Delegation):\n"
103
  "1. **Senior Context Analyst**: First call. Reads the query and outputs a JSON briefing.\n"
@@ -127,11 +127,13 @@ class LoanOfficerSupervisor:
127
  " If a coworker returns an error, do not retry the exact same request. Ask them to clarify.\n"
128
  "- Do not invent data.\n"
129
 
130
- "### πŸ›‘ CRITICAL TOOL RULES:\n"
131
- "1. **NO NESTED JSON**: When using the delegate tool, the 'task' field must be a plain English sentence.\n"
132
- "2. **STRIP ALL QUOTES**: Do not include internal JSON or backslashes in your delegation request.\n"
133
- "3. βœ… CORRECT: \"task\": \"Search for high risk definitions\", \"coworker\": \"Bank Policy Researcher\"\n"
134
-
 
 
135
  "### FINAL ANSWER PROTOCOL:\n"
136
  "1. You MUST NOT output the final answer yourself until the Internal Operations Communicator has written it.\n"
137
  "2. Once the Internal Operations Communicator gives you the final report or response, output that immediately as your Final Answer."
 
93
  "You are the Chief Loan Officer. You run the department.\n"
94
  "**Your superpower is DELEGATION based on INTELLIGENCE.**\n\n"
95
 
96
+ # "### πŸ›‘ CRITICAL TOOL RULES (PREVENT CRASHES):\n"
97
+ # "1. **PLAIN TEXT ONLY**: The input to the coworker must be a simple, natural sentence.\n"
98
+ # "2. β›” WRONG: {'task': 'Get the score'} (DO NOT USE CURLY BRACES)\n"
99
+ # "3. βœ… CORRECT: 'Get the credit score for ID 9982.' (Just a string)\n"
100
+ # "4. Do not try to format the output. Just ask the question.\n\n"
101
 
102
  "### TEAM ROSTER (Exact Names for Delegation):\n"
103
  "1. **Senior Context Analyst**: First call. Reads the query and outputs a JSON briefing.\n"
 
127
  " If a coworker returns an error, do not retry the exact same request. Ask them to clarify.\n"
128
  "- Do not invent data.\n"
129
 
130
+ "### πŸ›‘ TOOL USAGE DECREE:\n"
131
+ "1. **INPUT IS PLAIN TEXT**: Your tool input must be a simple, continuous string. Do not use { } or [ ].\n"
132
+ "2. **NO NESTED KEYS**: Never use the word 'description' or 'query' inside your action input.\n"
133
+ "3. **TRANSLATE TO PROSE**: If you received JSON data from a coworker, describe that data in a sentence when passing it to the next person.\n"
134
+ "4. **CLEAN STRINGS**: Do not use backslashes (\), quotes inside quotes, or markdown (```) in tool calls."
135
+
136
+
137
  "### FINAL ANSWER PROTOCOL:\n"
138
  "1. You MUST NOT output the final answer yourself until the Internal Operations Communicator has written it.\n"
139
  "2. Once the Internal Operations Communicator gives you the final report or response, output that immediately as your Final Answer."
crew/agents/rag_agent.py CHANGED
@@ -197,6 +197,13 @@ class RAGAgent:
197
  "You do NOT take in customer name and find specific policy for that customer.\n"
198
  "⚠️ IMPORTANT: NEVER include or search for any personal identifiers such as customer names, IDs, or emails. "
199
  "Always convert any customer-specific query into generic attributes like credit score, account status, or loan type before searching.\n"
 
 
 
 
 
 
 
200
  ),
201
  tools=tools_list,
202
  verbose=True,
 
197
  "You do NOT take in customer name and find specific policy for that customer.\n"
198
  "⚠️ IMPORTANT: NEVER include or search for any personal identifiers such as customer names, IDs, or emails. "
199
  "Always convert any customer-specific query into generic attributes like credit score, account status, or loan type before searching.\n"
200
+
201
+ "### πŸ›‘ TOOL USAGE DECREE:\n"
202
+ "1. **INPUT IS PLAIN TEXT**: Your tool input must be a simple, continuous string. Do not use { } or [ ].\n"
203
+ "2. **NO NESTED KEYS**: Never use the word 'description' or 'query' inside your action input.\n"
204
+ "3. **TRANSLATE TO PROSE**: If you received JSON data from a coworker, describe that data in a sentence when passing it to the next person.\n"
205
+ "4. **CLEAN STRINGS**: Do not use backslashes (\), quotes inside quotes, or markdown (```) in tool calls."
206
+
207
  ),
208
  tools=tools_list,
209
  verbose=True,
crew/agents/resolution_agent.py CHANGED
@@ -31,8 +31,15 @@ class ResolutionAgent:
31
  "**YOUR CONTEXT**: The 'Data Investigator' found the facts, the 'Policy Researcher' found the rules, "
32
  "and the 'Underwriter' made the decision.\n"
33
  "**YOUR JOB**: The human Bank Staff needs to see all this information in one place, formatted in perfect English.\n"
34
- "You act as the bridge between the AI agents and the Human Officer. "
35
- "Make the report clear, professional, and comprehensive."
 
 
 
 
 
 
 
36
  ),
37
  llm=llm,
38
  verbose=True,
 
31
  "**YOUR CONTEXT**: The 'Data Investigator' found the facts, the 'Policy Researcher' found the rules, "
32
  "and the 'Underwriter' made the decision.\n"
33
  "**YOUR JOB**: The human Bank Staff needs to see all this information in one place, formatted in perfect English.\n"
34
+ "You act as the bridge between the AI agents and the Human Officer.\n"
35
+ "Make the report clear, professional, and comprehensive.\n"
36
+
37
+ "### πŸ›‘ TOOL USAGE DECREE:\n"
38
+ "1. **INPUT IS PLAIN TEXT**: Your tool input must be a simple, continuous string. Do not use { } or [ ].\n"
39
+ "2. **NO NESTED KEYS**: Never use the word 'description' or 'query' inside your action input.\n"
40
+ "3. **TRANSLATE TO PROSE**: If you received JSON data from a coworker, describe that data in a sentence when passing it to the next person.\n"
41
+ "4. **CLEAN STRINGS**: Do not use backslashes (\), quotes inside quotes, or markdown (```) in tool calls."
42
+
43
  ),
44
  llm=llm,
45
  verbose=True,
crew/agents/underwriter_agent.py CHANGED
@@ -37,7 +37,15 @@ class UnderwriterAgent:
37
  "2. **Risk Matrix**: Classification based purely on score + status.\n\n"
38
 
39
  "### OUTPUT PROTOCOL:\n"
40
- "Be robotic. Be literal. No emotions. No 'I assumed...'."
 
 
 
 
 
 
 
 
41
  ),
42
  llm=llm,
43
  verbose=True,
 
37
  "2. **Risk Matrix**: Classification based purely on score + status.\n\n"
38
 
39
  "### OUTPUT PROTOCOL:\n"
40
+ "Be robotic. Be literal. No emotions. No 'I assumed...'.\n"
41
+
42
+ "### πŸ›‘ TOOL USAGE DECREE:\n"
43
+ "1. **INPUT IS PLAIN TEXT**: Your tool input must be a simple, continuous string. Do not use { } or [ ].\n"
44
+ "2. **NO NESTED KEYS**: Never use the word 'description' or 'query' inside your action input.\n"
45
+ "3. **TRANSLATE TO PROSE**: If you received JSON data from a coworker, describe that data in a sentence when passing it to the next person.\n"
46
+ "4. **CLEAN STRINGS**: Do not use backslashes (\), quotes inside quotes, or markdown (```) in tool calls."
47
+
48
+
49
  ),
50
  llm=llm,
51
  verbose=True,
crew/tasks/underwriting_tasks.py CHANGED
@@ -28,8 +28,8 @@ def create_underwriting_task(agent, context_tasks):
28
  " - **DEFINITION**: A 'Foreigner' is anyone whose nationality is NOT 'Singaporean'.\n"
29
  " - **THE STRICT RULE**: \n"
30
  " - If Customer is Singaporean -> **PASS** (Eligible).\n"
31
- " - If Customer is Foreigner AND is PR (Permanent Resident) -> **PASS** (Eligible).\n"
32
- " - **If Customer is Foreigner AND is NOT PR -> REJECT IMMEDIATELY**.\n"
33
  " - (Reasoning: We do not lend to non-residents. Foreigners must hold PR status).\n\n"
34
 
35
  "2. **Risk Mapping**: \n"
@@ -38,7 +38,7 @@ def create_underwriting_task(agent, context_tasks):
38
  " - DETERMINE: Is the Overall Risk 'Low', 'Medium', or 'High'?\n\n"
39
 
40
  "3. **Final Verdict**: \n"
41
- " - If its High Risk OR Foreigner+PR, please REJECT.\n"
42
  " - Low/Medium Risk is APPROVE.\n\n"
43
 
44
  "**REQUIRED OUTPUT**:\n"
@@ -48,6 +48,7 @@ def create_underwriting_task(agent, context_tasks):
48
  "{\n"
49
  ' "decision": "APPROVED" | "REJECTED",\n'
50
  ' "risk_level": "Low" | "Medium" | "High",\n'
 
51
  ' "reason_code": "The specific rule from policy that triggered this decision"\n'
52
  "}\n"
53
  "```"
 
28
  " - **DEFINITION**: A 'Foreigner' is anyone whose nationality is NOT 'Singaporean'.\n"
29
  " - **THE STRICT RULE**: \n"
30
  " - If Customer is Singaporean -> **PASS** (Eligible).\n"
31
+ " - If Customer is Non-Singaporean AND is PR (Permanent Resident) -> **PASS** (Eligible).\n"
32
+ " - **If Customer is Non-Singaporean AND is NOT Permanent Resident -> REJECT IMMEDIATELY**.\n"
33
  " - (Reasoning: We do not lend to non-residents. Foreigners must hold PR status).\n\n"
34
 
35
  "2. **Risk Mapping**: \n"
 
38
  " - DETERMINE: Is the Overall Risk 'Low', 'Medium', or 'High'?\n\n"
39
 
40
  "3. **Final Verdict**: \n"
41
+ " - If its High Risk OR Non-Singaporean+PR, please REJECT.\n"
42
  " - Low/Medium Risk is APPROVE.\n\n"
43
 
44
  "**REQUIRED OUTPUT**:\n"
 
48
  "{\n"
49
  ' "decision": "APPROVED" | "REJECTED",\n'
50
  ' "risk_level": "Low" | "Medium" | "High",\n'
51
+ ' "interest_rate": "The numerical rate (e.g. 4.85%) or N/A",\n'
52
  ' "reason_code": "The specific rule from policy that triggered this decision"\n'
53
  "}\n"
54
  "```"