← Journal / AI · Hobby · Home automation

My first AI agent

11 September 2026 / Alessandro Mastrofini

With the latest Codex updates, I finally found some time to start experimenting with AI agents beyond simple chat interactions. My first project is intentionally small: a personal agent that helps me organize my week.

The idea is simple. The agent reads my Apple Calendar, while I describe new activities directly in the chat. From a sentence like

“I need to finish the figures for the paper before Thursday”

the agent creates a structured task, estimating properties such as duration, priority, cognitive load, deadline rigidity, and whether the work can be split into multiple sessions. I can provide these details myself when I know them, but otherwise the agent makes a reasonable first estimate.

Existing meetings and appointments become fixed constraints. The agent can then schedule the remaining activities into the free time and create them in a dedicated calendar, using a predefined prefix so I can immediately recognize its decisions. Before every new plan, it reads the calendar again, meaning that manual changes I make from my Mac or phone become part of the next scheduling iteration.

From an AI agent to an optimization problem

I did not want the language model itself to decide where every task should go. Instead, Codex acts as the interface and reasoning layer, while the actual scheduling is handled by a deterministic optimizer.

For a task (i) assigned to a candidate time slot (t), I can define a scheduling cost such as:

J(x)=∑i∈T∑s∈Sxi,s(wdDi,s+weEi,s+wcSi,s+woOi,s)+wfF(x)+wrR(x)J(\mathbf{x}) = \sum_{i \in \mathcal{T}} \sum_{s \in \mathcal{S}} x_{i,s} \left( w_d D_{i,s} + w_e E_{i,s} + w_c S_{i,s} + w_o O_{i,s} \right) + w_f F(\mathbf{x}) + w_r R(\mathbf{x})

where:

The weekly scheduling problem then becomes approximately:

min⁡x∑i∑txi,tCi,t,\min_{\mathbf{x}} \sum_i\sum_t x_{i,t}C_{i,t},

subject to constraints such as

∑ixi,t≤1,\sum_i x_{i,t} \leq 1,

together with deadlines, working hours, existing calendar events, minimum block durations, maximum daily workload, and task-specific constraints.

The weights (wd,we, …) are configurable, so part of the experiment is also understanding which scheduling strategy actually works well in practice.

Giving the agent rules

One interesting part of the project is that the behaviour of Codex itself can be described in the repository through an AGENTS.md file. A simplified part looks something like this:

You are my weekly scheduling agent.

When planning or replanning:

1. Read the current Apple Calendar.
2. Synchronize existing AI-scheduled events.
3. Read pending tasks and their history.
4. Infer missing task properties when reasonable.
5. Ask the user only when an important property
   cannot be inferred reliably.
6. Run the deterministic scheduler.
7. Detect overload and unscheduled tasks.
8. Present the proposed schedule.
9. Never modify the calendar before explicit approval.
10. After approval, write only to the "AI Schedule" calendar.

This separation is something I particularly like: the LLM handles language and reasoning, while conventional software handles state, constraints, and optimization.

Closing the loop

The next part is what makes the experiment more interesting to me. The agent also keeps track of what actually happens.

If a task estimated at two hours consistently takes me three, that information should influence future plans. A simple correction can already be written as

T^i,LLM,kc\hat{T}{i}^{,\mathrm{LLM}} , k{c}

where (kc) is a historical correction factor for a category of activities. If I systematically underestimate coding tasks by 20%, for example, the scheduler can start allocating more realistic blocks.

The same history can reveal a different problem: too much work rather than bad scheduling. Comparing requested workload with realistic available capacity,

ρ=TrequiredTavailable\rho = \frac{T_{\mathrm{required}}} {T_{\mathrm{available}}}

immediately tells the agent when no reasonable schedule exists. If (\rho > 1), moving boxes around the calendar is not going to solve the problem.

It is still a small project, but I like it as a first practical experiment with agentic AI:

flowchart LR
    A["Conversation"] --> B["Structured State"]
    B --> C["Optimization"]
    C --> D["Action"]
    D --> E["Feedback"]
    E --> F["Replanning"]
    F --> A

And, hopefully, fewer weeks where Friday arrives with half of Monday’s to-do list still open.