* docs(agent): add ADR 016 on agent channels A channel is a place outside the agent's own page where people talk to it and get its replies. It is its own concept beside triggers: a trigger reacts once to an event, a channel carries a conversation that continues. * feat(agent): add channels and replies with no member behind them A conversation a channel started is shared, has no owner and holds visitor messages. Its replies run on the channel's authority and stop once the channel is off, trashed or deleted. A reply that can call tools keeps its text out of the stream, so nothing written before a tool call reaches a visitor. Members can read such a conversation, filter for it and decide its held calls, but not write in it. * feat(agent): add channel types, the visitor service and the channels API Channel types are a registry and each type keeps its own data in a subclass. Builders list, add, change and delete an agent's channels, with audit actions and trash. One service holds everything an anonymous visitor may do. * feat(agent): add the public chat channel with its visitor API A public chat is a page with its own link and an optional password. Anyone with the link talks to the agent through an anonymous API that shows a message's text only; a signed token says which conversation is theirs. * feat(agent): show visitor conversations to members A conversation a channel started reads "Started by a visitor" in the list and can be filtered. The visitor's messages sit on the right under their label, and the composer gives way to a note, since members don't write in it. * feat(agent): add the public chat page The page a visitor opens from the link: the title and welcome text, the conversation, and a password form when the chat is protected. It keeps its tokens in local storage and recovers a reply through one sync path, so it never stays on the typing dots. * feat(agent): add the Channels section to the agent configuration A builder adds a public chat, copies its link, sets a title, a welcome text and a password, switches it off or deletes it. The link and password controls match the ones shared views and dashboards have. * feat(agent): edit the public chat's welcome text with the rich text editor The card shows the text formatted while it is written and saves it as markdown. The public page shows it read-only with the same component, so the builder sees what the visitor gets. * feat(agent): give channels and visitor conversations their own icon The person icon marks a private conversation and the globe the HTTP trigger, so channels use two bubbles: a conversation with someone outside the workspace. * fix(agent): harden public chat replies, sends and exports after review - A reply that can call tools keeps no draft: when it fails, is stopped or waits for approval, the visitor sees nothing rather than text it wrote before a tool call. - One rule decides whether a channel can be used, for the visitor API and for the worker before a reply starts or resumes, licence included. - Visitor sends can be repeated safely. A lost first message is recovered only with a secret key the page generated, never with ids members can read. - Visitor conversations never become template examples, even when pinned. - Visitor responses are never cached, and passwords are taken exactly as typed when set and when checked. * fix(agent): harden the public chat page and Channels section after review - The page sends a secret key with the first message and ids with the next ones, so a resend after a lost answer runs nothing twice, and shows each message once. - It asks for a password when the chat became protected, retries a failed first load with backoff while saying so, and shows a stopped reply. - The password modals wait for the server before the switch changes. - In a workspace without Advanced or Enterprise a card only allows switching the chat off and deleting it. - The welcome text is checked against its limit before it is saved. - In a visitor's conversation the reject dialog says the visitor may see the reason, and the conversation filter is named Channels. * fix(agent): fit the Permissions section description on one line * fix(agent): open a protected public chat only once the server grants access The page took a stored token as proof of access and guessed a refused one from an empty title, so a failed info request after the password showed a blank chat. The info endpoint now says whether the request has access, and the page shows the chat only on that answer. * fix(agent): open a protected public chat without flashing the password form The server renders the page without the visitor's token, which only the browser keeps, so a saved session showed the password form until the info reloaded. The page now shows neither the form nor the chat until the browser has checked its stored token. * fix(agent): read the public chat from the primary database A replica can lag behind a chat that was just switched off or given a password, so visitors could keep using it until the replica caught up. * fix(agent): cap the length of a public chat password guess * fix(agent): back off syncing a public chat reply that waits for a member A reply can wait for approval for hours, so the visitor page now checks less often, up to once a minute, and right away when the tab is shown. * fix(agent): refuse an agent message's uuid sent again by a visitor A visitor and the agent both write without a sender, so a visitor resending an agent message's uuid and text got it back as accepted, with no reply after it, and a 500. The retry now also needs the role of the sender. * fix(agent): keep syncing a resent public chat reply that waits for approval A resend can get back a reply without a run, which opened no stream and started no sync, so the page never showed the decision. Following a reply now syncs whenever no stream follows it. * fix(agent): send a heartbeat for each run record a visitor can't see During a long tool run the visitor's stream dropped every record, so the page saw nothing, reconnected every 15 seconds and replayed the hidden records each time. * fix(agent): word the approval and workspace access instructions for visitors They told the agent that the reader approves held calls and can restore the Run as identity, which is wrong for a visitor and shares internal configuration with them. * feat(agent): copy channels switched off with a link of their own A copy of an agent now keeps its channels, so a builder doesn't have to set them up again, but none answers before a member turns it on, and each gets a new link. Only a duplicate or a snapshot restore keeps a public chat's password; file exports and templates leave it out. Copied visitor conversations stay on the copied channel.
19 KiB
ADR 014: Start agent runs from core trigger services
| Status | Proposed |
| Date | 2026-11-09 |
| Issue | https://github.com/baserow/baserow/issues/6259 |
| Author | Davide Silvestri (@silvestrid) |
| Contributors | Bram Wiepjes (@bram2w) |
Summary
Agents only answered when a person wrote to them. We let an agent own triggers built
on the trigger services Automation workflows already start from, and open a
conversation whenever one fires. Three decisions carry this: trigger service types
notify every registered listener and expose arm() so a service can go live without
Automation's publish step; a trigger-started conversation is shared, like one a
person chose to share; and an unattended run pauses on held calls until an editor
decides them, like any other run.
Context
Trigger service types (periodic, http_trigger, email_trigger, the row and field
signal types) produce events and find the Service rows that should receive them.
Until now each type held exactly one callback, set by the Automation trigger node type
when it registered; a second consumer replaced it. Making a service live was done
inline when a workflow was published: the import code set next_run_at for periodic
services and is_public for HTTP and email services.
Agent conversations had a non-null owner. The owner was the permission subject every reply ran as, the only reader, the realtime recipient and the only possible approver. Nothing expected a reply to start without a person, except the core chat-run engine, which already accepts runs with no user.
Agent Builder is behind FF_AGENT_BUILDER and has no production users, so no
mixed-version compatibility is needed for these changes.
| Term | Meaning |
|---|---|
| Trigger | An AgentTrigger row: an agent-owned wrapper of one trigger service, with an enabled switch and a message formula. |
| Trigger service | The Service row (periodic, HTTP, email, rows) that produces events; owned by exactly one consumer. |
| Event payload | The dict a service type produces per event; exposed to the trigger message as the trigger data provider. |
| Listener | A callable a consumer registers to receive (services, event_payload, user, isolate_failures). |
| Armed | A trigger service that receives real events now: periodic next_run_at set, HTTP/email is_public. |
| Shared conversation | A conversation with shared set; readable by everyone with read_conversations on the agent. |
| Private conversation | A conversation started by a person and not shared; visible to its participants only. |
| Run identity | The subject the agent's tools act as. Never a conversation owner, never an author. |
| Ask-first tool | An allowed tool whose calls pause the reply until a person approves them. |
In scope: how events reach consumers, how a service goes live, who owns and sees trigger-started conversations, and what an unattended run may do. Out of scope: which trigger types the picker offers (a constant, widened per release), rate limits and auto-disable, the agent-level pause and "Run once". A person outside Baserow talking to an agent is not a trigger but a channel: see ADR 016.
Decision
1. Trigger fan-out and arming live in core
TriggerServiceTypeMixin keeps a list of listeners. start_listening(cb) appends and
calls connect() when the list was empty; stop_listening(cb) removes and calls
disconnect() when it becomes empty; on_event materialises the services once and
returns every listener's results concatenated. ServiceTypeRegistry.add_trigger_listener(cb)
subscribes a consumer to every trigger type, including types registered later, so the
order of INSTALLED_APPS and plugins does not matter.
arm(service) is the one way to make a service receive real events. Periodic sets
next_run_at; HTTP and email set is_public. Automation's publish calls the same hook
instead of its three inline branches; agents call it when a trigger is created, its
service values change, or it is enabled. There is no disarm: a disabled trigger keeps
its schedule and is skipped at dispatch, a trashed one leaves the due set with its
service.
ServiceMisconfigured is a core exception; Automation's error subclasses it, so
the periodic service type no longer imports an Automation exception at module level.
A consumer holds the foreign key to its service (AgentTrigger.service, as automation
nodes, data sources and button actions do). Service knows no owner.
2. A trigger-started conversation is shared
A trigger-started conversation has no owner, is shared and started_by_trigger, and
a trigger foreign key (set to null when the trigger is deleted) records what started
it. A person's conversation starts private, and its owner can share it for good: once
others may have read it, making it private again wouldn't take back what they saw.
Shared conversations are visible to everyone with read_conversations on the agent;
private ones to their participants: the owner, and whom the owner asked to approve
held calls. Those keep access after the decision, and after the owner leaves or deletes
their account. Each message records its sender, and a reply runs for the person it
answers, or for the person whose decision resumed it.
Three operations decide who takes part: create_message sends messages in a
person's conversation, approve_tool_calls decides held calls, and
continue_triggered_conversation sends messages in a trigger-started one. With RBAC,
per-agent rules set each to a lowest role, specific users or teams, or nobody. Chat
and approve default to Editors and above, continue to nobody, workspace admins
included; approve can't be nobody, or no held run could resume. Without RBAC every
member chats and approves and nobody continues; stored rules are kept, not applied.
Always allowing a tool also needs configuration access.
Renaming, trashing, restoring and stopping a shared conversation additionally require
application.update; only the owner changes a private one. The person a reply answers
can always stop it. Following its runs live requires read_conversations. Realtime
updates go to the users permitted to read the agent's conversations, or to a private
one's participants, and the pending count to everyone who may decide the held calls.
Viewers read conversations, and may trash and restore their own private ones, such as one left from an older role. Renaming needs the editor role, the lowest role that may create a conversation.
Everyone in a private conversation can remove it from their own list ("Delete for me"), and the others keep it; only its owner deletes it for everyone. The owner leaving alone trashes it, as deleting does. Once the owner has left, the last person to leave deletes it for good, because only an owner's trash may list a private conversation: without one, every trash reader would see it. A person removed from the workspace leaves the conversations they were asked into, and the rules that name them, as they lose their role assignments; the ones they own are kept. Shared deletion, restoration, renaming and stopping require the existing management permissions. A reply stopped by someone else says who stopped it. Realtime delivery checks conversation visibility.
The opening message, with role trigger, holds the resolved trigger message, a runtime
formula over the event payload. A message with no text opens with the trigger and when
it fired. A trigger with no message formula also gets what its agent trigger type says
about the event, such as the body of an HTTP request; one whose formula resolves blank
doesn't, as its builder chose what the agent reads. The whole payload is never sent: it
can hold a request's headers and the sender's address.
It is the only record of what the model received; the title derives from it, and no raw
payload column exists. Triggers that arrive through duplicate, snapshot restore or
template install are always disabled.
3. Trigger runs have no sender
A trigger run's tools act as the agent's run identity, as in any run, but the run has
no sender: created_by names the person who sent the message, and a trigger isn't
one. So created_by=None: the per-user run cap does not apply, the workspace cap does, and a cap hit records a failed reply with the code
chat_run_limit_reached instead of disappearing. Ask-first tools are offered as in any
run: a held call pauses the reply until an editor decides it, and the resumed run
has no sender either. A waiting reply counts as going, so the trigger's overlap rule
skips or queues the firings that come meanwhile instead of piling up waiting
conversations. Their tools read dates in the trigger's
timezone (the service's own, or UTC when its type has none), so a daily digest's
"today" is the day the builder scheduled it for.
An unattended reply may pause to ask a person: the built-in ask_person tool is held
like an ask-first call, so the question shows where approvals show, counts as going for
the overlap rule, and is answered by those who may approve tool calls. The answer, or a
note that nobody will answer, comes back as the call's result, like a deferred tool
call. Later replies replay a decided question and its answer, or the dismissal, as
plain turns in their history. A trigger's may_ask_person stops new questions, and the
agent is then told to finish or explain what is missing; a question already waiting
still gets its answer.
The dispatcher resolves the payload of every matched trigger before filtering, so a
disabled trigger still advances its schedule and never fires a backlog when enabled
again. It resolves each enabled trigger's message during the event, then starts the
conversation in a task once the event's transaction commits, in a transaction of its
own: the workspace run lock lasts until the outermost commit, which must not be the
rest of a beat tick. The task checks again that the trigger is enabled, its type is
available and its agent is ready, and logs instead of raising. A message whose formula
fails at run time opens the conversation with when the trigger fired and fails the
reply with trigger_message_failed, so the list shows why the agent didn't answer.
4. One overlap rule bounds a trigger's replies
Each trigger's overlap rule sets how many of its replies may be going (running or waiting for approvals) and how many may wait, queued without a run:
| Rule | Going at once | Queued |
|---|---|---|
| Skip | 1 | 0 |
| Wait | 1 | AGENT_TRIGGER_MAX_QUEUED_RUNS |
| Parallel | AGENT_TRIGGER_MAX_PARALLEL_RUNS |
AGENT_TRIGGER_MAX_QUEUED_RUNS |
A firing starts when there is room to go and nothing is queued ahead of it, queues
when the queue has room, and is skipped otherwise; a cap of 0 or less means no
limit. A firing the workspace's run limit holds back queues where the rule queues,
and fails visibly where it doesn't. When a reply ends, in a task of its own, and
every minute as a safety net, the trigger's oldest queued replies start while there
is room and the trigger could fire; otherwise they keep waiting. The rate limits
apply before the rule. The rule lives in OverlapLimits, small enough to move to
core when another background feature needs it.
Options considered
| Option | Why not |
|---|---|
| A registry of trigger consumers | Two consumers exist; a listener list is enough and keeps Service ignorant of who owns it. |
A reverse foreign key from Service to its owner |
Breaks the consumer-holds-the-key precedent of nodes, data sources and button actions. |
Arm in after_create / after_update |
Also runs for automation drafts, which must not go live. |
| Owner = the trigger's creator or the run identity | Visibility would hang on one account; deleting it would trash the run log; identities are not people. |
| A trigger-type column on the conversation | Derivable from the service's content type; stale after a type rename. |
| Store the raw payload next to the opening message | A second source of truth; the periodic payload is two timestamps. Revisit with row triggers. |
| Leave ask-first tools out of unattended runs | Silently drops tools the builder allowed; the overlap rule already bounds the waiting replies. |
| Refuse to arm while any allowed tool asks first | Blocks the common digest case and leaks approval semantics into arming. |
| Agent hooks on the shared service type | The type and its form serve Automation too; an opt-in agent trigger type holds what agents change. |
| Send the whole payload when there is no message | It holds an HTTP request's headers and sender address; each new type would leak until curated. |
Consequences
- A new trigger service type needs no agent model or dispatch code. Before it enters
AGENT_TRIGGER_TYPES_ENABLED, its form must be verified in the agent host and its reach reviewed: row triggers read tables the builder could read when saving, in any workspace, and HTTP and email triggers hand unauthenticated input to a run that may use write tools. - Plugins that overrode
start_listeningorstop_listeningon a trigger service type must overrideconnectanddisconnectinstead; theon_eventclass attribute is now a method. - A reply runs for its
sender, or the person whose decision resumed it, not the conversation's owner: they differ, and the owner can be gone. - Readers of a shared conversation see what the run identity could read. Builders pick the identity knowing that.
- The periodic beat tick only resolves trigger messages; conversations start in tasks after it commits. Rate limits and auto-disable follow before other types are offered.
- Follow-ups: in-app notifications for waiting approvals, the agent-level pause
switch, "Run once" and "Last run", email triggers in the picker, per trigger rate
limits and auto-disable, the setup wizard's "Run automatically" step, a "Row comment is created"
trigger type, the
manualtype (hidden until something can start an agent), an optional shared secret for HTTP triggers, and sample data for their message picker.
Adding another trigger
Reuse the registered integration service type and its form. Agents already listen
to every TriggerServiceTypeMixin, call arm() and resolve messages against the
service's payload and schema. Do not add an agent-specific service, model, endpoint
or dispatcher for an existing trigger. Qualify the type through the Agent API,
its real event entry point and the mounted Agent form before adding its identifier
to AGENT_TRIGGER_TYPES_ENABLED. Verify copy/import, disabled and trashed agents,
and the existing consumer's behavior as well.
Where an agent needs something else than the service type gives, register an
AgentTriggerType under the service type's name, on the backend, the frontend or
both. It is opt-in: a type without one is hosted as it is. The backend one can say
what an event tells an agent whose trigger has no message, give a new service other
defaults, and name the service fields an agent doesn't use, which then keep their
defaults. The frontend one can word the default message and name the form fields to
hide. Nothing agent-specific goes on the shared service type or its form: any form
built on the form mixin takes hiddenFormFields from its host, and a hidden field
isn't shown, validated or sent. A hook on the shared service type is fine when it
names no consumer and its default keeps every existing type as it is; what an agent
does with it stays in agent code.
The HTTP trigger uses all of it. Agents hide the test URL and the workflow response
settings: a firing starts a run in the background, and a valid request is always
acknowledged with 204, never with the agent's reply. That acknowledgement doesn't
guarantee a run, as the usual readiness, rate and overlap rules still apply. New
triggers exclude GET, so a link preview opening the URL starts nothing. The default
message is the request's raw body, and a trigger with no message gets the raw body
too; headers and the sender's address reach the agent only when the builder's
message asks for them. Agents record no sample data, so the message picker offers
Raw body and the standard headers only; other values need a typed path such as
get('trigger.body.ticket'). Copies get a fresh URL and stay disabled until
enabled, and an export without sensitive data leaves the URL's identifier out.
Anyone with the live URL can send input to the agent; its tools still use the
configured run identity and approval policy. The guard against an agent triggering
itself reads who caused the event, and a webhook request has no one, so it never
applies here: the rate limits bound an agent wired to its own webhook. The request
throttle and the body size cap are the shared BASEROW_AUTOMATION_HTTP_TRIGGER_*
settings, so raising them for Automation raises them for agents too.
Row triggers add such hooks to the trigger service type. can_subject_read and
get_form_choices limit a trigger to the tables the agent's run identity may list.
split_event_payload cuts a large event into the batches that start one
conversation each, and get_event_context gives each batch its count and table.
events_can_be_skipped is off for rows only, so a new row trigger waits for the
previous run while the other types still skip. Their AgentTriggerTypes word the
default message and what opens a trigger without one: when it fired, then the
count, the table and the rows.
Revisit triggers
- A third consumer of trigger services appears, such as a button field starting an agent: reconsider a consumer registry.
- Row triggers ship and readers need the raw payload: add the payload column.
- Agent identities become users: trigger runs keep
created_by=None, since several agents can share an identity and a per-identity cap would throttle them together, and keep the trigger's timezone.