AI & agents

Agent scheduling, approvals and run cost

Runs agents on a schedule, holds risky actions for a human decision and records what each run consumed.

BetaEngine edition 5f8ea3af

What it does

Three operator controls around the agent runtime. A cron scheduler fires stored agent tasks once per minute bucket. An approval gate parks destructive or external actions until an administrator decides, and denies on timeout. Each run records token usage and an estimated cost, with a summary endpoint over a window of days.

How it works

POST /admin/agents/schedules stores an agent id, a task and a five-field cron expression, validated on creation. A background task wakes every 60 seconds, evaluates each enabled schedule against the current minute bucket in UTC and, when due, claims that bucket with a deterministic claim entity, so a schedule fires once per bucket even when several processes share one log. It then runs the agent and writes last_run_at and last_run_id back to the schedule. The first tick after boot is skipped, and the scheduler does not run on a read replica.

Every action declares its effect once: reads and reversible writes run freely, destructive writes and external effects require approval. Before such an action runs, the shared execution gate opens a pending approval record, with secret-looking argument keys redacted by name, appends a request event to a content-free audit outbox and parks the run for up to 300 seconds. An administrator decides with POST /admin/agents/approvals/{id}/approve or /reject; the decision and the deciding actor are stored on the record. A rejection, a timeout or a missing approval service denies the action, which never executes, and the run continues with an error result for that tool.

In the shipped action set, deploy_to_provider, destroy_provider_instance and create_cloudflare_hyperdrive are gated. The batch loop and the streaming loop that the server exposes both call the same gate, as does the library durable loop, and a test per path checks that a denying decider blocks execution.

Each run sums the input and output tokens that providers report, and prices them from a built-in per-token table. GET /admin/agents/runs/summary?days=N totals tokens and cost over the last N days (default 7).

Where you reach it

  • HTTPPOST and GET /admin/agents/schedules, DELETE /admin/agents/schedules/{id}
  • HTTPGET /admin/agents/approvals, POST /admin/agents/approvals/{id}/approve, POST /admin/agents/approvals/{id}/reject
  • HTTPGET /admin/agents/runs/summary?days=7

Example

Run an agent every weekday at 07:30 UTCbash
curl -s -X POST "$KYNETRA_URL/admin/agents/schedules" \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "agent_id": "'"$AGENT_ID"'", "task": "Report collection sizes", "cron": "30 7 * * 1-5" }'

Limits

  • Schedules have minute resolution and use UTC. A minute missed while the server is down is not made up afterwards.
  • The approval hold lasts 300 seconds. There is no outbound notification, so an operator must poll the approvals list or watch the admin console.
  • Redaction works on key names. A secret typed into a free-text value is stored in the pending approval record.
  • Cost is an estimate from a built-in per-token price table at whole-unit resolution, and an unknown model is priced at zero. The dollar field of the summary uses a unit scale that does not match the table and under-reports. Budget from the token totals instead.
  • Actions are gated by the effect they declare, and the built-in read actions are not. Choose action allow-lists with that in mind.
  • All of these routes need an admin role.

Evidence

  • On this siteAI features catalogue
  • Tests6 approval-gate tests cover denial, approval, fail-closed behaviour with no decider and the batch, streaming and durable paths; 10 approval tests cover redaction, a single winner among concurrent decisions, project scoping, a content-free audit trail, fail-closed expiry and waiter wake-up; 4 tests cover schedule creation, firing, deletion and the replica rule

Test coverage is listed as present in the engine repository at this edition. This page does not report test results.

KynetraDB is in private preview

Request a preview to talk through the limits above against your own workload.