Overview
Thewrite-agent-digest worker creates a governance-compliant agent digest or report page in the Docs or Home Docs database. It handles all formatting, status line formatting, section ordering, and ERROR-title naming automatically.
Key features:
- Automatic status line generation from machine-readable format
- Heartbeat detection for zero-activity runs
- ERROR-titled pages for partial/failed runs
- Structured sections: Flagged Items, Actions Taken, Routing Summary, Needs Review, Escalations
- Relation support for Client and Project properties
Input Parameters
Name of the agent creating the digest. Must be one of the valid agent names:
"Inbox Manager""Personal Ops Manager""GitHub Insyncerator""Client Repo Auditor""Docs Librarian""VEP Weekly Reporter""Home & Life Watcher""Template Freshness Watcher""Time Log Auditor""Client Health Scorecard""Morning Briefing"
Emoji used in page title (unless ERROR-titled). Example:
"🔄"Type of agent run:
sync— Synchronization runsnapshot— Point-in-time snapshotreport— Generated reportheartbeat— Zero-activity check-in
Run outcome:
complete— ✅ Completepartial— ⚠️ Partial (ERROR-titled)failed— ❌ Failed (ERROR-titled)full_report— 📊 Full Reportstub— 📝 Stub
ISO 8601 timestamp in Chicago timezone. Example:
"2026-02-28T09:00:00-06:00"Description of data/entities processed. Example:
"All open PRs and recent commits in tracked repos"Upstream digest versions or “None” if not applicable. Example:
"Time Log Auditor v2026-02-28"Items requiring attention. Each item must include:
description(string, required): Description of the flagged itemtask_link(string, optional): Notion URL of created/linked taskno_task_reason(string, optional): Reason no task was created
task_link or no_task_reason.Tasks created or updated during the run:
created_tasks(array): List of{ name: string, notion_url: string }updated_tasks(array): List of{ name: string, notion_url: string }
High-level summary of routing decisions and linking actions. Example:
"Synced 3 repos. 2 items flagged, 1 escalation to Client Repo Auditor."Items needing manual classification. Each item contains:
description(string, required): Description of unclassified item
Handoffs to other agents. Each escalation includes:
escalated_to(string, required): Target agent nameescalation_reason(string, required): Reason for escalationescalation_owner(string, required): Owner of escalation (usually target agent)handoff_complete(boolean, required): Whether handoff is complete
Target Notion database:
docs— Docs database (most agents)home_docs— Home Docs database (Personal Ops Manager, Home & Life Watcher)
Value for Doc Type select property. Example:
"Agent Digest"Array of Notion page IDs to link in Client relation property
Array of Notion page IDs to link in Project relation property
Output Format
Whether the digest was created successfully
On Success (success: true)
Full Notion URL of the created page
Notion page ID (32-char hex)
Generated page title. Format:
- Normal:
"🔄 GitHub Sync — 2026-02-28" - ERROR:
"GitHub Sync ERROR — 2026-02-28"
Whether page title includes “ERROR” (true for partial/failed status_value)
Whether run was detected as heartbeat (zero flagged items and zero actions taken)
On Failure (success: false)
Error message describing validation or API failure
Usage Examples
- Complete Sync
- Heartbeat Run
Page Structure
The worker generates pages with the following structure:Error Handling
Validation errors:- Invalid agent name:
{ success: false, error: "Invalid agent_name: ..." } - Missing required fields:
{ success: false, error: "Missing required fields: ..." } - Flagged item missing task_link/no_task_reason:
{ success: false, error: "FlaggedItem must have task_link or no_task_reason: ..." }
- Notion API failures return:
{ success: false, error: "[Notion API error message]" }
Implementation Details
Source Files
- Worker implementation:
src/workers/write-agent-digest.ts:120-188 - Schema definition:
src/index.ts:12-46 - Type definitions:
src/shared/types.ts:37-66
Heartbeat Detection
A run is detected as heartbeat if:status_type === "heartbeat", ORflagged_items.length === 0ANDcreated_tasks.length === 0ANDupdated_tasks.length === 0
"Heartbeat: no actionable items"
ERROR Titling
Pages are ERROR-titled when:status_value === "partial"ORstatus_value === "failed"
"[Digest Type] ERROR — [Date]" (no emoji)
Normal format: "[Emoji] [Digest Type] — [Date]"
The worker automatically determines the digest type from agent name using
AGENT_DIGEST_PATTERNS mapping. For example, “GitHub Insyncerator” → “GitHub Sync”.