Phase 11, part 4: agents' limits, recent calls and a pause switch

Each agent has calls a minute and things it may ask to send out a day,
checked on every tool call and every request to send; every call is
recorded (tool, outcome, time) and the agent's page lists the last 50 and
what it's waiting on. Pause refuses all its calls at once. Also fixes each
agent's MCP server being shared with others that had the same scopes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 11:09:18 -07:00
co-authored by Claude Opus 5.5
parent 311d2e815b
commit 6bf0517163
16 changed files with 527 additions and 13 deletions
+25 -3
View File
@@ -53,9 +53,9 @@ branch `phase10` (2026-11-25), not yet merged: schema 36, a new
the visible changes are posting accounts, Connections, Activity, and a
CSRF token in every form.
**Next: Phase 11, agents.** Parts 1–3 (agent users and keys, module tools
over MCP, approvals) are built on branch `phase11`; part 4 (limits and
visibility) is next. Phase 12 still needs who adds Supermarket's client to
**Next: Phase 11, agents.** Parts 1–4 (agent users and keys, module tools
over MCP, approvals, limits and visibility) are built on branch `phase11`;
part 5 (a JSON API) can wait until someone needs it. Phase 12 still needs who adds Supermarket's client to
Authelia.
**Coming back to it (for the agent working on it):**
@@ -2620,6 +2620,28 @@ single `mcp-token`. A commit after each part.
tools that change things, and once allowed once a day, posts on its own
once, then asks again. Revoking its key stops it at once.
**Part 4 built 2026-11-26** on `phase11`.
- Schema 39: `agent_limits` (calls a minute, default 60; things it asks to
send out a day, default 50; paused, by whom) and `agent_calls` (each tool
call: when, the tool, ok, error or refused, the error or the start of the
answer, how long), kept 30 days (`job:accounts`, now on every edition).
The calls aren't exported.
- Each tool call goes through a middleware on the agent's MCP server: over
its calls a minute, it's refused (*too many calls*) and recorded as
refused, which doesn't count toward the next minute's; then it's
recorded with how it went. Asking to send something out counts against
its cap per day (in the last 24 hours, approved or not); over it, the
agent is told to wait or ask for a higher limit.
- *Pause* (on the agent's page, and shown on the list) refuses every call
at once, with 403 and why, whatever key it uses, also mid-session; *Resume*
undoes it. Pausing, resuming and the limits are in the audit log.
- The agent's page shows its limits, what it asked to send out in the last
24 hours, what it's waiting on (linked to Approvals), and its last 50
calls.
- Fixed from part 1: each agent's MCP server was cached by its scopes, so
two agents with the same scopes shared one, and the tools recorded the
first as the writer of what both wrote. Now each agent has its own.
1. **Agent users and their keys.**
- An admin creates an agent on Settings → Users → *New agent*. It has a
name, a description, and the modules it's given, each *read* or