Skip to content

v0.11: Routines, Cron, And Triggers [PARTIAL]

Goal

Let the character act on recurring workflows and external events.

Implementation Status

  • [x] Routine config model (Pydantic).
  • [x] Routine persistence store.
  • [x] Routine runner (bus injection logic).
  • [x] Routine scheduler skeleton (Cron bridge).
  • [x] /routines management command.
  • [x] Script pre-processing with bounded stdout context and diagnostics.
  • [x] Routine step metadata rendering fixed/tested.
  • [x] Busy protection default restored; explicit bypass for internal routine preserved.
  • [ ] Multi-skill workflows.
  • [ ] Webhook/API triggers.

Scope

  • Add routine model.
  • Support cron schedules for reminders, reports, check-ins, monitoring, and content generation.
  • Support script pre-processing where stdout becomes context.
  • Support multi-skill workflows later.
  • Add webhook/API triggers after command/session/store foundation is stable.
  • Keep proactive behavior opt-in and bounded by quiet hours and consent gates.

Routine Fields

  • name
  • trigger type
  • schedule/webhook/API event
  • target character
  • destination channel
  • allowed tools
  • approval policy
  • optional script command, cwd, timeout, and max output
  • delivery policy
  • quiet hours
  • enabled

Module Targets

  • backend/agent/g_agent/routines/model.py
  • backend/agent/g_agent/routines/store.py
  • backend/agent/g_agent/routines/scheduler.py
  • backend/agent/g_agent/routines/runner.py
  • backend/agent/g_agent/routines/script.py
  • backend/agent/tests/test_routines_*.py

Acceptance Criteria

  • Owner can create/list/enable/disable cron routines.
  • Routine output routes to a selected channel.
  • Script output can become agent context.
  • Routines obey tool and approval policy.
  • Quiet hours are respected.

References

  • hermes-agent-ref/hermes-already-has-routines.md

Agent Handoff

Current G-Agent State

  • cron/service.py and cron/types.py already exist.
  • agent/tools/cron.py already exposes scheduling as a tool when cron service is configured.
  • proactive/engine.py already implements quiet hours and calendar reminder dedupe.
  • channels/slash_commands.py already has /cron.
  • routines/script.py runs optional script commands without a shell, confines cwd under the workspace, bounds runtime/output, injects stdout as reference-only context, and stores stderr/exit diagnostics in message metadata.

Implementation Strategy

Routines should extend cron/proactive instead of creating a parallel scheduler.

Recommended shape:

  • routines/model.py: routine config model.
  • routines/store.py: persistence.
  • routines/runner.py: converts routine trigger into agent task.
  • routines/scheduler.py: bridges cron service to routines.

Implementation Slices

  1. Add routine model and store.
  2. Map cron jobs to routine triggers.
  3. Add destination channel and target character fields.
  4. Add allowed toolset and approval policy fields.
  5. Add script pre-processing. Shipped with bounded stdout context and metadata diagnostics.
  6. Add /routines command.
  7. Add webhook/API triggers after API server exists.

Tests

  • test_routine_store.py
  • test_routine_scheduler.py
  • test_routine_runner.py
  • test_routine_quiet_hours.py
  • test_routine_script_preprocess.py

Guardrails

  • Proactive behavior must be opt-in.
  • Quiet hours must apply to outbound delivery.
  • Dangerous tools in routines must respect approval policy.
  • Cron jobs without present user should deny risky actions by default.

Shipped Slice

Routine model/store + /routines list + cron bridge skeleton + script pre-processing with bounded stdout context and metadata diagnostics. Routine step metadata rendering fixed/tested (test_routine_steps_rendering.py + routine_script_preprocess). Busy protection default restored; explicit bypass for internal routine preserved. No webhooks or multi-skill workflows yet.