add_event
Log medication starts, habit changes, visits, or trips as context events so later analysis can segment around them; returns stored event with id and avoids duplicates.
Instructions
Log a context event the user tells you about (a medication start, a habit change, a visit, a trip) so later analysis can segment around it. Writes ONLY health-events-agent.json in the export folder, never Apple Health and never a file the iOS app writes; the app shows these events read-only. Returns the stored event with its id (starting "agent-"). Idempotent: repeating a call with the same clientEventId (or, without one, the same date, type, title and endDate) returns the event already logged instead of adding a duplicate. Ask the user before logging anything they did not state. Refused in demo mode, when the folder is not writable, and on an encrypted export without HEALTH_EXPORT_PASSPHRASE (the file is sealed like the rest of the export when the passphrase is set).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Local day the event happened or started, YYYY-MM-DD. | |
| note | No | Optional longer note, at most 2000 characters. | |
| tags | No | Optional tags for filtering, e.g. ["magnesium"]. At most 20. | |
| type | Yes | Event type: medication, habit, visit, life, shift, episode, travel or other. Range types (shift, travel, episode) usually carry an endDate. | |
| title | Yes | Short description, e.g. "Started magnesium 300 mg". At most 200 characters. | |
| endDate | No | Last day of a range event (inclusive), YYYY-MM-DD, not before date. Omit for a point event. | |
| clientEventId | No | Optional idempotency key: the same key never logs a second event. |