Garry's Opinionated OpenClaw/Hermes Agent Brain
Reference Cron Schedule
Goal
A production brain runs 20+ recurring jobs that keep it alive, current, and compounding. This guide shows the schedule, the patterns, and how to set it up.
What the User Gets
Without this: the brain only updates when you manually ingest data. Pages go stale, entities are thin, citations break, and the agent answers from old context.
With this: the brain maintains itself. Email, social, calendar, and meetings flow in automatically. Thin pages get enriched overnight. Broken citations get fixed. You wake up and the brain is smarter than when you went to sleep.
The Schedule
| Frequency | Job | Brain Interaction | Recipe |
|---|---|---|---|
| Every 30 min | Email monitoring | Search sender, update people pages | email-to-brain |
| Every 30 min | X/Twitter collection | Create/update media pages, entity extraction | x-to-brain |
| 3x/day (weekdays) | Meeting sync | Full ingestion + attendee propagation | meeting-sync |
| Weekly | Calendar sync | Daily files + attendee enrichment | calendar-to-brain |
| Daily AM | Morning briefing | Search calendar attendees, deal status, active threads | briefing skill |
| Weekly | Brain maintenance | gbrain doctor, embed stale, orphan detection |
maintain skill |
| Nightly | Dream cycle | Entity sweep, enrich thin spots, fix citations | See below |
Prefer gbrain's native schedulers where they fit
System cron is the lowest common denominator, but gbrain ships its own scheduling surfaces — reach for these first:
gbrain dream— the shipped nightly maintenance cycle (lint, backlinks, extract, sync, embed, synthesize). Schedule THIS instead of hand-rolling the dream cycle below.gbrain jobs/ minions — queue shell jobs or LLM subagents with retry, backoff, and an audit trail. See theminion-orchestratorskill.gbrain serve— while the agent connected to it is idle, it runs the free upkeep (gbrain maintain --unattended) once a day, with nothing to install. A source too big to finish in its short idle slices is parked after 30 tries and finished by the next full run.gbrain maintain --statusshows the last run and anything parked.gbrain maintain --schedule— for a brain no agent opens most days: installs a job that runs the same upkeep every 6 hours (launchd, a systemd user timer or cron). Opt-in; preview with--dry-run.gbrain autopilot— the long-lived background daemon that runs full cycles on its own cadence, for a Postgres brain with a repo.cron-schedulerskill (skills/cron-scheduler/) — teaches an agent to manage its harness's scheduler.- Bootstrap session-triggered schedules —
gbrain bootstrapinstalls HEARTBEAT.md-driven schedules that fire on session activity; see bootstrap.md.
For scheduling sync + embed --stale specifically, the home doc is
live-sync.md.
Dream beside autopilot
A nightly gbrain dream beside autopilot is supported. Source phases run
under the source's own lease; brain-wide phases (synthesize, patterns, embed,
purge…) also need the shared gbrain-cycle lease, so the later run skips only
those (maintenance_lock_busy) and the holder runs them.
gbrain status --section locks --json shows the holder.
Implementation: Setting Up Cron Jobs
# Email collector — every 30 minutes
*/30 * * * * cd /path/to/email-collector && node email-collector.mjs collect && node email-collector.mjs digest
# X/Twitter collector — every 30 minutes
*/30 * * * * cd /path/to/x-collector && node x-collector.mjs collect >> /tmp/x-collector.log 2>&1
# Meeting sync — 10 AM, 4 PM, 9 PM on weekdays
0 10,16,21 * * 1-5 cd /path/to/meeting-sync && node meeting-sync.mjs >> /tmp/meeting-sync.log 2>&1
# Calendar sync — Sundays at 10 AM
0 10 * * 0 cd /path/to/calendar-sync && node calendar-sync.mjs --start $(date -v-7d +%Y-%m-%d) --end $(date +%Y-%m-%d)
# Brain health — weekly Mondays at 6 AM. Every gbrain call goes through the
# wrapper below (gbrain-run), never a bare `gbrain` or `bun run src/cli.ts`.
0 6 * * 1 gbrain-run doctor --json >> /tmp/gbrain-health.log 2>&1 && gbrain-run embed --stale
# Health alert — hourly. Page on the alert verdict, never on health_score:
# exit 0 none, 17 act (alert.items carry each fix), 18 unknown (a page-class
# check did not run fresh); page on 18 only from the second run in a row.
17 * * * * gbrain-run doctor --alert --json > /tmp/gbrain-alert.json 2>> /tmp/gbrain-alert.err; rc=$?; case $rc in 0) ;; 17) your-notify "gbrain needs action" ;; 18) [ "$(jq -r '.alert.consecutive_unknown // 0' /tmp/gbrain-alert.json)" -ge 2 ] && your-notify "gbrain health unknown twice in a row" ;; *) your-notify "gbrain doctor --alert failed (exit $rc)" ;; esac
# Autopilot health gate — daily at 7 AM. The exit code is the signal:
# 0 fresh (or nothing installed), 1 needs attention (stale heartbeat,
# never ran, paused, or brain-wide maintenance stalled: no completed pass
# for 3 global intervals while its jobs fail or a phase keeps blocking it,
# or passes stamping past a phase that failed 3+ passes in a row),
# 2 the daemon took itself out of rotation. Status is filesystem-only (the
# daemon writes the maintenance verdict each tick), so it works even during
# a DB outage. On a stall: gbrain doctor --only global_maintenance_stalled
# names the phase and the command to run.
0 7 * * * gbrain-run autopilot --status >> /tmp/gbrain-autopilot-health.log 2>&1 || your-notify "gbrain autopilot needs attention"
# Dream cycle — nightly at 2 AM
0 2 * * * /path/to/dream-cycle.sh
Call gbrain through one wrapper
A scheduled job does not run in the shell you tested it in. Cron, a harness's
workspace scripts and git hooks start with another HOME, a bare PATH and
whatever environment their parent had, so a call that works by hand can do
something else on a schedule:
- No database. The job finds no brain config or URL, gbrain refuses
(
no_brain, orGBRAIN_DB_ACCESS no_url) on stderr, and a caller that drops stderr reads every lookup as "nothing found". - A second host. gbrain keeps its host identity under the brain home, so a
job that resolves another home is another host:
gbrain sources refreshrefusesrefresh_not_owner(since v0.60.427.0 it names the identity file it read and theHOMEandGBRAIN_HOMEit resolved), and owner-only maintenance reportsowner_unavailablewith reasonhost_mismatch. - A stale database. A variable the caller already exported wins over the
brain's
config.jsonand.gbrain/.env, so a job started from an old environment keeps using the oldDATABASE_URL.
Give every cron line, workspace script and hook one entry point, a wrapper that
sets GBRAIN_HOME, loads the brain's env file if the harness keeps one, and
runs the installed binary:
#!/usr/bin/env bash
# gbrain-run: the only way scheduled work calls gbrain
set -euo pipefail
export GBRAIN_HOME=/srv/gbrain # parent of .gbrain; the value serve, workers and autopilot use
if [ -f /srv/gbrain/brain.env ]; then # only if the harness keeps the brain's settings in its own file
set -a; . /srv/gbrain/brain.env; set +a
fi
exec /srv/gbrain/.bun/bin/gbrain "$@" # the installed binary, by absolute path
Rules for the wrapper and everything that calls it:
- Set
GBRAIN_HOME, neverHOME.GBRAIN_HOMEmoves only gbrain's state. ChangingHOMEalso changes the git identity, SSH keys and push credentials the job runs with. Use the same value as the serve, the workers and autopilot; doctorhost_identity_mismatchnames a process that differs. - Run the installed binary. Never
bun run src/cli.tsfrom a checkout with the caller's inherited environment: it skips the wrapper's settings and can run another build than the serve. - Keep stderr and the exit code. Never send gbrain's stderr to
/dev/null. Append it to a log and branch on the exit code (exit codes):10means the write was accepted and is still pending, not "not found" or "failed";3means stop and ask the user. A refusal fails the job; it is never an empty result. - Keep stdout clean. A
--jsoncaller parses stdout as one document, so the wrapper and any hook it runs log to a file or stderr, never stdout. - Allow time. A cold CLI start takes 3–6 s on a pooled Postgres brain.
Set caller timeouts of at least 10 s in the shell and in the language
runtime that runs it (a runtime's exec timeout can override the shell's
without saying so), and turn on the warm CLI socket so
reads skip the cold start. Give fetch or push calls (
gbrain sources git-reconcile,refresh) 15 minutes. - Quote the env file. A file a shell sources is shell syntax. An unquoted
&in a URL ends the assignment and backgrounds the rest, so the variable silently keeps its old value. Quote every value, keep Postgres URLs to?sslmode=require(set driver options such asGBRAIN_PREPARE=falseas variables instead of extra¶meters), and restart every running gbrain process after an edit: a process keeps the environment it started with. - Never print the environment.
env,printenvor a process'senvironholds the database URL and API keys, and a transcript keeps them. To debug, print variable names only, or rungbrain engine status --json, which redacts the URL.
On a managed brain the same wrapper runs gbrain-run sources refresh <id> on
a schedule (the managed cron line).
Scripts commit the files they write with
gbrain git commit-push --path <absolute brain checkout> -- <paths>, never
plain git commit, in the managed checkout (a wrapper that changes directory
would otherwise point it at another repository); see
shared-checkout git.
gbrain doctor --only cron_gbrain_home --json reads the crontab and the scripts
it names and warns about a line that runs src/cli.ts straight from a checkout,
or calls gbrain without the brain's GBRAIN_HOME.
Quiet Hours Gate (MANDATORY)
Every cron job that sends notifications MUST check quiet hours first. The gate is a small script YOU create (it doesn't ship with gbrain) and call at the top of every notification-sending cron script; held output goes to a holding directory that the morning briefing drains. See Quiet Hours for the gate script and the full pattern — don't copy a snippet from here, that page is the single home.
Travel-Aware Timezone Handling
The agent reads your calendar for flights, hotels, and out-of-office blocks to infer your current location and timezone. All times shown in YOUR local timezone.
// Example: user flew to Tokyo
// 2 PM Pacific = 3 AM Tokyo = quiet hours
// Hold the notification, fold into morning briefing
get_user_timezone():
calendar = gbrain query "flight" --types calendar --since 7d
if recent_flight:
return infer_timezone(flight.destination)
return config.default_timezone // fallback: US/Pacific
When you travel: cron jobs that would fire during your waking hours at home but hit your sleeping hours at the destination get held and folded into the next morning briefing. Zero config change needed.
The Dream Cycle
The most important cron job. Runs while you sleep.
gbrain ships this: gbrain dream runs the maintenance half of the cycle
(lint, backlinks, extract, sync, embed, synthesize) as one command — schedule
it nightly and Phase 4 below (plus most of Phase 2's hygiene checks) is
covered. The pseudocode that follows is the harness-side variant for agents
that also do LLM-driven entity sweeps and memory consolidation on top.
Nightly summaries land on the calendar day you actually lived: the cycle
buckets by explicit --date > cycle.timezone config > the host's IANA
timezone > UTC, so a run scheduled after local midnight lands on the day
you lived, not on the UTC date. When the host clock's zone isn't yours (a cloud box on
UTC), pin it once: gbrain config set cycle.timezone America/Los_Angeles.
Synthesis cost control: the triage cascade
The synthesize phase is a two-stage cascade: a cheap scored triage (utility-tier model, one call per new transcript) gates the expensive per-transcript synthesis subagents. The dials:
dream.triage.threshold(default 0.5) — the score bar, and the first of the two ways a transcript passes the gate (the verified-segment rescue below is the second). Scores are cached, so retuning it re-gates instantly with zero new LLM calls. Lower it if real signal is being skipped. Raising it alone may not cut volume (#6753): the rescue band below is[rescue_floor, threshold), so it widens with the threshold, and transcripts that stop passing directly can still pass through the rescue. To cut volume, raisedream.triage.rescue_floorordream.triage.rescue_min_segmentsalong with it (0turns the rescue off), and comparedetails.triage.rescue_firedbefore and after.models.dream.triage— the triage model (default: utility tier / Haiku).dream.triage.max_chars(default 24000, floor 1000) — per-transcript sample window (head/middle/tail) sent to the judge. Not part of cache validity — after changing it,gbrain dream retriage --forcere-judges under the new sampling.dream.triage.max_tokens(default 2048, floor 256) — judge output budget.dream.triage.concurrency(default 4, clamped 1–16) — concurrent judge calls.- Verified-segment rescue (buried-signal recovery, $0): a transcript whose
score lands in
[dream.triage.rescue_floor, threshold)still passes when at leastdream.triage.rescue_min_segments(default 2; 0 disables) of the judge's own quoted segments verify as substrings of the transcript AND its content type is indream.triage.rescue_content_types(defaultmixed,reflection,idea,strategy,people— never routine/technical). Zero extra LLM calls; works on cached verdicts;dream retriagereads the same gate, so a reconcile sweep never cancels rescued jobs. Telemetry:details.triage.rescue_checked/rescue_fired. dream.synthesize.quote_verify(default on) — the mechanical post-write claim check on every page a synthesis child wrote. Paraphrased quotes are repaired to verbatim transcript slices; a sentence whose quote grounds nowhere, spans two speakers, is attributed to the wrong speaker, or states a number or date the transcript lacks is moved out of the page body into frontmatterunverified_claims, so search, recall and think never see it. Pages that already existed are checked only on the sentences this run added. The off switch is the incident escape hatch; telemetry lands indetails.synthesis.quote_verify.cycle.propose_takes.types(default unset = every page type) — a JSON array of page types thepropose_takesphase may scan, for examplegbrain config set cycle.propose_takes.types '["meeting","analysis"]'. Pages of other types (machine-written lanes,notescratch pages) are never sent to the model, so the phase spends only on the lanes you name. The built-in exclusions (receipts, atoms, the dream cycle's own output) still apply; a value that is not a JSON array is ignored with one stderr line and the phase scans every type. Note that a page with notypehas no type to match, so it is excluded whenever the list is set. A page whose reply is a complete empty array ([], even with an explanation after it) gets a "no gradeable claims" tombstone and is not sent again while its content is unchanged; a reply that is truncated, prose only, or empty and then followed by takes is retried next cycle. There is no per-page force flag: the tombstone is keyed by a hash of the page body, so any edit to the body re-extracts the page on the next cycle, and that is the only way to send one tombstoned page again. A page the model refuses the same way in 3 cycles (a prompt too long for the model, a content block) gets a separate failure tombstone and is skipped while its body and the prompt version are unchanged; pages that failed before are retried after the fresh ones, so they never block the rest.gbrain takes propose --failedlists held pages andgbrain takes propose --retry-failed [--slug <slug>]releases them. Timeouts, rate limits and other transient errors are never held.dream.synthesize.attribution_rulesanddream.propose_takes.attribution_rules(default off) — extra prompt rules from #5425: keep who proposed what and later corrections explicit; an assistant-authored judgment is not the user's. Off because matched runs measured no benefit (propose-takes F1 0.896 → 0.876); a brain that wants them opts in per phase.dream.attribution_checks(default off;trueorfalse) — the two mechanical attribution checks of #5425 that need the same held-out measurement before they can change defaults. On,propose_takesstores a proposal held bypeople/<slug>as held bybrainwhen its numbers, dates and quoted phrases appear only in assistant turns of the page and no user turn states or explicitly accepts any of them (a page without speaker turns is left alone), and the synthesis claim check addssuperseded_in_source: a sentence whose grounded quote a later user turn takes back in a sentence that negates and names the same number or date moves tounverified_claims; a later sentence that only repeats the number, or negates a different one, changes nothing. Off, every page and proposal is byte-identical to a release without the checks. One switch, both checks:gbrain config set dream.attribution_checks true.dream.synthesize.max_turns(default 16) — synthesis turn budget for agentic children and oneshot fallbacks (the default oneshot path — see the next section — is a single completion and never spends turns). The triage map hands the subagent pre-extracted segments, so the mid-tier default model (models.dream.synthesize, tierreasoning) with a 16-turn budget is the intended pairing — frontier-model overrides are unnecessary and slow the queue. Completeness comes from triage coverage (every file scored, minus files deferred under themax_msbudget below) plus segment-guided prompts, not model size. If written-page counts are low, raise it to 30 and checkdetails.synthesis.avg_turnsfor cap pressure.dream.triage.max_ms(default 5 min) — per-cycle wall-clock budget for judging NEW files; a big cold corpus triages across a few cycles (cached files are free). Deferred files are labeled "not yet triaged", never silently rejected.- A truncated, refused or unparseable verdict backs off (24h, doubling to
7 days;
triage_unreliable_backoff) instead of being re-paid nightly;gbrain dream retriage --forcere-judges now. dream.synthesize.max_submissions_per_source_per_day(default 0 = off) — opt-in backstop cap on synthesis jobs per source; 200/day is a sane value for busy deployments.
Maintenance recipe — after changing the threshold, upgrading through a
TRIAGE_VERSION bump (the current version scores peak-not-average; after a
bump the first cycle re-judges the corpus within the max_ms budget and
defers the rest to following cycles), or to drain a queued synthesis
backlog:
gbrain dream retriage --dry-run # what would change (zero LLM calls)
gbrain dream retriage --reconcile-queue # re-score + cancel queued jobs that fail the gate
gbrain dream retriage --audit-rejects 20 # synthesis-model second opinion on 20 gate rejects
Synthesis speed: oneshot mode + the drain pool
Above the triage cascade sit the execution dials:
dream.synthesize.mode(defaultoneshot) — how each synthesis child runs.oneshotmakes ONE tool-less completion against a prompt that already carries a pre-retrieved LINK CANDIDATES manifest and the write allow-list, then validates and writes the pages programmatically (slug grammar, allow-list, transcript hash suffix, exact-match wikilinks — all checked before any write; embeds deferred out of the model path and backfilled at phase end by a bounded pass over just the pages the phase wrote — never a source-wide sweep). A response that fails any check automatically falls back to the classic agentic loop in the same job — no lost work, no resubmission. The oneshot attempt and its fallback calls are both paid provider work and both are included in synthesis token/spend telemetry. Typical effect: 10+ provider round-trips per transcript (up to the 16-turn default cap, more on raisedmax_turns) → 1. Revert dial:gbrain config set dream.synthesize.mode agentic.dream.synthesize.link_manifest(default on) — the zero-embed pre-retrieval manifest (built from the triage verdict's cached entities + segment notes). Benefits BOTH modes: agentic children stop burning turns on low-yield searches; oneshot children get their link targets up front.dream.synthesize.inline_concurrency(default 1, clamp 1–8) — concurrent drain loops for the per-run child queue on Postgres (PGLite always drains serially). Provider ceilings stay with the rate leases (every provider round-trip on every path holds a lease slot), so this dial only removes queue-wait, never over-drives the API.
Reading the phase report (details.synthesis): mode, oneshot_jobs /
fallback_jobs / agentic_jobs + a fallback_reasons histogram (a rising
fallback rate means the model is failing the output contract — check the
top reason before considering the agentic revert; length includes malformed
responses whose output usage reached the requested output cap even when the
provider stop reason was ambiguous), queue_wait_ms_p50/p95
and child_runtime_ms_p50/p95 (a slow-but-healthy drain is visible instead
of indistinguishable from a stuck one), and dead_jobs/degraded. A run
with any non-completed child does NOT stamp the cooldown, so the next
nightly retries exactly the failed transcripts; a run whose EVERY child
died fails the phase loudly. Synthesis children also fail (dead-letter)
when every attempted page write failed, or when they attempted no page
write and stopped dirty, finished with prose instead of calling the write
tool, or had only failed tool calls. A completed child with zero pages written is a
deliberate answer: the model explicitly skipped the transcript
({"pages":[],"skipped":true}), or a patterns child ran its tools and found
nothing new. It completes so the cooldown stamps instead of re-billing the
same input.
A dream key whose submissions died dream.breaker.max_dead_submissions
times (default 3; 0 disables) within 24 hours is refused before the next
submission, and gbrain doctor reports it as dream_paid_loop. Fix the
cause first (a missing provider key, a quota, a failing transcript), then
gbrain dream reset-key --list shows the refused keys and
gbrain dream reset-key '<key>' re-enables one. Details in
spend controls.
Three more fields answer "what did that cost and did it land":
spend— what the phase actually spent,cost_basis: 'in+out+cache_read'. Children are summed fromminion_jobstoken counts priced at the configured synthesis model; triage comes from the pass's own usage.total_usdisnullunless BOTH price, so an unpriced model reads as unknown rather than as a fake0.details.triagecarries the judge's owntokens_in/tokens_out/cost_usdon the same terms.children_zero_pages— children that completed but wrote no page. A number that climbs here means the model is producing valid-but-empty output, which a green phase status alone would hide.quote_verify— what the post-write claim check touched: quotes checked and repaired, sentences quarantined (with counts per reason:quote_not_in_source,quote_crosses_speakers,speaker_mismatch,number_not_in_source,decision_misattributed, and, withdream.attribution_checkson,superseded_in_source), pre-existing pages checked by diff, and unbalanced paragraphs.decision_misattributedis a sentence saying a speaker decided, agreed or will do something whose numbers or dates only another speaker stated and the named speaker never explicitly accepted.superseded_in_sourceis a sentence whose quote a later user turn took back on the same number or date.
Per-call spend also lands in the chat_usage_log ledger with a phase tag:
the orchestrator's own calls under phase:synthesize, each drained child
under its own job:<name>, so the two never double-count.
What It Does
dream_cycle():
// Phase 1: Entity Sweep
conversations = get_todays_conversations()
for message in conversations:
entities = detect_entities(message)
for entity in entities:
page = gbrain search "{entity.name}"
if not page:
create_page(entity) // new entity, create + enrich
elif page.is_thin():
enrich_page(entity) // thin page, fill it out
else:
update_timeline(entity) // existing page, add today's mentions
// Phase 2: Fix Broken Citations
pages = gbrain list --type person --limit 100
for page in pages:
for entry in page.timeline:
if not entry.has_source_attribution():
fix_citation(entry) // add [Source: ...] where missing
if entry.has_tweet_url() and not entry.url_is_valid():
fix_url(entry) // broken tweet links
// Phase 3: Consolidate Memory
patterns = detect_patterns_across_conversations()
for pattern in patterns:
promote_to_memory(pattern) // ephemeral → durable knowledge
// Phase 4: Sync
gbrain sync --no-pull --no-embed
gbrain embed --stale
Setting Up the Dream Cycle
OpenClaw: Ships with DREAMS.md as a default skill. Three phases (light, deep, REM) run automatically during quiet hours.
Hermes Agent:
/cron add "0 2 * * *" "Dream cycle: search today's sessions for
entities I mentioned. For each person, company, or idea: check
if a brain page exists (gbrain search), create or update it if
thin. Fix any broken citations. Then consolidate: read MEMORY.md,
promote important signals, remove stale entries."
--name "nightly-dream-cycle"
Claude Code / Custom agents: Create a script:
#!/bin/bash
# dream-cycle.sh
# Check quiet hours (should be quiet — that's when we run)
echo "Dream cycle starting at $(date)"
# Phase 1: Entity sweep (spawn sub-agent)
# Read today's conversation logs, extract entities, update brain
# Phase 2: Shipped maintenance cycle (lint, backlinks, extract, sync, embed, synthesize)
gbrain dream
# Phase 3: Surface anything that needs someone (exit 17 act, 18 unknown)
gbrain doctor --alert --json | jq '.alert'
echo "Dream cycle complete at $(date)"
Tricky Spots
The dream cycle is NOT optional. Without it, signal leaks out of every conversation. With it, nothing is lost. This is the difference between an agent that forgets and one that remembers.
Quiet hours gate on EVERY notification job. If you skip it, the user gets pinged at 3 AM. One 3 AM ping and they'll disable the whole system.
Don't over-cron. 20+ jobs sounds like a lot. Start with: email (30 min), dream cycle (nightly), brain health (weekly). Add more as you add integration recipes.
Timezone changes are automatic. Don't make the user reconfigure cron when they travel. Read the calendar, infer the timezone, adjust delivery.
Held messages MUST be picked up. If quiet hours hold a notification, the morning briefing MUST include it. Otherwise information is lost.
How to Verify
- Quiet hours: Set quiet hours to current hour. Run a notification cron.
Verify output went to
/tmp/cron-held/, not to messaging. - Dream cycle: Run the dream cycle manually. Check that thin entity pages got enriched and broken citations were fixed.
- Email collector cron: Wait 30 minutes. Check
data/digests/for new digest. - Morning briefing: Check that held messages appear in the briefing.
- Health check: Run
gbrain doctor --json. All checks should pass.
Part of the GBrain Skillpack. See also: Quiet Hours, Operational Disciplines