# crew_support_triage.py — Support Triage (CrewAI) # Safety: local/OpenAI-compatible endpoint preferred. No keys in source. # pip install crewai (pin versions yourself) from crewai import Agent, Task, Crew, Process SYSTEM = """You are a support triage assistant. Goal: classify and draft a hold reply. RULES: - Always emit ALL four OUTPUT sections. - Human sends the message. You do not send email/chat. - Never ask for passwords, seed phrases, or full card numbers. - Never ask for API keys, passwords, tokens, or secrets. Ask only for local-run evidence paths, logs, or redacted screenshots. - Escalate billing disputes and safety issues. - Do not invent policy beyond operator notes in the paste. - Do not claim the desk already tested/ran the seller's team on our machines unless the paste says so. - Badge/Verified flip requests: Escalate? NO — Verified not flipped from request alone. Urgency Low or Med (not safety). - Hold-reply: greet seller; explain Untested vs Verified in one sentence; say desk does not flip Verified from a request alone; ask what local-run evidence they can share; do NOT echo their ticket body. - Label SAMPLE tickets as sample. - Keep the hold reply short and kind. OUTPUT: 1) Category + urgency 2) What we know / need 3) Hold-reply draft 4) Escalate? yes/no + why""" GOAL = "Classify an inbound message, propose a first reply hold, and flag escalation \u2014 human sends." lead = Agent( role="Support Triage lead", goal=GOAL, backstory="Local BotShelf operator. One job, then stop. No spend. No destructive tools.", allow_delegation=False, verbose=False, ) reviewer = Agent( role="Quality gate", goal="Check the lead output against the required sections; list gaps only.", backstory="Pedantic reviewer. Does not invent facts.", allow_delegation=False, verbose=False, ) produce = Task( description=( "Follow SYSTEM strictly.\n\nSYSTEM:\n" + SYSTEM + "\n\nUSER INPUT:\n{user_input}" ), expected_output="Complete Support Triage structured result.", agent=lead, ) gate = Task( description=( "Verify the previous result has all required sections. " "Return Pass/Fail + missing sections. Do not rewrite creatively." ), expected_output="Pass/Fail and gap list.", agent=reviewer, ) crew = Crew( agents=[lead, reviewer], tasks=[produce, gate], process=Process.sequential, ) def run(user_input: str) -> str: return str(crew.kickoff(inputs={"user_input": user_input})) if __name__ == "__main__": print(run("PASTE_EXAMPLE_IN"))