@@ -130,45 +130,55 @@ async def adapt_tone(
130130 risk : RiskAssessment ,
131131 burnout : BurnoutDetection ,
132132 reliability_score : float = 100.0 ,
133+ consecutive_firm_calls : int = 0
133134 ) -> AgentDecision :
134135 if self .provider .is_mock :
135136 tone = ToneType .SUPPORTIVE
137+
138+ # 1. THE BURNOUT SAFETY VALVE (Mandatory)
136139 if burnout .is_at_risk :
137140 tone = ToneType .SUPPORTIVE
138141 msg = f"I hear you. It sounds like you're reaching your limit. { burnout .recommendation } ."
142+
143+ # 2. TONE-DAMPING (Ethical Cooling-off)
144+ elif consecutive_firm_calls >= 3 :
145+ tone = ToneType .NEUTRAL
146+ msg = "Let's reset and focus on a small, achievable win today. No pressure."
147+
148+ # 3. RELIABILITY SCALING
139149 elif reliability_score < 50.0 :
140- tone = (
141- ToneType .CONFRONTATIONAL
142- if reliability_score < 20
143- else ToneType .FIRM
144- )
150+ tone = ToneType .CONFRONTATIONAL if reliability_score < 20 else ToneType .FIRM
145151 msg = "This is your third delay this month. We need an immediate recovery plan."
146- elif excuse .category == ExcuseCategory .DEFLECTION :
147- tone = ToneType .FIRM
148- msg = "We need to stay focused on the commitment. How can we get back on track?"
152+
153+ # 4. DEFAULT
149154 else :
150- msg = "Thank you for the update. Let's adjust the timeline accordingly. "
155+ msg = f "Thank you for the update. [Context: { settings . CULTURAL_DIRECTNESS_LEVEL } directness enabled] "
151156
152157 return AgentDecision (
153- action = "none"
154- if not (burnout .is_at_risk or reliability_score < 50 )
155- else "escalate_to_manager" ,
158+ action = "none" if not (burnout .is_at_risk or reliability_score < 50 ) else "escalate_to_manager" ,
156159 tone = tone ,
157160 message = msg ,
158- analysis_summary = f"Mock: Decision based on reliability of { reliability_score } %" ,
161+ analysis_summary = f"Mock: Decision based on reliability of { reliability_score } % and { consecutive_firm_calls } firm calls."
159162 )
160163
164+ # 5. ENTERPRISE LLM PROMPT (Self-Correction / Sensitivity)
165+ prompt = f"""
166+ Determine action and tone.
167+ User Reliability: { reliability_score } %
168+ Consecutive Strict Interventions: { consecutive_firm_calls }
169+ Manager's Cultural Directness Setting: { settings .CULTURAL_DIRECTNESS_LEVEL }
170+
171+ RULES:
172+ - If Consecutive Strict >= 3, you MUST use SUPPORTIVE/NEUTRAL tone to avoid morale burnout.
173+ - Respect the Cultural Directness: if 'low', soften all firm feedback.
174+ """
175+
161176 return await self .provider .chat_completion (
162177 response_model = AgentDecision ,
163178 model = self .model ,
164179 messages = [
165- {
166- "role" : "system" ,
167- "content" : f"Determine action and tone. User Reliability: { reliability_score } %" ,
168- },
169- {
170- "role" : "user" ,
171- "content" : f"Excuse: { excuse } \n Risk: { risk } \n Burnout: { burnout } " ,
172- },
180+ {"role" : "system" , "content" : prompt },
181+ {"role" : "user" , "content" : f"Excuse: { excuse } \n Risk: { risk } \n Burnout: { burnout } " },
173182 ],
174183 )
184+
0 commit comments