DevKX commited on
Commit
487b369
·
1 Parent(s): b9eafd0

Fix prompt

Browse files
Files changed (1) hide show
  1. crew/agents/loan_officer_agent.py +30 -21
crew/agents/loan_officer_agent.py CHANGED
@@ -94,38 +94,47 @@ class LoanOfficerSupervisor:
94
  "**Your superpower is DELEGATION based on INTELLIGENCE.**\n\n"
95
 
96
  "### 🛑 CRITICAL TOOL RULES (PREVENT CRASHES):\n"
97
- "1. When delegating, the 'task' and 'context' arguments must be SIMPLE STRINGS.\n"
98
- "2. WRONG: {'task': {'description': 'Get the credit score'}}\n"
99
- "3. ✅ CORRECT: {'task': 'Get the credit score'}\n"
100
- "4. NEVER wrap text in a dictionary labeled 'description'.\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"
104
- "2. **Senior Data Investigator**: Only if `requires_database = true`. Fetches Credit Score, Nationality, PR Status, Account Status.\n"
105
- "3. **Bank Policy Researcher**: Only if `requires_policy = true`. Fetches generic rules like Interest Rates, Loan Limits. "
106
  "⚠️ NEVER give customer names, IDs, or emails to this agent. Only sanitized attributes (e.g., 'Credit Score: 720, Status: Active').\n"
107
  "4. **Senior Credit Underwriter**: After Data/Policy evidence, evaluates Risk Classification & Interest Rate.\n"
108
- "5. **Internal Operations Communicator**: Last step. Writes final report.\n\n"
109
 
110
  "### DELEGATION LOGIC:\n"
111
  "STEP 1: Ask Senior Context Analyst for the 'Intelligence Briefing'.\n"
112
- " - If intent is General Chat: delegate only to Internal Operations Communicator.\n"
113
- "STEP 2: If strictly `requires_database = true`, delegate to Senior Data Investigator with only customer identifiers needed (IDs allowed here, not names in policy queries).\n"
114
- "STEP 3: If strictly `requires_policy = true`, delegate to Bank Policy Researcher. Do not find a subsitute co worker\n"
 
 
 
 
115
  " - ⚠️ ALWAYS sanitize customer-specific info: replace names/emails/IDs/Nationality with generic attributes before delegating.\n"
116
  " - Example: 'What is the interest rate for Credit Score 720 and Active Status?'\n"
117
- "STEP 4: Delegate to Senior Credit Underwriter if intent is loan recommendation. If not, please skip and go directly to next step.\n"
118
- "STEP 5: Internal Operations Communicator writes final report. No delegation needed.\n\n"
119
-
 
120
  "### FAIL-SAFES:\n"
121
- "- If an agent tries to provide info outside their scope, STOP and redirect back to you.\n"
122
- "- Do NOT allow hallucination. Never invent policy data or personal data.\n"
123
- "- Validate JSON output from each agent before using in next step.\n"
124
-
 
 
 
 
 
125
  "### FINAL ANSWER PROTOCOL:\n"
126
- "1. If an agent returns a complete answer resolving the query, do not delegate again.\n"
127
- "2. Take that information and provide it as Final Answer immediately.\n"
128
- "3. Never ask Policy Researcher to verify or communicate—they only fetch facts."
129
  ),
130
  llm=self.llm,
131
  allow_delegation=True,
@@ -173,7 +182,7 @@ class LoanOfficerSupervisor:
173
 
174
  plan_data = clean_and_extract_json(t1_strategy.output.raw)
175
 
176
- is_policy_question = plan_data.get("intent") == "Policy Question" and plan_data.get("requires_policy", False)
177
 
178
  # # Rule base decision making to decide if its policy question or not
179
  # if is_policy_question:
 
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"
104
+ "2. **Senior Data Investigator**: Only if `requires_database = true` and fetches Credit Score, Nationality, PR Status, Account Status.\n"
105
+ "3. **Bank Policy Researcher**: Only if `requires_policy = true` and fetches generic rules like Interest Rates, Loan Limits. "
106
  "⚠️ NEVER give customer names, IDs, or emails to this agent. Only sanitized attributes (e.g., 'Credit Score: 720, Status: Active').\n"
107
  "4. **Senior Credit Underwriter**: After Data/Policy evidence, evaluates Risk Classification & Interest Rate.\n"
108
+ "5. **Internal Operations Communicator**: Last step. Writes final report or final response.\n\n"
109
 
110
  "### DELEGATION LOGIC:\n"
111
  "STEP 1: Ask Senior Context Analyst for the 'Intelligence Briefing'.\n"
112
+ " - ⚠️ CRITICAL: Do NOT ask them the user's question directly.\n"
113
+ " - YOUR INPUT MUST BE: 'Analyze the following query and tell me who to call: {query}'\n"
114
+ " - Once you receive the briefing. DO not delegate to Senior Context Analyst'\n"
115
+ "STEP 2: If the plan contain `requires_database = true`, delegate to Senior Data Investigator with only customer identifiers needed.\n"
116
+ "STEP 3: If `requires_policy = true`, you MUST delegate to the 'Bank Policy Researcher'.\n"
117
+ " - 🛑 DO NOT call the 'Senior Context Analyst' again for this step.\n"
118
+ " - 💡 Input for Researcher: 'What is the bank policy for [Insert Topic]?'\n"
119
  " - ⚠️ ALWAYS sanitize customer-specific info: replace names/emails/IDs/Nationality with generic attributes before delegating.\n"
120
  " - Example: 'What is the interest rate for Credit Score 720 and Active Status?'\n"
121
+ "STEP 4: **UNDERWRITING GATE**:\n"
122
+ " - IF `intent = 'Loan Request'`, delegate to Senior Credit Underwriter for a verdict.\n"
123
+ " - IF `intent = 'Policy Question'` or `'General Chat'`, **SKIP THIS STEP** and move directly to Step 5.\n"
124
+
125
  "### FAIL-SAFES:\n"
126
+ "-If an agent tries to provide info outside their scope, STOP and redirect back to you.\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
+ "### 🛑 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."
 
138
  ),
139
  llm=self.llm,
140
  allow_delegation=True,
 
182
 
183
  plan_data = clean_and_extract_json(t1_strategy.output.raw)
184
 
185
+ # is_policy_question = plan_data.get("intent") == "Policy Question" and plan_data.get("requires_policy", False)
186
 
187
  # # Rule base decision making to decide if its policy question or not
188
  # if is_policy_question: