v5: heartbeat-by-default, copilot voice fix, autopilot security note

MA
7mo ago
+133-41

Stacked on #212 (v4). Five changes.

1. Heartbeat-by-default (bot-side, agent doesn't self-schedule)

Inspired by your OpenClaw heartbeat reference + my research into how they ship it. Verified pattern: gateway-side scheduler, agent-side reception. The agent doesn't run a loop or call tg-schedule from inside its own turn — the gateway (here: the bot + at jobs) pulses it.

Implementation:

  • tg-schedule learns --repeat <interval>. Writes the repeat field into job.json.
  • tg-schedule-fire re-queues itself when job.repeat is set. Self-sustaining loop. Inherits chat/thread context from the original schedule.
  • _start_agency_goal_from_command schedules a +1 hour heartbeat with --repeat "+1 hour" right after the first cycle.

The bot drives cadence. The agent's prompt no longer says "call tg-schedule at end of cycle." User can ask to change cadence and the agent handles it via atrm + new tg-schedule --repeat.

2. Autopilot — fully autonomous + security warning

Sharpened in the system prompt: completely autonomous, no permissions, keep going until the goal is achieved or genuinely impossible. No approval cards. Only stop and message the user on completion, external blocker, or impossibility.

Security note baked in: don't give autopilot access to sensitive data (banking, PII, secrets). It will use whatever it has to reach the goal. Whoever can prompt the topic effectively gives it commands — gate the topic accordingly.

3. Copilot voice fix

You called out that "Done — sent it" implies acting without asking. Voice is now question-first:

Should I send this draft to Vincent? He asked about parallel browsers last Thursday. Two options below — pick one.

Pattern: short question + named recipient + why-now + drafted thing in expandable + button row. The user reads in 2 seconds and taps.

4. Queued cards rule

When the user accepts 10 cards in 30 seconds and walks away, complete every one. Parallelize with Agent sub-agents for independent work. Treat every new message — including button-tap dispatches — as a queued follow-up, not a cancellation.

5. Dropped "If you are running as Codex"

After v4's discovery that codex is launched with -a never -s danger-full-access, codex and claude behave the same way. The special-case section was dead weight.

Research summary (from the agent run)

Hermes (NousResearch) memory: agent-curated, file-based. Two markdown files at ~/.hermes/memories/MEMORY.md (~2,200 char cap) + USER.md (~1,375 char cap). The agent autonomously writes via a memory tool. Char-bounded forces curation. Injected into the system prompt only at session start (prefix caching).

OpenClaw heartbeat: gateway-side scheduler, not agent-side. Each pulse runs as a turn in the existing main session, queue-aware. Default 30 min, 1 h on Anthropic auth. Has a HEARTBEAT.md brain file with explicit silence criteria.

My implementation follows OpenClaw's pattern. The future v6 candidate: file-based agent-curated memory à la Hermes (currently we use Claude Code's auto-memory which is similar in spirit but not file-based).

Test plan

  • 33 tests pass
  • Shell + Python syntax check on tg-schedule + tg-schedule-fire
  • On a box: tg-schedule "+1 minute" --repeat "+1 minute" "test heartbeat" — verify it fires and re-queues itself
  • /goal X in a forum — verify the first heartbeat is queued (atq should show it)

🤖 Generated with Claude Code


Summary by cubic

Make cadence bot-driven with a self-repeating heartbeat by default, and tighten the system prompt: copilot asks before visible actions; autopilot runs end-to-end with a clear security note.

  • New Features

    • Self-repeating heartbeat: tg-schedule adds --repeat <interval> and writes it to job.json; tg-schedule-fire re-queues itself when repeat is set. The bot schedules a +1h repeating heartbeat when /goal starts; the agent no longer self-schedules.
    • Copilot voice: question-first for any visible action, with named recipient, why-now context, the draft in an expandable, and a button row.
    • Autopilot: fully autonomous, no approvals; only report when done, blocked, or impossible. Adds a one-time security note advising against giving access to sensitive data.
    • Queued cards: treat new messages and button taps as queued follow-ups. Complete every accepted action; parallelize with sub-agents when independent.
  • Refactors

    • Removed the Codex-only section; both CLIs now behave the same.