Agentic Mesh

Build automated, scalable workflows where deterministic scheduling triggers intelligent agents. Configure cron jobs, workflow chains, and observability.

Traditional automation is deterministic: run this script at this time. AI agents are intelligent but unpredictable. Agentic Mesh combines both: deterministic scheduling meets agentic intelligence.

Source: scheduler crate and agent crate

What is Agentic Mesh?

Agentic Mesh is a pattern for building automated, scalable workflows where:

  1. Deterministic triggers initiate workflows (cron schedules, webhooks, events)
  2. Intelligent agents handle the actual work (reasoning, decision-making)
  3. Structured outputs feed into downstream systems (databases, APIs, notifications)
┌─────────────────────────────────────────────────────────────┐
│                     AGENTIC MESH                             │
│                                                              │
│  TRIGGERS          AGENTS              OUTPUTS               │
│  ┌──────────┐     ┌──────────┐       ┌──────────┐          │
│  │  Cron    │────▶│ Analyst  │──────▶│ Database │          │
│  │ Schedule │     └──────────┘       └──────────┘          │
│  └──────────┘            │                                  │
│                          ▼                                  │
│  ┌──────────┐     ┌──────────┐       ┌──────────┐          │
│  │ Webhook  │────▶│ Writer   │──────▶│ Content  │          │
│  │  Event   │     └──────────┘       │   CMS    │          │
│  └──────────┘            │           └──────────┘          │
│                          ▼                                  │
│  ┌──────────┐     ┌──────────┐       ┌──────────┐          │
│  │ Database │────▶│ Notifier │──────▶│  Email   │          │
│  │  Change  │     └──────────┘       │   Slack  │          │
│  └──────────┘                        └──────────┘          │
└─────────────────────────────────────────────────────────────┘

Why Agentic Mesh?

Beyond Simple Automation

Traditional automation:

# Old way: deterministic script
schedule: "0 9 * * *"
run: python send_report.py

Agentic Mesh:

# New way: intelligent agent
schedule: "0 9 * * *"
agent: report-analyst
task: "Analyze yesterday's metrics and generate insights"

The agent decides:

  • What metrics matter today
  • What trends are significant
  • How to present the information
  • What recommendations to make

Production Reliability

Agents are powerful but need guardrails:

Challenge Solution
Unpredictable runtime Timeout limits
Cost control Budget caps per job
Error handling Retry policies
Observability Structured logging
Audit trail Every run recorded

Configuring Agentic Mesh

Scheduler Configuration

Define scheduled agent jobs:

# services/scheduler/config.yaml
scheduler:
  enabled: true
  jobs:
    - name: publish_content
      extension: core
      job: publish_content
      schedule: "0 */30 * * * *"  # Every 30 minutes

    - name: daily_analysis
      extension: analytics
      job: analyze_metrics
      schedule: "0 0 9 * * *"     # 9 AM daily
      agent: data-analyst
      task: "Analyze yesterday's performance"

    - name: content_refresh
      extension: content
      job: refresh_content
      schedule: "0 0 */6 * * *"   # Every 6 hours
      agent: content-curator
      task: "Review and update stale content"

Agent-Triggered Jobs

Agents can trigger jobs directly:

# services/agents/orchestrator.yaml
name: orchestrator
capabilities:
  - job:trigger
allowed_jobs:
  - publish_content
  - send_notifications
system_prompt: |
  You orchestrate content workflows.
  When content is ready, trigger the publish job.
  When users need updates, trigger notifications.

Workflow Chains

Chain multiple agents for complex workflows:

# services/agents/content-pipeline.yaml
name: content-pipeline
type: orchestrator
workflow:
  steps:
    - name: research
      agent: researcher
      task: "Research the assigned topic"
      timeout: 300s
      output: research_notes

    - name: write
      agent: writer
      task: "Write article based on research"
      input: research_notes
      timeout: 600s
      output: draft

    - name: review
      agent: reviewer
      task: "Review and improve the draft"
      input: draft
      timeout: 300s
      output: final

    - name: publish
      job: publish_content
      input: final

Job Types

Extension Jobs

Jobs defined by extensions:

impl JobExtension for ContentExtension {
    fn jobs(&self) -> Vec<Arc<dyn Job>> {
        vec![
            Arc::new(PublishContentJob),
            Arc::new(RefreshCacheJob),
        ]
    }
}

Agent Jobs

Jobs that invoke agents:

jobs:
  - name: morning_briefing
    type: agent
    agent: briefing-agent
    task: "Generate morning briefing for team"
    schedule: "0 0 8 * * MON-FRI"

Hybrid Jobs

Jobs that combine code and agents:

jobs:
  - name: data_pipeline
    type: hybrid
    steps:
      - type: code
        job: fetch_data
      - type: agent
        agent: analyst
        task: "Analyze the fetched data"
      - type: code
        job: store_results

Reliability Features

Timeouts

Prevent runaway jobs:

jobs:
  - name: analysis
    agent: analyst
    timeout: 600s  # 10 minute maximum

Retries

Handle transient failures:

jobs:
  - name: sync_data
    job: sync_external
    retry:
      max_attempts: 3
      backoff: exponential
      initial_delay: 10s

Budget Limits

Control AI costs:

jobs:
  - name: content_generation
    agent: writer
    budget:
      max_tokens: 50000
      max_cost_usd: 5.00

Dead Letter Queue

Handle persistent failures:

scheduler:
  dead_letter:
    enabled: true
    retention: 7d
    notify: ops@example.com

Observability

Job Logs

View job execution:

# List recent jobs
systemprompt infra jobs list

# View job details
systemprompt infra jobs show <job-id>

# Follow job logs
systemprompt infra jobs logs <job-id> --follow

Metrics

Track job performance:

# Job success rates
systemprompt analytics jobs success-rate

# Average duration
systemprompt analytics jobs duration

# Cost per job
systemprompt analytics jobs costs

Alerts

Configure job alerts:

scheduler:
  alerts:
    - condition: job_failed
      notify: slack
      channel: "#ops-alerts"
    - condition: duration > 5m
      notify: email
      to: ops@example.com

Use Cases

Automated Content Pipeline

# Publish new content every 30 minutes
jobs:
  - name: content_pipeline
    schedule: "0 */30 * * * *"
    workflow:
      - agent: curator
        task: "Select next content to publish"
      - job: publish_content

Daily Analytics Reports

# Generate insights every morning
jobs:
  - name: daily_insights
    schedule: "0 0 9 * * *"
    agent: analyst
    task: "Analyze yesterday's data and generate report"
    output:
      - email: team@example.com
      - slack: "#daily-metrics"

Real-Time Event Processing

# React to webhook events
triggers:
  - type: webhook
    path: /hooks/github
    agent: devops
    task: "Process GitHub event and take appropriate action"

Periodic Data Sync

# Sync external data sources
jobs:
  - name: sync_crm
    schedule: "0 0 */4 * * *"
    job: sync_salesforce
    on_complete:
      agent: analyst
      task: "Summarize new data and flag anomalies"

Getting Started

CLI Help: Run systemprompt infra jobs --help for command options. See CLI Reference.

  1. Configure the scheduler:
# services/scheduler/config.yaml
scheduler:
  enabled: true
  jobs:
    - name: my_job
      agent: my-agent
      task: "Perform automated task"
      schedule: "0 0 * * * *"  # Every hour
  1. Create the agent:
# services/agents/my-agent.yaml
name: my-agent
system_prompt: |
  You perform automated tasks reliably.
  1. Start the scheduler:
systemprompt infra services start scheduler
  1. Monitor execution:
systemprompt infra jobs list --follow

Previous Next
Audit Logging Getting Started