File size: 4,118 Bytes
d287a79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""
Data models for the Customer Support Ticket Management Environment.

This environment simulates real-world customer support operations where an AI agent
must handle incoming tickets by categorizing, prioritizing, routing, and responding.
"""

from typing import Optional, List, Literal
from openenv.core.env_server.types import Action, Observation
from pydantic import Field


class CustomerHistory(Observation):
    """Customer historical data embedded in observations"""
    account_age_days: int = Field(description="Number of days since account creation")
    total_tickets: int = Field(description="Total number of previous tickets")
    resolved_tickets: int = Field(description="Number of successfully resolved tickets")
    satisfaction_score: float = Field(ge=0.0, le=5.0, description="Average satisfaction rating (0-5)")
    is_premium: bool = Field(description="Whether customer has premium status")
    lifetime_value: float = Field(description="Customer lifetime value in USD")


class TicketMetadata(Observation):
    """Metadata about the current ticket"""
    ticket_id: str = Field(description="Unique ticket identifier")
    timestamp: str = Field(description="Ticket creation timestamp")
    customer_id: str = Field(description="Customer identifier")
    channel: Literal["email", "chat", "phone", "social"] = Field(description="Communication channel")


class CustomerSupportObservation(Observation):
    """
    Observation returned by the environment.
    Contains all information visible to the agent about the current ticket.
    """
    # Ticket information
    ticket_id: str = Field(description="Unique ticket identifier")
    timestamp: str = Field(description="Ticket creation timestamp")
    customer_id: str = Field(description="Customer identifier")
    channel: Literal["email", "chat", "phone", "social"] = Field(description="Communication channel")

    # Customer message
    customer_message: str = Field(description="The customer's support request message")

    # Customer history
    account_age_days: int = Field(description="Number of days since account creation")
    total_tickets: int = Field(description="Total number of previous tickets")
    resolved_tickets: int = Field(description="Number of successfully resolved tickets")
    satisfaction_score: float = Field(ge=0.0, le=5.0, description="Average satisfaction rating (0-5)")
    is_premium: bool = Field(description="Whether customer has premium status")
    lifetime_value: float = Field(description="Customer lifetime value in USD")

    # Additional context
    previous_interactions: List[str] = Field(
        default_factory=list,
        description="List of previous messages in this ticket thread"
    )
    attachments: List[str] = Field(
        default_factory=list,
        description="List of attachment filenames (if any)"
    )

    # Task context
    task_id: str = Field(default="easy", description="Current task difficulty level")


class CustomerSupportAction(Action):
    """
    Action taken by the agent.
    Represents the agent's decision about how to handle the ticket.
    """
    category: Literal["billing", "technical", "account", "shipping", "general"] = Field(
        description="Ticket category classification"
    )
    priority: Literal["low", "medium", "high", "critical"] = Field(
        description="Assigned priority level"
    )
    assigned_team: Literal["tier1", "tier2", "billing", "technical", "management"] = Field(
        description="Team to handle the ticket"
    )
    response_draft: str = Field(
        min_length=10,
        description="Draft response to the customer (minimum 10 characters)"
    )
    internal_notes: Optional[str] = Field(
        default=None,
        description="Internal notes for the assigned team"
    )
    escalate: bool = Field(
        default=False,
        description="Whether to escalate to management"
    )