Skip to content

7. Business layer — run a services team with AI agents

Difficulty: advanced · Time: 30 minutes · Ends at: three agents that clock in at 9am, claim tickets from a backlog, report progress, and produce a daily summary

Scenario

A small consulting firm has three AI teammates — Alice (marketing), Bob (dev), Carol (ops). You want them to:

  1. Clock in at 9am and receive a daily standup prompt
  2. Pull work from a shared backlog file (or GitLab)
  3. Claim and report tasks — status, time spent, blockers
  4. Clock out at 6pm with a daily summary posted to the team Telegram group
  5. Leave a KPI trail you can review weekly

This is the business layer — a day-cycle ticker + work-pool + KPI store + reporter built on top of AgentX's core.

Prerequisites

  • Three agents configured (see Journey 3)
  • A Telegram group where the daily report lands (chatId noted)

Config

json
{
  "business": {
    "enabled": true,
    "timezone": "Africa/Tunis",
    "mainChannel": {
      "channel": "telegram",
      "chatId": "-1001234567890",
      "accountId": "default"
    },
    "workSource": {
      "type": "backlog",
      "path": ".agentx/backlog.md"
    },
    "workTickMinutes": 15,
    "idleQueueThreshold": 0,
    "roles": {
      "marketing": {
        "title": "Marketing Lead",
        "responsibilities": [
          "Content drafts (blog, social)",
          "SEO monitoring",
          "Lead intake triage"
        ],
        "kpis": ["Published pieces per week", "Lead response time"]
      },
      "dev": {
        "title": "Engineer",
        "responsibilities": [
          "Ship issues from backlog",
          "Code review teammates",
          "Keep CI green"
        ],
        "kpis": ["Issues closed per day", "CI pass rate"]
      },
      "ops": {
        "title": "Operations",
        "responsibilities": [
          "Monitor production",
          "Weekly cost report",
          "Incident triage"
        ],
        "kpis": ["Uptime", "MTTR", "Spend per week"]
      }
    },
    "orgChart": {
      "alice": {
        "role": "marketing",
        "schedule": { "days": ["mon","tue","wed","thu","fri"], "start": "09:00", "end": "17:00" },
        "utilizationTarget": 0.75
      },
      "bob": {
        "role": "dev",
        "reportsTo": "carol",
        "schedule": { "days": ["mon","tue","wed","thu","fri"], "start": "09:00", "end": "18:00", "lunch": { "start": "12:30", "end": "13:30" } },
        "utilizationTarget": 0.8
      },
      "carol": {
        "role": "ops",
        "schedule": { "days": ["mon","tue","wed","thu","fri","sat"], "start": "08:00", "end": "16:00" },
        "utilizationTarget": 0.7
      }
    }
  }
}

The backlog file

The simplest work source is a GitHub-flavored markdown checklist at .agentx/backlog.md:

markdown
# Backlog

- [ ] @alice Draft launch blog post [time: 2h]
- [ ] @alice Refresh LinkedIn banner [time: 30m]
- [ ] @bob Fix login redirect bug — issue #142 [time: 1h30m]
- [ ] @bob Migrate `/users` endpoint to v2 [time: 3h]
- [ ] @carol Rotate GitLab token on clawd-server [time: 45m]
- [ ] @carol Weekly cost review [time: 1h]

Each unchecked line is a work item. The line number is the stable ID, so the file stays readable. When an agent reports done, AgentX flips [ ][x] and appends (done YYYY-MM-DD).

Other work sources

json
{ "workSource": { "type": "gitlab", "projects": ["noqta/agentx", "noqta/website"] } }

Pulls open GitLab issues assigned to each agent as work items.

json
{ "workSource": { "type": "wiki", "path": ".agentx/wiki/projects", "glob": "**/*.md" } }

Treats every matching wiki article as a work item (useful for knowledge-curation teams).

What the day-cycle does

Every minute, a ticker evaluates each agent against orgChart[agent].schedule:

EventWhen it firesWhat the agent gets
StandupFirst minute of the agent's schedule window, once per day"It's 09:00 Monday. Here are your responsibilities, open work items, yesterday's KPI. Plan today in 3 lines."
Work tickEvery workTickMinutes during hours"Pick the next item from your work pool, claim it, and start. Report when done."
WrapLast minute of the schedule window"Summarize: what closed, what's blocked, what rolls to tomorrow."
Day rolloverMidnight in timezonePer-agent state resets

The idleQueueThreshold skips work ticks if the agent already has N queued messages (avoids piling up during standup bursts).

Commands agents can call (via HTTP)

Each agent's context is injected with the business HTTP API (src/business/http.ts):

bash
# List my open items
GET /business/work/list?agent=bob

# Claim one
POST /business/work/claim
{ "agent": "bob", "itemId": "backlog:3" }

# Report progress
POST /business/work/report
{ "itemId": "backlog:3", "status": "in-progress", "note": "debugging redirect loop" }

# Report done
POST /business/work/report
{ "itemId": "backlog:3", "status": "done", "timeSeconds": 4200 }

# Report blocked
POST /business/work/report
{ "itemId": "backlog:3", "status": "blocked", "blocker": "needs prod credentials" }

# Clock out (emits a per-agent KPI snapshot)
POST /business/clock-out
{ "agent": "bob" }

Agents don't usually call these directly — the prompts injected by the day-cycle do.

KPIs

For each agent, AgentX tracks:

  • Hours accrued on-clock
  • Tasks completed / blocked
  • Estimation accuracy (estimatedSeconds vs timeSeconds)
  • Utilization vs utilizationTarget

Pull the current snapshot:

bash
curl http://localhost:19900/business/kpi/today
curl http://localhost:19900/business/kpi/week

Or see token cost alongside:

bash
agentx usage today
agentx usage serve --port 4300   # dashboard

The daily reporter

At the end of each day, AgentX posts a summary to business.mainChannel:

Daily summary — Monday 2026-04-13

▸ alice (marketing) — 5h30m on clock, 3 tasks done, 1 blocked
  • Launch blog post draft (done, 1h45m vs 2h est)
  • LinkedIn banner (done, 20m)
  • SEO audit (blocked: need GSC access)

▸ bob (dev) — 7h20m on clock, 2 tasks done
  • Login redirect (done, 55m vs 1h30m est)
  • /users v2 migration (in progress, 4h logged)

▸ carol (ops) — 6h on clock, 2 tasks done
  • Token rotation (done, 40m)
  • Weekly cost review (done, 55m)

Team utilization: 73% (target 75%)

Verify

  1. Set each agent's schedule.start to a minute from now, end five minutes later.
  2. Watch the daemon:
    [business] STANDUP → alice
    [alice] executing standup prompt
    [business] WORK-TICK → alice (3 open)
    
    [business] WRAP → alice
    [business] daily summary posted to telegram:-1001234567890
  3. Check .agentx/backlog.md — the items the agents claimed should be marked [x].

What's next

Released under the MIT License.