Skip to main content

Agents, automation, and triggers

A task stores a prompt, a trigger and a delivery target; when the trigger fires, the task's agent runs like it would for a chat message.

Agents​

ConceptImplementation
Main agentensureMainAgent() in services/agents/manager.js keeps one main agent per user
Agent scopeagent_id on settings, conversations, memory, runs, connections, MCP servers and tasks
Agent tasksloop/agent_tasks.js runs durable work between agents; rows in agent_delegations, messages in agent_task_messages
Agent creationcreate_agent → services/agents/creation.js; gated by the agent_creation tool policy
Agent restrictionsagents.tool_restrictions_json, enforced in security/tool_security_hook.js
SubagentsspawnSubagent() starts a child run of the same agent; cancelled when the parent ends
  • Delegation rule. The source needs can_delegate; the target must allow can_be_delegated_to.
  • Target list. An empty delegate_targets_json allows every eligible agent.
  • Task lifecycle. pending → working → (waiting →) completed | failed | cancelled. The owner works in its own run (trigger_source = 'agent_delegation'); the asking run is never blocked.
  • Hearing back. A still-running requester gets a steering note. Otherwise a parent task resumes, or a new run starts on the requester's surface from its resume envelope. report_pending makes each update arrive once.
  • Restart. resumeAgentTasks() requeues working tasks and delivers pending reports at boot.
  • Bounds. LIMITS in services/agents/tasks.js: depth 2, 3 tasks per run, 20 open per account, 20 messages and 6 runs per task; 2 task runs at a time per account; no handing back to an agent already on the chain.
  • Trust. Subagents share the parent run's trust record; an agent task shares it while the asking run is alive and otherwise starts untrusted.
  • Permissions. A task carries its requesters' restrictions; a created agent gets its creator's restrictions plus any it asked for.

Task record​

Tasks live in scheduled_tasks and are managed by TaskRuntime (services/tasks/runtime.js).

ColumnHolds
agent_idThe agent that runs the task
trigger_type, trigger_configAdapter type and its validated config
task_configprompt, notify target (notifyPlatform, notifyTo), model, loopBudget
cron_expression, run_at, one_timeSchedule fields
last_trigger_fingerprintLast event handled, for de-duplication

Trigger adapters​

services/tasks/adapters/index.js lists 42 trigger types; each adapter exports type, label, configHint, validateConfig(), summarize(), and a poll or event block.

GroupTypesFires by
Coreschedule, manual, webhookCron or one-time poller, Run button, signed HTTP
Email and chatgmail_message_received, outlook_email_received, slack_message_received, teams_message_received, whatsapp_personal_message_receivedPoll; WhatsApp also by event
Messaging platformsmessaging_member_joined, messaging_member_left, messaging_reaction_added, messaging_platform_disconnectedEvent
Calendarsgoogle_calendar_event_starting, google_calendar_event_created, outlook_calendar_event_starting, nextcloud_calendar_event_startingPoll
Files and documentsgoogle_drive_file_added, google_sheets_row_added, onedrive_file_added, nextcloud_file_added, nextcloud_share_received, notion_database_item_added, notion_database_item_updated, trello_card_entered_list, figma_comment_addedPoll
Developergithub_issue_opened, github_pr_opened, github_workflow_run_failed, github_commit_pushed, mcp_server_disconnectedPoll; MCP by event
Home, media, memoryhome_assistant_state_changed, spotify_track_changed, neorecall_memory_created, neorecall_daily_summary_created, neorecall_conversation_recordedPoll
Worldweather_event, world_newsPoll
Devices and tasksandroid_notification_received, geofence_event, health_metric_recorded, wearable_connection_changed, task_run_finishedEvent

Firing paths​

PathModuleHow
Recurring scheduleruntime.jsOne node-cron job per task, in the user's timezone
One-time scheduleruntime.jsMinute poller; the task is deleted after it runs
Finish on timeruntime.jsfinishOnTime tasks start early by their average run time (last 10 runs, at most 1 hour)
Polled triggertrigger_polling.jsMinute tick; fetchRows() calls integration tools and returns rows after the checkpoint
Event triggertrigger_events.jsListens on runtime, messaging, mcp, wearable and whatsapp_personal emitters
Device eventsroutes/triggers.jsPOST /api/triggers/notification and /api/triggers/geofence publish runtime events
Webhooktasks/webhooks.jsPOST /api/task-webhooks/:taskId/deliver
  • De-duplication. fireTaskFromTrigger() ignores a fingerprint equal to last_trigger_fingerprint and stores it after a successful run.
  • Event queue. Events for one task wait for the previous run, so two at once both run.
  • Chains. task_run_finished stops after a chain depth of 3.

Webhook authentication​

HeaderValue
X-NeoAgent-TimestampMilliseconds since epoch, within 5 minutes of server time
X-NeoAgent-Request-IdUnique per delivery; a reused ID is rejected with 409
X-NeoAgent-Signaturesha256= + hex HMAC-SHA256 of <timestamp>.<raw body> with the task secret
  • Secret. Stored encrypted in task_webhook_secrets; rotate with POST /api/task-webhooks/:taskId/rotate.
  • Limit. Payloads above 256 KiB are refused.
  • Log. Each delivery is recorded in task_webhook_deliveries.

Execution and delivery​

  1. Gate. A task already running is skipped (already_running_or_queued); a recurring run starting over 90 seconds late is skipped (stale_start_delay).
  2. Prompt. The task prompt is combined with the trigger payload, fenced as untrusted data.
  3. Run. The agent runs in the task's own conversation with triggerSource set to the trigger type.
  4. Decide. The final answer is the result. Exactly [NO RESPONSE] means nothing is sent; a send_message the run made already counts as the delivery.
  5. Deliver. The runtime sends the final answer, or a staged message, to the notify target.
  6. Retry. A failed run retries once with the error attached; rate-limit errors skip the run instead.
  7. Publish. A task_run_finished event lets other tasks react.
  • Default target. Without a configured target, the agent's last messaging chat (last_platform, last_chat_id) is used.
  • Delivery failure. A failed send fails the task (TASK_DELIVERY_FAILED) without re-running the agent.

See Automation for the user-facing guide.