Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Merge remote-tracking branch 'origin/main' into pr-1286

Petr Baucha4eede98a88e
diff --cc CHANGELOG.md
index 5af8416ab,07854ff2a..2c0e0bbc9
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -236,11 -760,180 +760,183 @@@ version of their own to them without al
group whose subgroup would move up next to a namesake is refused too, and
the dashboard now shows why. Names can no longer contain `/` or be blank.
Existing duplicates are left as they are and can be reached by id.
+ - **Delivering an event to an agent behind a controller no longer reads the
+ agent's head first.** The notification of a new agent event already carries
+ its number, and the controller's stream now keeps it as the agent's head, so
+ a delivery costs the agent's own read alone, where it read the heads of all
+ the controller's agents first. The heads are still read after each idle
+ interval, when an agent is attached, and after the listener reconnects.
+ - **Delivering an event to an agent costs three statements, where it cost
+ seven.** The rooms dropped after the agent's cursor are read with its
+ events, and the unread count reads the agent's baseline, the room's window
+ and the agent's user id in the statement that counts.
+ - **Writing a message no longer costs four statements for each agent it is
+ for.** The agents' own events are stored together, in two statements and
+ one savepoint, where each agent's event took a savepoint, a numbering, an
+ insert and a release of its own.
+ - **A controller's stream waits on three events, where it waited on one per
+ agent and two more.** Every attached agent's doorbell now rings the stream's
+ one bell.
+ - **Reading an agent's own events no longer builds its query each time.**
+ Each shape of the read is built once and run with bind parameters.
+ - **A message addressed to a connected agent no longer reads the agent's
+ membership after it commits.** That read stops an agent removed from the
+ room in the meantime from saying anything there, and a connected agent has
+ nothing to say about a message addressed to it, so the read is now made only
+ before a refusal or an offline notice is posted, or a machine woken.
+ - **Message telemetry reads a workspace's rooms, clients and agents at once.**
+ The first lookup that misses reads all of them, where each room, sender and
+ agent was read on its own, so in a large workspace most messages no longer
+ cost a lookup.
+ - **Registering, renaming or deleting an agent no longer makes every process
+ read every client and agent.** The change now names the clients it touched,
+ and each process reads only those, where it read every client of the
+ workspace and, with a messaging app connected, every agent as well. The
+ 30-second re-check reads every client only when a fingerprint of the
+ workspace's clients and agents has changed since its last full read, where
+ it read them all every time.
+ - **The 30-second re-check of which controller runs each agent reads one
+ query, and nothing when no placement changed.** Every process read every
+ placed agent's definition, document included, then each controller with a
+ query of its own. It now reads the columns a binding is made of in one
+ query per workspace, and only when a fingerprint of the placements has
+ changed since its last full read.
+ - **The 30-second re-check of who holds each controller's socket no longer
+ reads every controller each time.** It compares a fingerprint of their
+ connections and of the live processes first, and when it reads, reads only
+ the connection columns, where it read every row with its status and
+ platform, and the rooms of every agent on a controller another process held.
+ - **Writing to a room for the first time through a process no longer reads the
+ room.** A process's clients now share the room ids they look up, where each
+ kept its own, and the first one a process misses reads every open room of
+ the workspace at once, so with many agents behind a load balancer most sends
+ no longer start with a read of the room.
+ - **Checking a message against Switch Trust no longer reads its settings each
+ time.** Each process keeps the settings it read until they change: saving or
+ clearing them in the gateway tells every process, so a change still takes
+ effect on the next message. Settings are read again after 30 seconds at most,
+ for a change whose signal was lost.
+ - **Reading an agent's budget standings no longer builds their query each
+ time.** The standings are read twice for every message an agent posts, and
+ building the query cost more than running it; it is now built once.
+ - **Reading a room's context costs one transaction.** The room's newest
+ message number, the membership check and the history read share one
+ session, where each opened its own.
+ - **A controller's requests no longer read its row and its agent's row each
+ time.** They were kept for 5 seconds, and a controller's requests, spread
+ over several processes, rarely came back to one within that. They are now
+ kept until a signal says they changed, which triggers on `agents` and
+ `agent_controllers` send, and a miss reads all of the controller's agents
+ at once. `CONTROLLER_AUTH_CACHE_MAX_AGENTS` (20,000) bounds the agent rows
+ kept.
+ - **Reading an agent's rooms uses an index.** `room_agents` is indexed on
+ `agent_id`; reads by agent scanned the whole table, 2.9 ms each at 10,000
+ agents.
+ - **Recording a message's usage builds its statement once.** The insert was
+ built for every message an agent sent; it is built once and run with bind
+ parameters.
+ - **A controller's access token is verified once.** Each process keeps the
+ tokens that verified until they expire, where every request verified its
+ token again; revocation is still checked on every request.
#### Fixed
+- **`!list-documents` and `!list-references` answer again.** Since they began
+ listing what a room's packages bring, both failed on the admin client that
+ runs them, and the channel got no answer at all.
+ - **The dashboard's addressing policy editor judges rules as the server
+ does.** A rule letting in only the agent's owner, or its owner's agents,
+ was taken for one that lets in nobody, and Save was held; the editor now
+ shows both choices, and says why a rule can never let anyone in in the
+ server's own words. A restricted policy with no rules lets anyone address
+ the agent, as documented, though the editor said it let in nobody:
+ choosing Restricted now starts with an owner-only rule, the last rule
+ cannot be removed, and a policy saved with no rules shows as Open.
+ - **A dashboard page someone may not open says so instead of loading.**
+ Typing the address of a page they may not open, or one the server does
+ not run, loaded it into a column of refusals; it now says why. A member
+ could open the operator's Users page; it is refused now.
+ - **The dashboard offers each action only where the server would allow it.**
+ Every action follows the server's own answer for that thing, rather than
+ the dashboard's guess from someone's role or ownership. An organization
+ admin was offered Delete workspace in a workspace they are not an admin
+ member of, and was refused. Anyone may edit a publicly writable
+ reference, document or package, but only its owner and admins were
+ offered the fields. An agent that cannot be handed over now says why
+ beside a disabled Transfer.
+ - **A bridged room's description can be edited.** It was locked, though
+ nothing sets it from the channel; whoever may write to the room can now
+ edit it, as on any other room.
+ - **The dashboard reads the server's feature flags instead of guessing.**
+ Agent management, connectors and organization connector apps were taken
+ to be off when a page answered "not found"; they are now read from the
+ server's flags, and if those cannot be read the dashboard says so rather
+ than hiding pages.
+ - **Two organization admins demoting or removing each other at once** could
+ leave the refused one without their keys and connections in the workspaces
+ they reached as an organization admin: those were taken away before the
+ last-admin check that refused the change. The check is now made, under a
+ lock held until the change is saved, before anything is taken away.
+ - **Deleting an API key an agent still signs in with** failed with a 500. It
+ is refused with a 409 that says to delete the agent; once the agent is gone,
+ its leftover key can be deleted.
+ - **Attaching a document or package that is already attached**, to a room or
+ a package, failed with a 500. It now changes nothing, as for a reference,
+ and attaching anything a room already has is no longer reported as a new
+ attachment.
+ - **A package in a room's list said the caller may open it** only on that
+ list; every route now works it out from the package's read rule.
+ - **Stable Switch Console can link chat accounts again.** Since links have to
+ be confirmed from the account with a one-time code, a claim from a Console
+ that cannot show the code was refused with "Update Switch Console", and no
+ stable release could show it, so nobody on stable could link a new account.
+ Switch now issues the code anyway and returns it as the 409's text, which
+ stable Switch Console shows in the link dialog: what to post from the
+ account and that the code expires in 30 minutes. An account already
+ confirmed links normally. An admin linking someone else from an older client
+ is still refused while the link needs confirming, since the code would be
+ shown to the admin.
+ - **A file that names nobody now follows the conversation like text does.**
+ A post with one or more files and no mention never reached the room's
+ assigned agent, the agent whose thread it was posted in, or the agent the
+ sender was just talking to, even with follow-ups on; the same words as a
+ text message did. A post is now decided by the same rules, read from its
+ first file's caption and thread, and the agent gets the post with every
+ file on it, in that thread.
+ - **The dashboard offers only the room changes the server would allow.** On
+ a publicly writable room, the default, anyone could change the Access
+ setting and press Save, only for the server to refuse it. Someone who could
+ only read a room was still offered adding and removing its agents and
+ users, attaching and detaching its resources, linking it to other rooms and
+ deleting its room documents. A document, reference or package's page
+ offered attaching it to, and detaching it from, rooms the viewer could not
+ change. The rooms list offered archiving, and the groups page filing,
+ rooms the viewer could not change; a bulk archive skipped those without
+ saying so. Each of these was refused when tried. Access is now read-only for
+ everyone but the room's owner and admins, and its description says so.
+ Everything else is offered only to those who may write to the room, and
+ only rooms they may write to are offered for attaching. A reader still sees
+ each agent's "Notify on join" setting, but cannot change it. A publicly
+ writable room's other settings stay editable by everyone, as before.
+ - **Those taking part in a private room can read its resources.** The room
+ itself could be read by its participants, but its references, documents,
+ packages and linked rooms were refused to anyone but its owner and admins.
+ - **Deleting a room document from the room page asks first.** It cannot be
+ undone, and its own page already asked.
+ - **Reconnecting Google Workspace no longer ends the new connection.** On a
+ reconnect, Switch revoked the sign-in it replaced. Google ends every
+ sign-in of the account through the client when one is revoked, so the new
+ connection also stopped working, and the next token refresh asked the
+ person to reconnect again. A reconnect to the same Google account through
+ the same client no longer revokes the old sign-in. A reconnect to another
+ account still revokes it, and so does a disconnect. A sign-in that Switch
+ does not keep, because the workspace switched Google Workspace off during
+ it, no longer ends the existing connection either.
+ - **A client in more than 32,767 rooms starts reading them.** The reads a
+ client makes as it starts matched its rooms with one parameter each, and
+ Postgres takes at most 32,767 per statement. Switch's own client is in
+ every room of its workspace, archived ones included, so past that many it
+ failed to start, retried, and failed again while the process ran, taking
+ up rooms one at a time in between. The rooms now go as one array.
- **On Slack, the 👀 and the activity card no longer arrive after the agent's
reply.** Every running turn's card was redrawn every 5 seconds to tick its
clock. Slack closes a streamed card after 10 minutes, so on a longer turn