Agent building · Reference project
Calendar Agent
From natural language to a real macOS Calendar: an engineering record of a Mac-first Personal Agent.
This is not an “LLM + Calendar API” demo. It is a real project built around Task, State, Tool Calling, Persistence, Verification, Remote Access, and Agent QA.
00 · PROJECT OVERVIEW
What did I build?
iPhone · Siri · Apple Watch
HTTPS
analysis · state · clarification · planner
MacAgentHost
macOS Calendar
Final response
The user submits a natural-language session request, AgentRuntime manages task and parameter state, the Tool Execution Layer sends a constrained operation to MacAgentHost, EventKit creates real Calendar state, and Verification decides the final response.
Current capability status
MacAgentHost + EventKit, followed by state verification.
Currently used mainly for Create verification.
The real execution boundary exists; the capability scope is still narrow.
Tool success is not automatically Task success.
The user entry point and HTTP API exist; device access needs separate acceptance.
The code path exists; public and device regression is not claimed as complete.
Implemented in code; real device validation is still pending.
DemoLLM is a deterministic development adapter.
Contracts exist, but these are not executable capabilities yet.
Future Personal Agent capabilities.
01 · FROM IDEA TO PROTOTYPE
From idea to the first Agent Prototype
The first question was: if I speak a natural-language request to Siri, can my own agent understand it and operate Calendar? The first abstraction had three layers: Natural Language → Agent → Calendar Action.
UserRequest
↓
AgentRuntime
↓
LLM / Semantic Analysis
↓
Planner
↓
Mock Tool
↓
FinalThe Mock Tool came first so the Agent Core, Task, Parameter, Planner, and Tool Contract could be validated before adding macOS permissions, EventKit, networking, and Siri.
02 · BUILDING THE AGENT CORE
What makes an agent more than an API?
“Create a one-hour meeting tomorrow at 3 PM” cannot simply become an API parameter. It must pass semantic analysis, task state, and planning. Parameters carry value, source, and status; tasks carry conversation, task, and step identity.
User Request
↓
Semantic Analysis
intent = create
object = calendar_event
date = tomorrow
start = 15:00
duration = 60
↓
Task / Parameter State
↓
Planner → Tool Contract03 · CONNECTING TO THE REAL WORLD
From Mock Tool to a real macOS Calendar
A Mock Tool only proves that the agent believes it executed an operation. It cannot prove that Calendar changed. The execution boundary therefore moved into a native host with macOS permissions.
AgentRuntime → Tool Request
→ MacAgentHost.app
→ EventKit
→ macOS Calendar
→ query_calendar / VerificationThe Python Runtime and the macOS Calendar permission boundary are different boundaries, so MacAgentHost, EventKit, and a JSON-lines contract connect them.
The persistent NSApplication lifecycle conflicted with subprocess.run timeouts. The boundary evolved into stdin request → stdout ToolResult → controlled termination.
04 · FROM MAC TO IPHONE & SIRI
From Mac localhost to Siri and iPhone
Running on a Mac was only the beginning. A Personal Agent needs to move from the Terminal to iPhone, Shortcuts, and Siri.
localhost 127.0.0.1:8000
↓
LAN access
↓
DHCP address changed
↓
stable HTTPS endpoint
↓
Cloudflare Named Tunnel → 127.0.0.1:8000This path introduced authentication, Bearer tokens, HTTPS, a localhost-only Agent Server, and no public port 8000. Public and real-device connectivity still require separate acceptance.
05 · MULTI-TURN AGENT
From one-shot commands to a multi-turn agent
When the user says “Create a meeting tomorrow,” the agent must not guess. It enters waiting_clarification, asks a question, and uses the same conversation to find the original task.
same conversation → find waiting task
↓
same task_id → analyzing_clarification
↓
parameter merge → planning → tool → verificationClarification Resume is implemented in code, but real iPhone/Siri multi-turn regression is still in progress.
06 · ARCHITECTURE EVOLUTION: V1 → V2
From Protocol V1 to V2: a real architecture reconciliation
Client → Agent → Tool Request
→ Client executes Tool
→ Tool Result → AgentClient → AgentRuntime
→ Tool Execution Layer
→ MacAgentHost → EventKitAs the real implementation formed, Specification ≠ Implementation and architecture drift became visible. That led to audit, reconciliation, an ADR, and Protocol V2. V1 was not deleted; it remains as historical context.
07 · RELIABILITY & VERIFICATION
How does the agent prove it completed the task?
The core rule is: Tool Success ≠ Task Success. Only real-state Verification can justify Final.success.
Tool Execution → Tool Result
↓
query_calendar / verify_state
↓
compare event_id · title · start · end
↓
Verified → success | mismatch → failure | unknown → unknownThis boundary also covers operation_id, duplicate prevention, retry, unknown state, pre-execution safety, and real EventKit state. The system does not claim exactly-once.
08 · AGENT QA & EVALUATION
How do I test the agent?
Agent QA is not a final test run. It runs through the build: deterministic testing, Agent Evaluation, Observability, Integration, E2E, and Regression.
- Deterministic Testing
- Agent Evaluation
- Observability
- Integration / E2E
- Regression
09 · WHAT BROKE ALONG THE WAY
What broke along the way
NEXT · PERSONAL AGENT
Calendar is only the first capability
Next come a production LLM, an evaluation dataset, automated evaluation, and continuous evaluation; later come Reminder, Mail, Files, Obsidian, Browser, and Computer Use on the path to a Personal Agent.
Continue to Agent QA →