File size: 1,571 Bytes
0366d65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Shared pydantic schemas for the scheduling agent.

The model is constrained to emit an ActionPlan (see server/agent.py); these types
are also the contract used by the UI and the calendar outputs.
"""
from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Field


class Event(BaseModel):
    title: str
    start: str  # ISO 8601, e.g. 2026-06-10T13:00:00
    end: Optional[str] = None
    location: Optional[str] = None
    attendees: list[str] = Field(default_factory=list)
    reminder_minutes: Optional[int] = None
    notes: Optional[str] = None


class Conflict(BaseModel):
    event_index: int = Field(description="index into ActionPlan.events")
    clashes_with: str = Field(description="summary of the existing event it clashes with")
    severity: str = Field(description='one of: "overlap", "adjacent", "tight"')


class ActionPlan(BaseModel):
    """Everything the agent decides for one thread, in one constrained object."""

    reasoning: Optional[str] = Field(
        default=None, description="brief chain of thought shown to the user"
    )
    events: list[Event] = Field(default_factory=list)
    conflicts: list[Conflict] = Field(default_factory=list)
    proposed_times: list[str] = Field(
        default_factory=list, description="ISO 8601 alternatives when there is a conflict"
    )
    reply_draft: str = Field(default="", description="suggested reply to send back")
    needs_clarification: Optional[str] = Field(
        default=None, description="a question to ask if the plan is ambiguous"
    )