Skip to content

Commit c75a07f

Browse files
committed
Ethics: Technical Implementation of Tone-Damping and Cultural Sensitivity
1 parent 6744880 commit c75a07f

3 files changed

Lines changed: 41 additions & 21 deletions

File tree

src/agents/brain.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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}\nRisk: {risk}\nBurnout: {burnout}",
172-
},
180+
{"role": "system", "content": prompt},
181+
{"role": "user", "content": f"Excuse: {excuse}\nRisk: {risk}\nBurnout: {burnout}"},
173182
],
174183
)
184+

src/core/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class Settings(BaseSettings):
1111
GROQ_API_KEY: str | None = None
1212
MODEL_NAME: str = "gpt-4o"
1313
LLM_PROVIDER: str = "openai" # Options: openai, groq, mock
14+
15+
# Ethical & Sensitivity Settings
16+
CULTURAL_DIRECTNESS_LEVEL: str = "high" # Options: low, medium, high
17+
COOLING_OFF_PERIOD_HOURS: int = 48
18+
1419

1520
# Infrastructure
1621
REDIS_URL: str = "redis://localhost:6380"

src/schemas/agents.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,10 @@ class UserHistory(SQLModel, table=True):
8181
total_commitments: int = Field(default=0)
8282
failed_commitments: int = Field(default=0)
8383
reliability_score: float = Field(default=100.0)
84+
85+
# Ethical Tracking
86+
consecutive_firm_interventions: int = Field(default=0)
87+
last_intervention_at: Optional[str] = Field(default=None)
88+
8489

8590

0 commit comments

Comments
 (0)