Commit Graph
2 Commits
Author SHA1 Message Date
Davide Silvestri dcf2ce57b4 feat(agent): let people outside Baserow talk to an agent through a public chat (#6864)
* 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.
2026-11-26 11:26:08 +00:00
Davide Silvestri 18ae3c06cb feat(agent): ask before running tools (#6602)
* feat(agent): retain reply execution details

* feat(agent): hold Ask first tool calls for the owner's approval

* feat(agent): approve or reject held tool calls in the chat

* fix(agent): tell the model that Ask first calls wait for the user

* refactor(agent): run the approval action through the action registry

* fix(agent): preserve approval state across reply transitions

Mark held calls waiting immediately and keep retry slots across durable
pauses. Keep stale history and run snapshots from undoing newer decisions.
Contain rejection dialog focus and localize its waiting announcement.

Add focused transition regressions and update the tool presentation contract.
Align approval fixtures with the parent conversation cursor contract.
Validation: 469 backend passed (one known xfail), 362 frontend passed;
query-growth, migration drift, lint and browser component checks passed.

* feat(agent): show partial results of approved calls in the approval card

* test(agent): cover web searches next to held tool calls

* fix(agent): drop retry slots, every tool call has its own card

A paused reply no longer saves which failed steps the next response may
continue. Transcripts drop text PostgreSQL can't store, like steps do.

* feat(agent): show a held call's named request while it waits

A held call is named as the Agent identity when it is held and sends
the request to its step like a running call, so the owner decides on
names. What can't be named keeps its ID; the call still waits.

* feat(agent): title held changes with their table

* fix(agent): end held calls by the owner's decision

A held call that a reply ends without resuming is rejected when the owner
rejected it, stopped when they approved it, since the resume may have run it,
and failed when undecided. Copies end held calls at export, where the
decisions are known. Rejected calls stay out of the interruption note.

* fix(agent): resume a paused reply as the run that paused

The transcript keeps whether the paused run offered web search and the
identity it acted as. A resume offers search only if the paused run did, so a
provider that refused it doesn't fail the reply after the approved change ran.
It runs approved calls only as the identity they were held under; when the
Agent no longer acts as it, they fail with a permission error. Every resume
tells the model that users approve these calls.

* chore(agent): clean up after the tool approval review

Drop the unreachable ChatRunAlreadyActive from the decide path, its API schema
and tests, and test the refused resume against the real run limit. Remove the
import branch for exports without ask_first_tools and the toolInputText
indirection, and add the decision audit strings to the agent catalog.

* fix(agent): end held calls that never ran as not run

A held call that a reply ends without running now fails with `not_run`:
undecided, or approved when the resume never started (not ready, cancelled
before it started). Only a resume that started stops its approved calls,
since it may have run them; `mark_reply_interrupted` now passes an empty
result, so `None` again means the run never started. The interruption note
leaves `not_run` calls out, like rejected ones, and the card says "It didn't
run."

* fix(agent): keep the IDs of what a held request can't name

A table, database or view the Agent identity can't see no longer empties the
whole request preview: it keeps its ID, like fields and rows already did.
Values of rows for a table that can't be named are all masked, since its
password fields are unknown. An approval for an unknown table now shows
`table_id` and the requested rows instead of nothing.

* fix(agent): tell the model why an approved call lost its identity

When the Agent no longer acts as the identity a call was held under, the
approved call is denied with a note saying so, and that tools are
unavailable for the rest of the reply, instead of "This tool is no longer
allowed."

* fix(agent): hold no change after a call with invalid arguments

pydantic-ai validates every call of a response before running any, and
reports invalid ones with `args_valid=False`. An ask first call that fails
validation is retried, never held, so it no longer holds the changes after
it: a change set to run without asking now runs.

* fix(agent): leave reply transcripts out of copies

Duplicates and snapshots no longer copy each reply's model messages and
usage. They hold every tool result, nothing reads them, and the export
loaded all of them at once. A copied reply can't resume anyway.

* feat(agent): title unfinished calls by their request

A call that isn't running or done is titled by what it asked for, so an
approved call that fails keeps "Update 1 row in Accounts". An approved card
item shows any outcome other than success next to the decision, now failed
too. Held reads keep their request and are titled with their table.
2026-11-10 18:06:58 +00:00