Esta página aún no se ha traducido - se muestra la versión en English.

routines

Prompts the agent runs on a schedule, made by asking it, run as the person who asked.

En esta página

Routines

A routine is a prompt the agent runs on a schedule, as the person who made it. "Every weekday at 9, check the build and tell me what broke" is a routine. A person makes it by asking the agent, and the agent keeps it in the chat database. The answer can go to a gateway, and a routine can keep reports as files.

Routines are not schedulers. They are for the people who use the agent, not for the developer.

schedules/*.bx schedulerRoutine
Who makes itThe developer, in a fileAnyone, by asking the agent
Where it livesIn the project, shipped with the agentIn the chat database, per person
Runs asThe appThe person who made it, with their notes and volumes
Changed byEditing the file and rebuildingAsking the agent, while the app runs
Turned on byExistingroutines.enabled: true
flowchart LR
  P[Person asks the agent] --> T[routine_schedule, approved by the person]
  T --> S[(routines table)]
  H[Heartbeat, every minute] --> S
  H --> R[Runner]
  R --> C[The routine's own conversation]
  R --> L[routines.log and heartbeat.log]

Turn it on

Routines are off by default, so a published agent never grows automated work by surprise.

routines:
  enabled: true
  minInterval: 5m
  timezone: Europe/Madrid

With the feature off there are no routine tools, no heartbeat and no routines capability. The settings:

SettingDefaultMeaning
enabledfalseTurns the feature on
maxPerUser20The most routines one person may have (1 to 200)
minInterval5mThe shortest a routine may repeat (1m to 1d)
maxParallel2How many routines the heartbeat starts in one beat (1 to 10)
maxPromptLength4000The longest prompt, in characters (200 to 20000). Longer instructions belong in a skill
approvalTimeout24hHow long a run waits for a person to approve a tool (5m to 7d)
timezonethe server'sThe time zone cron expressions are read in, an IANA name such as Europe/Madrid
summaryLength1500How many characters of an answer are sent to a gateway (200 to 4000)
maxReportSize256kbThe largest report file a routine may save (1kb to 5mb)
maxReportFiles500The most files in one routine's results folder (10 to 5000)

A duration is a whole number with m, h or d, and a size a whole number with kb or mb. A bad value stops the build and doctor names it.

Making one

Ask the agent: "every weekday at 9, check the build". The agent calls routine_schedule and a person approves it, as for any tool that needs approval. The answer says when it first runs.

A schedule is stored in one of two forms:

  • a 5 field cron expression, minute hour day-of-month month day-of-week, such as 0 9 * * 1-5
  • an interval, every 30m, every 2h or every 1d

The model turns plain words into one of these, and the tools answer with the English reading ("weekdays at 09:00") and the next run time, so a mistake is seen straight away.

The Routines page in the web app: three routines, one paused, with the schedule in words and the next run

The reports of one routine, with a report open

Routines have a page in the web app: list, make, edit, run, pause, resume, delete, and read the reports.

The tools

Every tool the agent gets from BX Agents is named {type}_{action}, so permissions can match them by pattern later.

ToolDoesNeeds a person's approval
routine_scheduleMakes a routine, and says where its answer goesYes
routine_listLists yours, with when each runs next and how the last run wentNo
routine_updateChanges the schedule, the prompt, where the answer goes, or any of themYes
routine_pauseStops one without deleting itNo
routine_resumeStarts a paused one again, and clears its failuresNo
routine_runRuns one at the next beat instead of waitingNo
routine_deleteDeletes one. Its conversation and reports stayYes
report_saveSaves a report file, for the routine that is running. Refused anywhere elseNo
report_listLists a routine's report filesNo
report_readReads oneNo

The tools act as the person in the conversation, never as an admin, and only the root agent has them. A routine's own run is refused the routine_* tools, so a routine cannot make or change routines. There is no tool that deletes a report.

A run

Every minute the heartbeat, a scheduler the build adds, looks for routines that are due and starts them, at most maxParallel at once. Each run:

  • is a normal turn as the person who owns the routine, so their notes, volumes and tool approvals all apply, and nothing extra is allowed
  • happens in a conversation of its own, routine-<name>-<id>, which the person finds in their conversation list and reads like any other
  • never overlaps itself: a routine still running is skipped, and the skip is logged
  • stops for approval like any chat. The routine shows as waiting, the person answers in its conversation, and after approvalTimeout the run is cancelled and counts as a failure

Three failures in a row pause the routine. routine_resume starts it again. If the server was down when a routine was due, it runs once on start, never once per missed time.

An admin sees and manages every person's routines. Nobody else can see yours.

Where the answer goes

Each routine has a destination, set when it is made:

DestinationMeaning
nothing saidThe gateway chat the person is writing in, if that is where they asked. Otherwise the routine's own conversation
routineThe routine's own conversation only
gateway:telegram (any gateway)A chat on that gateway

Gateways belong to the person who runs the agent. A person writing from a gateway may send a routine's answer to their own chat there. Anyone else is limited to the routine's own conversation, and the local user can choose a gateway, naming the chat when it has talked to more than one. A gateway can only write to a chat it has already heard from, because that is when the agent learns its address (and for Teams, the address it needs to reply). If the gateway has talked to nobody, the agent tells the owner to message the bot once.

What is sent is a summary: the answer cut to summaryLength characters, headed Routine <name>:, and a last line naming the reports the run saved. The whole answer is in the routine's conversation. A message that cannot be sent (the gateway is not connected, the chat is unknown, the platform refuses) counts as a failed run, so three in a row pause the routine, and routines.log says why. The log never holds the text.

A run that stopped for an approval is not sent anywhere once a person answers: its answer is in its conversation.

Reports

A routine can save what it found as files: report_save( file, content ) while it runs. They go in <data home>/routines/<name>-<id>/, are never overwritten (a name already used becomes report-2.md), and are never deleted automatically.

  • A file name is letters, digits, ., _ and -, up to 80 characters, ending in .md, .txt, .json, .csv or .html.
  • A file is at most maxReportSize, and a folder holds at most maxReportFiles; at the limit the agent is told a person has to clean up.
  • The agent reads reports back with report_list and report_read for the person's own routines. A long file is cut when read.
  • The reports are in a backup.

Logs

routines.log records each routine made, changed, run, skipped, failed, sent and paused, and each report saved (its name, never its text), and heartbeat.log the beats that started something. A prompt is never logged, only the routine's name and its owner. See logs.

Managing routines

Making and changing a routine is usually asked of the agent, where a person sees it and approves it. The terminal, the API and the web page can also make and change one directly. Everything else can be done from each surface, and every surface goes through the same service, so they cannot disagree.

SurfaceDoes
Chat: /routines, /routine <name> [run \| pause \| resume \| delete confirm \| reports \| report <file>]List yours (an admin adds all), show one, run, pause, resume, delete (only with confirm), list and read reports
Terminal: bxAgents routines list \| show \| add \| edit \| pause \| resume \| run \| delete \| reports \| report \| cleanThe same, as the local operator, so --all lists every owner's. See the CLI reference
APIGET /routines and the routes below, for your own program
Web pageThe Routines page of the menu (<path>/routines): a list with run, pause, edit, delete, reports and clean-up

run marks a routine due. It starts within a minute, by the heartbeat of a served app, so from a terminal that is not serving the app nothing starts until the app is running.

The /routines and /routine commands are for the terminal and the web page. They are not on gateways yet: a person there asks the agent, which has the routine_* tools.

Reports are removed by a person

Nothing in a chat deletes a file, and the agent has no tool for it. A person removes one report, or the old ones, from the terminal, the API or the web page:

  • bxAgents routines clean <name> --older-than=30d (or --all) only says what it would remove. Add --yes to remove it.
  • The API's POST /routines/reports/clean does the same, and removes only with "apply": true.
  • The web page asks first how many files and bytes it would remove, then asks you to confirm.

Deleting a routine keeps its reports. The count of what a clean-up removed is logged in routines.log, never a name or text.

Routes

RouteDoes
GET /routines (all=1 for an admin)List, with the schedule in words, status, next and last run, destination and the routine's conversationId
GET /routines/get?name=One routine with its full prompt
POST /routinesMake one: name, schedule, prompt, optional destination and chat
POST /routines/updateChange schedule, prompt or destination
POST /routines/pause, /resume, /run, /deleteAs the tools, with name
GET /routines/reports?name=, GET /routines/report?name=&file=List and read reports
POST /routines/reports/deleteRemove one report (name, file)
POST /routines/reports/cleanname, olderThanDays or all; removes only with apply

Every route answers 404 with "Routines are not turned on" when the feature is off. People see only their own routines, and an admin may act on anyone's by id, or by a name only one owner has. An admin may also send a routine's answer to a gateway, which the tools do not allow for a chat-scope person.

Editar esta página Descargar Markdown Última actualización Nov 26, 2026, 8:45:51 AM Report an issue