Commit Graph
6 Commits
Author SHA1 Message Date
Davide Silvestri eeca9ec5ee feat(agent): allow the tools an allowed tool requires (#6865)
Each Agent tool declares the tools that give the model an input it can't
get otherwise, like get_table_schema for create_rows. Saving allowed tools
without them is refused, Kuma refuses such a grant, and the tool permissions
modal allows them along with the tool and locks them while it is allowed.
Each section of the modal gets a Select all and Deselect all button.
2026-11-25 16:44:05 +01:00
Davide Silvestri d822dd067a feat(agent): row comment tools, with a search shared by MCP and Kuma (#6760)
* feat(row comments): search comments across a database

Add RowCommentHandler.search_comments and the shared search_row_comments
tool. They return the comments on the rows of a database, newest first,
each with its table and row, narrowed by table, mentioned users, authors
and creation time. A user is given as an ID, part of a name, or 0 for the
user the tools act as.

Every search is index-driven. A mention search is one query that starts
from the mentions of the given users. Any other search reads the newest
comments of each table from two new indexes, (table, -created_on) and
(table, user, -created_on), added with RetryableAddIndexConcurrently.
Comments on trashed rows are dropped after a page is read, so the result
carries has_more instead of a total.

list_row_comments now also returns the user_id and the mentions of each
comment.

* feat(mcp): expose search_row_comments

Register the comment search as a read-only MCP tool in the database_read
group, next to list_row_comments, and document it.

* feat(agent): let a tool type be deactivated for a workspace

An Agent tool type can now tell that a workspace can't use it, through
is_deactivated and raise_if_deactivated, like service and node types do.
A deactivated tool stays in the Agent's available tools, marked
deactivated, so the client can show it as locked. It is left out of the
allowed tools, so a reply never offers it, and the configuration refuses
to allow it.

* feat(agent): show a deactivated tool as locked in the tool permissions

A tool the workspace can't use keeps its row in the Agent's tool
permissions. A lock button replaces its Allow checkbox and opens the
modal the tool's presentation type returns from getDeactivatedClickModal.
The presets and the counts only consider the tools the workspace can use.

* feat(agent): add the row comment tools

An Agent can now list the comments of a row, search the comments of a
database and post comments. Premium registers the three tools and their
presentation. A workspace without premium sees them locked, and the lock
opens the paid features modal on row comments.

The core tests that pin the Agent tool names and their presentation now
cover the core tools only; premium pins its own.

* feat(agent): tell the model who a private conversation is with

The tools of an Agent act as its identity, so the model had no way to
turn "me" into a user. The instructions of a private conversation now
name the person and their user ID. A conversation started by a trigger
names nobody. The name is collapsed to one short line because it is
user-controlled text.

* feat(assistant): let Kuma search row comments

Wrap the shared search_row_comments tool for Kuma, active in every mode
like the other database read tools, and add an eval case that asks for
the comments mentioning the user.

* fix(agent): require workspace RBAC for row comment tools in Agents and Kuma

* fix(row comments): accept an empty table list and odd digits in a search

An empty table_ids returned no comments while the empty lists of users
meant no filter. It now searches every table like an omitted one. A
reference such as "²" passed isdigit() and failed in int(); isdecimal()
reads it as a name.

* refactor(row comments): check the searched tables in one permission call

check_multiple_permissions raises the first denial itself, so the search
no longer evaluates a denied table a second time to get its error.

* fix(agent): refuse a deactivated tool by default

A tool type that only said it is deactivated was listed as locked but
could still be allowed and called. The base check now raises when the
type is deactivated, as the service and automation node types do. A type
can still raise its own error, like the one for a missing licence.

* fix(agent): tell an Agent only about the locked tools it was allowed

Every reply in a workspace without the licence carried a note about the
three row comment tools, also for an Agent that never had them or has no
workspace access. The note now names the tools in the Agent's allow list
that the workspace can't use, and is left out when there are none. The
tool type gives the reason and the handler writes the sentence. Kuma has
no allow list, so its tool group keeps the sentence naming all three.

* fix(agent): honor saved tool grants and row comment search permissions

* fix(assistant): end a scenario's enterprise licence with its eval case

A scenario's instance-wide licence stayed for every later case of the run, and the cached licence list hid it from its own case. The case's fixtures now add it, refresh the cache and remove it when the case ends. A licence that was already there is kept.

* fix(row comments): cap the page of the comment tools

A search without a mention filter reads the comments up to its page in every table, and a huge page overflowed the offset. Both comment tools stop at page 100, also in Kuma.

* fix(row comments): read a user reference the same way in the search and its step

The step of a search showed "0" when the model sent the acting user as text. The search and the step now share one parser. The description also says a name matches everyone whose name contains it.

* fix(agent): make a tool's lock a button only when it explains itself

A locked tool without a modal got a button that did nothing, and every locked tool kept a disabled Ask first checkbox that screen readers announced.
2026-11-19 13:13:32 +01:00
Davide Silvestri 9f9e068a27 feat(agent): show waiting approvals and let editors stop the asking (#6610)
* feat(agent): count pending approvals per application and conversation

* feat(agent): show waiting approvals in the sidebar, header and conversation list

* feat(agent): always allow a held tool from the approval

* feat(agent): add Always allow and the ask before changes switch

* fix(agent): read pending counts from the primary and lock the conversation first

* test(agent): run approval test actions through the action registry

* test(agent): read the decision result in the web search approval test

* test(agent): let the waiting conversations request start before answering it

* fix(agent): keep older waiting conversations through a reconnect

* perf(agent): count pending approvals for many users and conversations at once

The core hook takes many users and returns counts per user and application, so
creating or restoring an Agent and the count task count once for all members
instead of once per member; the task sends every count in one broadcast.
Pending approvals are defined once, and a page of conversations gets its counts
in one query passed to the serializer, like its runs, instead of an annotation
with a per-object fallback.

* refactor(agent): return one decision result and name the count signal after its event

The service and the action both return the decision result, which carries the
approved and rejected tools, so they are computed once for the audit params and
Always allow. Always allow bumps the Agent's updated_on like a configuration
update. The signal is renamed application_pending_count_updated, like its
websocket event.

* fix(agent): keep the deciding tab's waiting counts current

A decision lowers the Agent's count before its request and restores it when the
request fails, unless the call was decided elsewhere. Its conversation count
goes through the tracked update, so a list read that started earlier restarts
instead of bringing the old count back. The pill adds only the waiting
conversations it hadn't loaded, and leaves a conversation picked while it loads
selected.

* chore(agent): describe the ask switch and drop the unused counter class

The ask switch is described by its text and the row separator is hidden from
screen readers. The sidebar no longer adds tree__action--has-counter, whose
padding --has-options already sets.

* test: give fixture fields unique default names

Two fields of one table could get the same random name, so a formula
referencing the other field referenced itself and failed with
SelfReferenceFieldDependencyError.

* refactor(agent): show the sidebar count with the warning counter

The admin Templates count added badge-counter--warning, so the Agent's count
uses it too instead of its own yellow color prop on BadgeCounter.

* fix(agent): reconcile approval counts and cycle loaded conversations

* fix(agent): name the tools Always allow stops asking for

* fix(agent): load older pages until the pill reaches a waiting conversation
2026-11-11 17:25:51 +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
Davide SilvestriandClaude Opus 5.5 eec8247c0a feat(agent): show tool activity in conversations (#6551)
* feat(agent): show tool activity in conversations

* refactor(agent): centralize tool step statuses

* fix(agent): keep tool-step diagnostics free of private data

* fix(agent): retain Sentry details for tool errors

* feat(agent): show tool inputs and failed read attempts

* fix(agent): show individual tool outcomes in activity groups

* feat(agent): explain tool failures in translated tooltips

* feat(agent): name known targets in failed tool calls

* fix(agent): use shared tool errors after rebase

* fix(agent): show interrupted changes, announce tool steps and clear pre-tool text

* refactor(agent): move input previews and failed-call targets out of tool steps

* refactor(agent): log tool-step failures without the Sentry helper

* fix(agent): classify tool errors once and drop partial-failure steps

Calls to tools a reply never offered no longer get a step.

* refactor(agent): key tool presenters by tool name and drop unused step data

Drops presentation_type, the unused card icon, copy-time step cleanup and Kuma-visible chat CSS changes, and defers steps when loading reply history.

* test(agent): cover Stop during a change and merge overlapping step tests

* docs(agent): trim tool presentation guide to the step contract

* fix(agent): keep step facts JSON-safe and polish stopped cards

Restores the JSON check on step facts, keeps a stopped change's title readable at narrow widths, raises its warning contrast, and stops reopening a running reply from re-announcing its old steps.

* fix(agent): cap the Agent chat column at 900px

* fix(agent): name the executing tool call and keep step cards stable while text streams

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(agent): name reused tables and views instead of showing zero created

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(agent): tell the model which changes an interrupted reply started

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(agent): continue a retried tool call on the step of its invalid attempt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(agent): report views skipped by name collisions

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 10:53:05 +00:00
Davide Silvestri 66053dd058 feat(agent): Agents use the database tools as their identity (#6543)
* feat(agent): Agents use the database tools as their identity

Each Agent has an allow list of the shared database tools, read tools on
for new Agents. A reply offers the enabled tools while the Run as identity
is usable and runs them as that identity. Table and view creation now work
for actors that aren't users.

* feat(agent): choose an Agent's tools in its settings

Workspace access gets a Workspace tools switch with Everything, Read only
and Custom presets, and a tool permissions modal that allows each tool.
The configuration lists the tools an Agent can be allowed to call.

* fix(agent): retry invalid tool calls and name the allowed tools

- Rename AgentTool to AgentAllowedTool and the API field tools to
  allowed_tools; the migration becomes agent.0007_agent_allowed_tools.
- Pin every tool name and whether it changes data, since Agents allow
  tools by name.
- Let the model correct up to 3 invalid calls in a row per tool instead
  of failing the reply after the second.
- Move the actor language helper to core user utils, so TableHandler is
  traced again.

* fix(agent): secure tool execution and improve permission controls

* fix(agent): disable workspace tools without a run-as identity

* polish and cleanup

* fix(test): isolate admin view search fixture IDs

* fix(agent): address tool execution review feedback

* fix(agent): make workspace tool access explicit
2026-11-06 09:35:18 +01:00