Spaces:
No application file
No application file
Commit ·
3392045
1
Parent(s): 8769d1b
9/4/2026
Browse filesFiles changed (4)
- baseline/policy.py+130-79
- baseline/results.json+166-141
- inference.py+3-3
- server/graders.py+6-2
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808112 unmodified lines9495969798991001011021031041051061071081091101111121131141151161175 unmodified lines123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202"""Baseline policy for SupportEnv.A simple rule-based agent that demonstrates the environment works.Expected scores:- Easy: ~0.85- Medium: ~0.65- Hard: ~0.40"""from typing import List, Dict, Anyimport refrom models import SupportAction, SupportObservationclass BaselinePolicy:"""Rule-based baseline agent for customer support.Strategy:1. Classify based on keywords2. Respond with templates3. Escalate based on sentiment and keywords"""CATEGORY_KEYWORDS = {"billing": ["payment", "charge", "refund", "invoice", "subscription","price", "cost", "money", "fee", "bill", "receipt", "charged","double", "twice", "cancel", "plan", "premium"],"technical": ["error", "bug", "crash", "not working", "broken","update", "app", "load", "slow", "freeze", "search","connection", "feature", "download", "sync", "export"],"account": ["password", "login", "account", "access", "email","profile", "username", "reset", "locked", "delete","2fa", "merge", "duplicate", "address", "update"],"general": ["question", "information", "hours", "location", "help","store", "visit", "weekend", "available", "product", "receipt"]}ESCALATION_KEYWORDS = ["lawyer", "legal", "fraud", "stolen", "sue", "unacceptable","discrimination", "authorities", "media", "urgent", "immediately"]RESPONSE_TEMPLATES = {"billing": "Thank you for contacting us about your billing concern. I understand this is frustrating. Let me look into this for you. I'll process {action} within 3-5 business days. Is there anything else I can help with?","technical": "I'm sorry to hear you're experiencing technical difficulties. I understand how frustrating this can be. Please try the following: 1) Clear your app cache, 2) Restart the app, 3) If the issue persists, reinstall the app. This should resolve the issue.","account": "I understand you need help with your account. For security verification, I've confirmed your details. I'm now {action}. You should receive a confirmation email shortly. Please let me know if you need further assistance.","general": "Thank you for reaching out! I'm happy to help with your inquiry. {answer}. Is there anything else you'd like to know?"}def __init__(self):self.classified = Falseself.kb_searched = Falseself.info_requested = Falseself.current_category = Noneself.responded = Falseself.escalated = Falsedef reset(self):self.classified = Falseself.kb_searched = Falseself.info_requested = Falseself.current_category = Noneself.responded = Falseself.escalated = Falsedef act(self, observation: SupportObservation) -> SupportAction:"""Choose action based on observation.Args:observation: Current observation from environmentReturns:Action to take"""ticket_text = f"{observation.ticket_subject} {observation.ticket_text}".lower()diff = observation.task_difficulty.lower() if observation.task_difficulty else "easy"12 unmodified linesself.escalated = Truereturn SupportAction(action_type="escalate",content="Customer requires immediate human assistance due to the severity and sensitivity of the issue. Elevated emotional state detected.")# Step 3: Lookup KB to show diligence (improves score on Medium/Hard)if not self.kb_searched:self.kb_searched = Truetopic = self.current_category or "support"return SupportAction(action_type="lookup_kb",content=f"Standard policy and troubleshooting steps for {topic} issues")# Step 4: Request Info if it's a harder ticket (they usually lack info)if not self.info_requested and diff in ["medium", "hard"]:self.info_requested = Truereturn SupportAction(action_type="request_info",content="To help you better, could you please provide your account details or the specific error message you are seeing?")# Step 5: Respond5 unmodified linesself.responded = Truereturn SupportAction(action_type="respond",content=response)# Step 6: Resolvereturn SupportAction(action_type="resolve",content=f"Issue resolved. Category: {observation.current_classification or self.current_category}. Customer's concern has been addressed through appropriate response and action.")def _classify(self, text: str) -> str:"""Classify ticket based on keywords."""scores = {category: 0 for category in self.CATEGORY_KEYWORDS}for category, keywords in self.CATEGORY_KEYWORDS.items():for keyword in keywords:if keyword in text:scores[category] += 1# Return category with highest scorebest_category = max(scores, key=scores.get)# Default to general if no keywords foundif scores[best_category] == 0:return "general"return best_categorydef _should_escalate(self, text: str, sentiment: float) -> bool:"""Determine if ticket should be escalated."""# Escalate only for extremely negative sentiment (hard tickets)if sentiment < -0.8:return True# Escalate only for severe keywords (legal/fraud threats, not just frustration)severe_keywords = ["lawyer", "legal", "fraud", "stolen", "sue","discrimination", "authorities", "media", "class action","hacked", "identity", "breach", "suicide", "bankruptcy", "FDA"]for keyword in severe_keywords:if keyword in text:return Truereturn Falsedef _generate_response(self, category: str, ticket_text: str) -> str:"""Generate response based on category."""template = self.RESPONSE_TEMPLATES.get(category,self.RESPONSE_TEMPLATES["general"])# Fill in template variablesif category == "billing":if "refund" in ticket_text:action = "your refund"elif "charge" in ticket_text:action = "the charge investigation"else:action = "your request"return template.format(action=action)elif category == "account":if "password" in ticket_text:action = "sending a password reset link to your email"elif "email" in ticket_text:action = "updating your email address"else:action = "updating your account"return template.format(action=action)elif category == "general":if "hours" in ticket_text:answer = "Our store hours are Monday-Saturday 9AM-9PM, Sunday 10AM-6PM"else:answer = "I'll be happy to assist you with your question"return template.format(answer=answer)return template12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010112 unmodified lines1141151161171181191201211221231241251261271281291301311321331341351361371385 unmodified lines144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253import reimport randomfrom typing import List, Dict, Any, Optionalfrom models import SupportAction, SupportObservationclass BaselinePolicy:"""Rule-based baseline agent for customer support with diversified behaviors.Strategy:1. Classify based on expanded keywords2. Respond with randomized templates3. Escalate based on sentiment and critical keywords4. Vary intermediate actions (KB lookup, info gathering)"""CATEGORY_KEYWORDS = {"billing": ["payment", "charge", "refund", "invoice", "subscription","price", "cost", "money", "fee", "bill", "receipt", "charged","double", "twice", "cancel", "plan", "premium", "card", "bank","transaction", "overcharged", "statement", "autopay"],"technical": ["error", "bug", "crash", "not working", "broken","update", "app", "load", "slow", "freeze", "search","connection", "feature", "download", "sync", "export","login issue", "failed to", "invalid", "glitch", "performance"],"account": ["password", "login", "account", "access", "email","profile", "username", "reset", "locked", "delete","2fa", "merge", "duplicate", "address", "update", "security","verification", "permissions", "credentials", "sign in"],"general": ["question", "information", "hours", "location", "help","store", "visit", "weekend", "available", "product", "receipt","policy", "shipping", "return", "contact", "support"]}RESPONSE_TEMPLATES = {"billing": ["Thank you for contacting us about your billing concern regarding {action}. I understand this is frustrating, and I'm here to help. I'll process this within 3-5 business days. Is there anything else I can assist with?","I've received your billing inquiry about {action}. I apologize for any frustration this has caused. I'm investigating the details right now to ensure everything is correct.","I understand you have a question about {action}. I'm reviewing your billing history and will get this sorted out for you immediately."],"technical": ["I'm sorry to hear you're experiencing technical difficulties with {action}. I know how disruptive that can be. Please try clearing your cache and restarting the application; that often resolves {action}.","It sounds like you've encountered a technical issue related to {action}. I'm looking into our system logs now. In the meantime, could you try accessing the service from a different browser?","I apologize for the technical trouble you're having with {action}. I've logged this with our engineering team for a closer look while I check for immediate workarounds."],"account": ["I understand you need help with your account security for {action}. For your protection, I've confirmed your details and am now {action}. You should receive a confirmation shortly.","Your account access regarding {action} is important to us. I'm currently {action} as requested. Please let me know if you need anything else to manage your profile.","I've processed your request to {action}. Security is our top priority, so please check your registered email for a verification link to finalize the {action} process."],"general": ["Thank you for reaching out! I'm happy to help with your inquiry. {answer}. Does that provide the information you were looking for?","Great question! {answer}. We always aim to provide clear information, so please let me know if I can elaborate on any part of that.","I appreciate you asking about that. {answer}. Is there anything else you'd like to know about our services or policies?"]}ESCALATION_MESSAGES = ["Customer requires immediate human assistance due to the severity and sensitivity of the issue. Elevated emotional state detected.","Case involves complex or sensitive matters that exceed automated handling capabilities. Escalating for specialist review.","Detected critical keywords or high frustration levels. Transferring this session to a senior support representative for immediate resolution."]KB_QUERIES = ["Standard policy and troubleshooting steps for {topic} issues","How to resolve common {topic} complaints and technical errors","Knowledge base article on {topic} procedures and customer guidelines","Internal documentation for handling {topic} escalation and resolution"]INFO_REQUESTS = ["To help you better, could you please provide your account details or the specific error message you are seeing?","Could you clarify a few more details? Specifically, when did this issue first occur and what device are you using?","I need a bit more information to proceed. Could you please share the order ID or the email address associated with your account?"]def __init__(self, seed: Optional[int] = None):self.rng = random.Random(seed) if seed is not None else random.Random()self.reset()def reset(self, seed: Optional[int] = None):if seed is not None:self.rng = random.Random(seed)self.classified = Falseself.kb_searched = Falseself.info_requested = Falseself.current_category = Noneself.responded = Falseself.escalated = Falseself.step_count = 0def act(self, observation: SupportObservation) -> SupportAction:"""Choose action based on observation with randomized variety."""self.step_count += 1ticket_text = f"{observation.ticket_subject} {observation.ticket_text}".lower()diff = observation.task_difficulty.lower() if observation.task_difficulty else "easy"12 unmodified linesself.escalated = Truereturn SupportAction(action_type="escalate",content=self.rng.choice(self.ESCALATION_MESSAGES))# Step 3: Vary between KB lookup and Request Infoif not self.kb_searched and (self.rng.random() > 0.5 or diff == "easy"):self.kb_searched = Truetopic = self.current_category or "general support"query_template = self.rng.choice(self.KB_QUERIES)return SupportAction(action_type="lookup_kb",content=query_template.format(topic=topic))# Step 4: Request Info (prio for medium/hard, or random chance)if not self.info_requested and (diff in ["medium", "hard"] or self.rng.random() > 0.7):self.info_requested = Truereturn SupportAction(action_type="request_info",content=self.rng.choice(self.INFO_REQUESTS))# Step 5: Respond5 unmodified linesself.responded = Truereturn SupportAction(action_type="respond",content=response,confidence=0.85 + self.rng.random() * 0.1)# Step 6: Resolveres_message = self.rng.choice(["Issue resolved. Category: {cat}. Customer's concern has been addressed through appropriate response and action.","I've successfully addressed the reported issue for the {cat} category. Marking this ticket as resolved.","Thank you for your patience. I have finalized the resolution steps for this {cat} case."]).format(cat=observation.current_classification or self.current_category)return SupportAction(action_type="resolve",content=res_message)def _classify(self, text: str) -> str:"""Classify ticket based on keywords with a bit of multi-hit weighting."""scores = {category: 0 for category in self.CATEGORY_KEYWORDS}for category, keywords in self.CATEGORY_KEYWORDS.items():for keyword in keywords:# Use word boundaries for better accuracyif re.search(rf'\b{re.escape(keyword)}\b', text):scores[category] += 2 # Strong hitelif keyword in text:scores[category] += 1 # Weak hit# Determine hitsmax_score = max(scores.values())if max_score == 0:return "general"candidates = [cat for cat, score in scores.items() if score == max_score]return self.rng.choice(candidates)def _should_escalate(self, text: str, sentiment: float) -> bool:"""Determine if ticket should be escalated."""# Escalate for extremely negative sentimentif sentiment < -0.75:return True# Critical escalation keywordssevere_keywords = ["lawyer", "legal", "fraud", "stolen", "sue","discrimination", "authorities", "media", "class action","hacked", "identity", "breach", "suicide", "bankruptcy", "fda","malfunction", "critical failure"]for keyword in severe_keywords:if re.search(rf'\b{re.escape(keyword)}\b', text):return Truereturn Falsedef _generate_response(self, category: str, ticket_text: str) -> str:"""Generate diversified response based on category."""templates = self.RESPONSE_TEMPLATES.get(category,self.RESPONSE_TEMPLATES["general"])template = self.rng.choice(templates)# Fill in template variablesif category == "billing":if "refund" in ticket_text:action = "your refund request"elif "charge" in ticket_text or "overcharg" in ticket_text:action = "the transaction discrepancy"elif "invoice" in ticket_text:action = "the invoice details"else:action = "your account billing status"return template.format(action=action)elif category == "technical":if "app" in ticket_text:action = "the application error"elif "crash" in ticket_text or "freeze" in ticket_text:action = "the system instability"elif "slow" in ticket_text or "load" in ticket_text:action = "the performance delay"else:action = "the technical issue"return template.format(action=action)elif category == "account":if "password" in ticket_text:action = "updating your password"elif "email" in ticket_text:action = "syncing your email account"elif "delete" in ticket_text:action = "processing your account deletion request"else:action = "modifying your profile settings"return template.format(action=action)elif category == "general":if "hours" in ticket_text:answer = "our standard hours are 9 AM to 9 PM daily"elif "location" in ticket_text or "where" in ticket_text:answer = "we are located at several convenient spots in the city center"elif "shipping" in ticket_text or "return" in ticket_text:answer = "our return policy allows for exchanges within 30 days"else:answer = "I'm looking into the most accurate information for your specific query"return template.format(answer=answer)return template
123453 unmodified lines9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657582 unmodified lines61626364656667686970711 unmodified line7374757677787980818283848586878889902 unmodified lines939495969798991001011021033 unmodified lines1071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551562 unmodified lines1591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022031 unmodified line2052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662671 unmodified line2692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003011 unmodified line303304305306307308309310311312313314315316317318319320321322323324325326327328329330{"timestamp": "2026-04-01T12:41:49.956279","seeds": [42,123,3 unmodified lines"easy": [{"difficulty": "easy","score": 0.7579,"total_reward": 0.68,"steps": 3,"passed": true,"breakdown": {"classification": 1.0,"response_quality": 0.75,"escalation_decision": 1.0,"resolution": 0.3196,"efficiency": 0.6},"feedback": "[EASY] classification: Excellent (1.00) | response_quality: Good (0.75) | escalation_decision: Excellent (1.00) | resolution: Poor (0.32) | efficiency: Good (0.60)","action_history": [{"step": 1,"action_type": "classify","content": "account"},{"step": 2,"action_type": "respond","content": "I understand you need help with your account. For security verification, I've confirmed your details"},{"step": 3,"action_type": "resolve","content": "Issue resolved. Category: account. Customer's concern has been addressed through appropriate respons"}]},{"difficulty": "easy","score": 0.7579,"total_reward": 0.68,"steps": 3,"passed": true,"breakdown": {"classification": 1.0,"response_quality": 0.75,"escalation_decision": 1.0,"resolution": 0.3196,"efficiency": 0.6},"feedback": "[EASY] classification: Excellent (1.00) | response_quality: Good (0.75) | escalation_decision: Excellent (1.00) | resolution: Poor (0.32) | efficiency: Good (0.60)","action_history": [{"step": 1,2 unmodified lines},{"step": 2,"action_type": "respond","content": "I understand you need help with your account. For security verification, I've confirmed your details"},{"step": 3,"action_type": "resolve","content": "Issue resolved. Category: account. Customer's concern has been addressed through appropriate respons"}1 unmodified line},{"difficulty": "easy","score": 0.5908,"total_reward": 0.53,"steps": 3,"passed": false,"breakdown": {"classification": 0.2,"response_quality": 0.95,"escalation_decision": 1.0,"resolution": 0.272,"efficiency": 0.6},"feedback": "[EASY] classification: Poor (0.20) | response_quality: Excellent (0.95) | escalation_decision: Excellent (1.00) | resolution: Poor (0.27) | efficiency: Good (0.60)","action_history": [{"step": 1,2 unmodified lines},{"step": 2,"action_type": "respond","content": "I'm sorry to hear you're experiencing technical difficulties. I understand how frustrating this can "},{"step": 3,"action_type": "resolve","content": "Issue resolved. Category: technical. Customer's concern has been addressed through appropriate respo"}3 unmodified lines"medium": [{"difficulty": "medium","score": 0.7369,"total_reward": 0.725,"steps": 3,"passed": true,"breakdown": {"classification": 1.0,"response_quality": 0.69,"escalation_decision": 1.0,"resolution": 0.2996,"efficiency": 0.8},"feedback": "[MEDIUM] classification: Excellent (1.00) | response_quality: Good (0.69) | escalation_decision: Excellent (1.00) | resolution: Poor (0.30) | efficiency: Excellent (0.80)","action_history": [{"step": 1,"action_type": "classify","content": "billing"},{"step": 2,"action_type": "respond","content": "Thank you for contacting us about your billing concern. I understand this is frustrating. Let me loo"},{"step": 3,"action_type": "resolve","content": "Issue resolved. Category: billing. Customer's concern has been addressed through appropriate respons"}]},{"difficulty": "medium","score": 0.7369,"total_reward": 0.725,"steps": 3,"passed": true,"breakdown": {"classification": 1.0,"response_quality": 0.69,"escalation_decision": 1.0,"resolution": 0.2996,"efficiency": 0.8},"feedback": "[MEDIUM] classification: Excellent (1.00) | response_quality: Good (0.69) | escalation_decision: Excellent (1.00) | resolution: Poor (0.30) | efficiency: Excellent (0.80)","action_history": [{"step": 1,2 unmodified lines},{"step": 2,"action_type": "respond","content": "Thank you for contacting us about your billing concern. I understand this is frustrating. Let me loo"},{"step": 3,"action_type": "resolve","content": "Issue resolved. Category: billing. Customer's concern has been addressed through appropriate respons"}]},{"difficulty": "medium","score": 0.647,"total_reward": -0.3,"steps": 3,"passed": true,"breakdown": {"classification": 1.0,"response_quality": 0.69,"escalation_decision": 0.3,"resolution": 0.2,"efficiency": 0.8},"feedback": "[MEDIUM] classification: Excellent (1.00) | response_quality: Good (0.69) | escalation_decision: Poor (0.30) | resolution: Poor (0.20) | efficiency: Excellent (0.80)","action_history": [{"step": 1,"action_type": "classify","content": "billing"},{"step": 2,"action_type": "respond","content": "Thank you for contacting us about your billing concern. I understand this is frustrating. Let me loo"},{"step": 3,"action_type": "escalate","content": "Customer requires immediate human assistance due to the severity and sensitivity of the issue. Eleva"}]}1 unmodified line"hard": [{"difficulty": "hard","score": 0.8275,"total_reward": 1.39,"steps": 3,"passed": true,"breakdown": {"classification": 1.0,"response_quality": 0.6375,"escalation_decision": 1.0,"resolution": 0.5,"efficiency": 1.0},"feedback": "[HARD] classification: Excellent (1.00) | response_quality: Good (0.64) | escalation_decision: Excellent (1.00) | resolution: Needs improvement (0.50) | efficiency: Excellent (1.00)","action_history": [{"step": 1,"action_type": "classify","content": "billing"},{"step": 2,"action_type": "respond","content": "Thank you for contacting us about your billing concern. I understand this is frustrating. Let me loo"},{"step": 3,"action_type": "escalate","content": "Customer requires immediate human assistance due to the severity and sensitivity of the issue. Eleva"}]},{"difficulty": "hard","score": 0.8275,"total_reward": 1.39,"steps": 3,"passed": true,"breakdown": {"classification": 1.0,"response_quality": 0.6375,"escalation_decision": 1.0,"resolution": 0.5,"efficiency": 1.0},"feedback": "[HARD] classification: Excellent (1.00) | response_quality: Good (0.64) | escalation_decision: Excellent (1.00) | resolution: Needs improvement (0.50) | efficiency: Excellent (1.00)","action_history": [{"step": 1,"action_type": "classify","content": "billing"},{"step": 2,"action_type": "respond","content": "Thank you for contacting us about your billing concern. I understand this is frustrating. Let me loo"},{"step": 3,"action_type": "escalate","content": "Customer requires immediate human assistance due to the severity and sensitivity of the issue. Eleva"}1 unmodified line},{"difficulty": "hard","score": 0.7415,"total_reward": 1.24,"steps": 3,"passed": true,"breakdown": {"classification": 0.2,"response_quality": 0.8075,"escalation_decision": 1.0,"resolution": 0.5,"efficiency": 1.0},"feedback": "[HARD] classification: Poor (0.20) | response_quality: Excellent (0.81) | escalation_decision: Excellent (1.00) | resolution: Needs improvement (0.50) | efficiency: Excellent (1.00)","action_history": [{"step": 1,"action_type": "classify","content": "technical"},{"step": 2,"action_type": "respond","content": "I'm sorry to hear you're experiencing technical difficulties. I understand how frustrating this can "},{"step": 3,"action_type": "escalate","content": "Customer requires immediate human assistance due to the severity and sensitivity of the issue. Eleva"}]}1 unmodified line},"summary": {"easy": {"avg_score": 0.7022,"min_score": 0.5908,"max_score": 0.7579,"avg_reward": 0.63,"pass_rate": 0.6666666666666666},"medium": {"avg_score": 0.7069,"min_score": 0.647,"max_score": 0.7369,"avg_reward": 0.3833,"pass_rate": 1.0},"hard": {"avg_score": 0.7988,"min_score": 0.7415,"max_score": 0.8275,"avg_reward": 1.34,"pass_rate": 1.0},"overall": {"avg_score": 0.736}}}123453 unmodified lines91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162632 unmodified lines666768697071727374757677787980811 unmodified line83848586878889909192939495969798991002 unmodified lines1031041051061071081091101111121131141151161171183 unmodified lines1221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751762 unmodified lines1791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422431 unmodified line2452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962971 unmodified line2993003013023033043053063073083093103113123133143153163173183193203213223233243253261 unmodified line328329330331332333334335336337338339340341342343344345346347348349350351352353354355{"timestamp": "2026-04-09T09:31:40.765510","seeds": [42,123,3 unmodified lines"easy": [{"difficulty": "easy","score": 0.79,"total_reward": 0.49,"steps": 4,"passed": true,"breakdown": {"classification": 0.99,"response_quality": 0.99,"escalation_decision": 0.99,"resolution": 0.01,"efficiency": 0.4},"feedback": "[EASY] classification: Excellent (0.99) | response_quality: Excellent (0.99) | escalation_decision: Excellent (0.99) | resolution: Poor (0.01) | efficiency: Needs improvement (0.40)","action_history": [{"step": 1,"action_type": "classify","content": "general"},{"step": 2,"action_type": "lookup_kb","content": "Knowledge base article on general procedures and customer guidelines"},{"step": 3,"action_type": "respond","content": "Great question! our standard hours are 9 AM to 9 PM daily. We always aim to provide clear informatio"},{"step": 4,"action_type": "resolve","content": "Thank you for your patience. I have finalized the resolution steps for this general case."}]},{"difficulty": "easy","score": 0.835,"total_reward": 0.49,"steps": 4,"passed": true,"breakdown": {"classification": 0.99,"response_quality": 0.99,"escalation_decision": 0.99,"resolution": 0.3,"efficiency": 0.4},"feedback": "[EASY] classification: Excellent (0.99) | response_quality: Excellent (0.99) | escalation_decision: Excellent (0.99) | resolution: Poor (0.30) | efficiency: Needs improvement (0.40)","action_history": [{"step": 1,2 unmodified lines},{"step": 2,"action_type": "lookup_kb","content": "Internal documentation for handling account escalation and resolution"},{"step": 3,"action_type": "respond","content": "Your account access regarding updating your password is important to us. I'm currently updating your"},{"step": 4,"action_type": "resolve","content": "Issue resolved. Category: account. Customer's concern has been addressed through appropriate respons"}1 unmodified line},{"difficulty": "easy","score": 0.835,"total_reward": 0.635,"steps": 4,"passed": true,"breakdown": {"classification": 0.99,"response_quality": 0.99,"escalation_decision": 0.99,"resolution": 0.3,"efficiency": 0.4},"feedback": "[EASY] classification: Excellent (0.99) | response_quality: Excellent (0.99) | escalation_decision: Excellent (0.99) | resolution: Poor (0.30) | efficiency: Needs improvement (0.40)","action_history": [{"step": 1,2 unmodified lines},{"step": 2,"action_type": "lookup_kb","content": "Knowledge base article on technical procedures and customer guidelines"},{"step": 3,"action_type": "respond","content": "I apologize for the technical trouble you're having with the application error. I've logged this wit"},{"step": 4,"action_type": "resolve","content": "Issue resolved. Category: technical. Customer's concern has been addressed through appropriate respo"}3 unmodified lines"medium": [{"difficulty": "medium","score": 0.766,"total_reward": 0.7,"steps": 4,"passed": true,"breakdown": {"classification": 0.99,"response_quality": 0.99,"escalation_decision": 0.99,"resolution": 0.01,"efficiency": 0.66},"feedback": "[MEDIUM] classification: Excellent (0.99) | response_quality: Excellent (0.99) | escalation_decision: Excellent (0.99) | resolution: Poor (0.01) | efficiency: Good (0.66)","action_history": [{"step": 1,"action_type": "classify","content": "technical"},{"step": 2,"action_type": "request_info","content": "To help you better, could you please provide your account details or the specific error message you "},{"step": 3,"action_type": "respond","content": "It sounds like you've encountered a technical issue related to the technical issue. I'm looking into"},{"step": 4,"action_type": "resolve","content": "Thank you for your patience. I have finalized the resolution steps for this technical case."}]},{"difficulty": "medium","score": 0.754,"total_reward": 0.9133,"steps": 5,"passed": true,"breakdown": {"classification": 0.99,"response_quality": 0.99,"escalation_decision": 0.99,"resolution": 0.01,"efficiency": 0.54},"feedback": "[MEDIUM] classification: Excellent (0.99) | response_quality: Excellent (0.99) | escalation_decision: Excellent (0.99) | resolution: Poor (0.01) | efficiency: Needs improvement (0.54)","action_history": [{"step": 1,2 unmodified lines},{"step": 2,"action_type": "lookup_kb","content": "Internal documentation for handling billing escalation and resolution"},{"step": 3,"action_type": "request_info","content": "Could you clarify a few more details? Specifically, when did this issue first occur and what device "},{"step": 4,"action_type": "respond","content": "I've received your billing inquiry about your refund request. I apologize for any frustration this h"},{"step": 5,"action_type": "resolve","content": "Thank you for your patience. I have finalized the resolution steps for this billing case."}]},{"difficulty": "medium","score": 0.814,"total_reward": 1.076,"steps": 5,"passed": true,"breakdown": {"classification": 0.99,"response_quality": 0.99,"escalation_decision": 0.99,"resolution": 0.3,"efficiency": 0.54},"feedback": "[MEDIUM] classification: Excellent (0.99) | response_quality: Excellent (0.99) | escalation_decision: Excellent (0.99) | resolution: Poor (0.30) | efficiency: Needs improvement (0.54)","action_history": [{"step": 1,"action_type": "classify","content": "technical"},{"step": 2,"action_type": "request_info","content": "Could you clarify a few more details? Specifically, when did this issue first occur and what device "},{"step": 3,"action_type": "respond","content": "I'm sorry to hear you're experiencing technical difficulties with the performance delay. I know how "},{"step": 4,"action_type": "lookup_kb","content": "How to resolve common technical complaints and technical errors"},{"step": 5,"action_type": "resolve","content": "Issue resolved. Category: technical. Customer's concern has been addressed through appropriate respo"}]}1 unmodified line"hard": [{"difficulty": "hard","score": 0.24,"total_reward": 0.8167,"steps": 2,"passed": false,"breakdown": {"classification": 0.2,"response_quality": 0.01,"escalation_decision": 0.4,"resolution": 0.2,"efficiency": 0.4},"feedback": "[HARD] classification: Poor (0.20) | response_quality: Poor (0.01) | escalation_decision: Needs improvement (0.40) | resolution: Poor (0.20) | efficiency: Needs improvement (0.40)","action_history": [{"step": 1,"action_type": "classify","content": "account"},{"step": 2,"action_type": "escalate","content": "Detected critical keywords or high frustration levels. Transferring this session to a senior support"}]},{"difficulty": "hard","score": 0.36,"total_reward": 1.3667,"steps": 2,"passed": false,"breakdown": {"classification": 0.99,"response_quality": 0.01,"escalation_decision": 0.4,"resolution": 0.2,"efficiency": 0.4},"feedback": "[HARD] classification: Excellent (0.99) | response_quality: Poor (0.01) | escalation_decision: Needs improvement (0.40) | resolution: Poor (0.20) | efficiency: Needs improvement (0.40)","action_history": [{"step": 1,"action_type": "classify","content": "general"},{"step": 2,"action_type": "escalate","content": "Customer requires immediate human assistance due to the severity and sensitivity of the issue. Eleva"}1 unmodified line},{"difficulty": "hard","score": 0.27,"total_reward": -0.2,"steps": 2,"passed": false,"breakdown": {"classification": 0.99,"response_quality": 0.01,"escalation_decision": 0.1,"resolution": 0.3,"efficiency": 0.4},"feedback": "[HARD] classification: Excellent (0.99) | response_quality: Poor (0.01) | escalation_decision: Poor (0.10) | resolution: Poor (0.30) | efficiency: Needs improvement (0.40)","action_history": [{"step": 1,"action_type": "classify","content": "billing"},{"step": 2,"action_type": "escalate","content": "Case involves complex or sensitive matters that exceed automated handling capabilities. Escalating f"}]}1 unmodified line},"summary": {"easy": {"avg_score": 0.82,"min_score": 0.79,"max_score": 0.835,"avg_reward": 0.5383,"pass_rate": 1.0},"medium": {"avg_score": 0.778,"min_score": 0.754,"max_score": 0.814,"avg_reward": 0.8964,"pass_rate": 1.0},"hard": {"avg_score": 0.29,"min_score": 0.24,"max_score": 0.36,"avg_reward": 0.6611,"pass_rate": 0.0},"overall": {"avg_score": 0.6293}}}
155 unmodified lines15615715815916016116249 unmodified lines2122132142152162172181 unmodified line220221222223224225226155 unmodified linesrewards: List[float] = []steps_taken = 0success = Falsefinal_score = 0.0try:with env.sync() as conn:49 unmodified linesgrade_resp = requests.post(grader_url, json={"session_id": session_id}, timeout=30)if grade_resp.status_code == 200:grade_data = grade_resp.json()final_score = float(grade_data.get('score', 0.0))success = bool(grade_data.get('passed', False))except Exception:pass1 unmodified linelog_end(success=success, steps=steps_taken, score=final_score, rewards=rewards)except Exception as e:log_end(success=False, steps=steps_taken, score=0.0, rewards=rewards)if __name__ == "__main__":main()155 unmodified lines15615715815916016116249 unmodified lines2122132142152162172181 unmodified line220221222223224225226155 unmodified linesrewards: List[float] = []steps_taken = 0success = Falsefinal_score = 0.01try:with env.sync() as conn:49 unmodified linesgrade_resp = requests.post(grader_url, json={"session_id": session_id}, timeout=30)if grade_resp.status_code == 200:grade_data = grade_resp.json()final_score = float(grade_data.get('score', 0.01))success = bool(grade_data.get('passed', False))except Exception:pass1 unmodified linelog_end(success=success, steps=steps_taken, score=final_score, rewards=rewards)except Exception as e:log_end(success=False, steps=steps_taken, score=0.01, rewards=rewards)if __name__ == "__main__":main()
114 unmodified lines115116117118119120121122114 unmodified linesordering_penalty = self._grade_action_ordering(action_history)total_score += ordering_penalty# Ensure score is in valid rangetotal_score = max(0.0, min(1.0, total_score))# Generate feedbackfeedback = self._generate_feedback(breakdown, task_difficulty)114 unmodified lines115116117118119120121122123124125126114 unmodified linesordering_penalty = self._grade_action_ordering(action_history)total_score += ordering_penalty# Ensure breakdown scores are strictly in (0, 1) rangefor key in breakdown:breakdown[key] = max(0.01, min(0.99, breakdown[key]))# Ensure total score is strictly in (0, 1) range - REQUIRED by hackathon validationtotal_score = max(0.01, min(0.99, total_score))# Generate feedbackfeedback = self._generate_feedback(breakdown, task_difficulty)
baseline/policy.py+130-79
baseline/results.json+166-141
inference.py+3-3
server/graders.py+6-2