diff --git a/markdown/apps/bebbi-bot/image.md b/markdown/apps/bebbi-bot/image.md index a065acf..413a03f 100644 --- a/markdown/apps/bebbi-bot/image.md +++ b/markdown/apps/bebbi-bot/image.md @@ -25,6 +25,7 @@ Python runs `sitecustomize.py` in every process of the image, before Open WebUI | MCP citations | Citation sources from tool results | `DCC_ENABLE_MCP_CITATIONS`, on | | MCP instructions | Instructions MCP servers send | `DCC_ENABLE_MCP_INSTRUCTIONS`, on | | MCP HTTP retry | MCP HTTP client | `DCC_ENABLE_MCP_HTTP_RETRY`, on | +| PII tool approval | Every tool call, before it is sent | `DCC_ENABLE_PII_TOOL_APPROVAL`, off | | RAG citations | Citation sources for files and knowledge | `DCC_ENABLE_RAG_CITATIONS`, on | | Sub-agent sources | Sub-agent results | `DCC_ENABLE_RAG_CITATIONS`, on | | Knowledge tool candidates | Retrieval for the knowledge tool | `DCC_ENABLE_KNOWLEDGE_TOOL_CANDIDATES`, on | @@ -101,6 +102,26 @@ Three hooks on Open WebUI's MCP handling. See [Tools](/apps/bebbi-bot/tools.md#c The labels for the DCC servers are a workaround until each server sends its own `citation_label`. The hook already prefers the server's label over its own rules, so each rule goes once its server follows the convention. +## Personal data in tool calls + +The hook wraps `execute_tool_call` in `open_webui.utils.middleware`. Every tool call of every type passes through that function: MCP, OpenAPI tool server, workspace tool and built-in tool. + +1. For calls in scope (by default MCP and OpenAPI tool servers), it sends the string values of the arguments to GLiNER (`POST /extract_entities`). +2. On a finding, it opens Open WebUI's confirmation dialog in the user's browser and waits for the answer. +3. On Confirm it runs the call. Otherwise it returns a refusal to the model in place of the tool result. + +[Tools](/apps/bebbi-bot/tools.md#personal-data-in-tool-calls) shows what users see. + +Settings: + +* `DCC_PII_GLINER_URL` and `DCC_PII_GLINER_API_KEY`: the GLiNER endpoint and its key. +* `DCC_PII_TOOL_TYPES`, `DCC_PII_TOOLS`, `DCC_PII_SKIP_TOOLS`: which calls are checked. +* `DCC_PII_LABELS`, `DCC_PII_THRESHOLD`: what GLiNER looks for, and the minimum confidence (0.5). +* `DCC_PII_CONFIRM_TIMEOUT`: how long to wait for the user (600 s). +* `DCC_PII_FAIL_CLOSED`: whether to ask when GLiNER fails (on). + +`tests/e2e/pii_tool_approval/gliner_cases.py` runs 18 short tool-call texts against a live GLiNER and fails on any miss or false alarm. + ## Knowledge bases: citations and retrieval Three hooks change how Open WebUI cites and searches knowledge bases and files. [Knowledge bases and citations](/apps/bebbi-bot/knowledge.md) explains the effect and the measurements behind them. diff --git a/markdown/apps/bebbi-bot/tools.md b/markdown/apps/bebbi-bot/tools.md index 66224cc..c71d970 100644 --- a/markdown/apps/bebbi-bot/tools.md +++ b/markdown/apps/bebbi-bot/tools.md @@ -129,6 +129,42 @@ A question such as "all motions on climate since 2023" returns hundreds of Gross The global inlet filter `subagent_hint` puts a short "Arbeitsweise" note in front of the user's message when the chat has MCP servers switched on: if the request asks for an overview of many entries or several years, distribute the research with sub-agents. The model decides whether it applies. With the note it delegated in 10 of 10 runs, and simple questions kept their usual tool calls. Only the request to the model changes. The chat stores the message as the user wrote it. +### Personal data in tool calls + +A tool call sends text out of Bebbi Bot: the model's search query goes to the MCP server or tool server. If the user's question contains a name, an e-mail address or an AHV number, the query often contains it too. Before such a call leaves Open WebUI, Bebbi Bot asks the user. + +The [custom image](/apps/bebbi-bot/image.md#personal-data-in-tool-calls) holds every call to an MCP or OpenAPI tool server before it is sent. It passes the text of the arguments to the GLiNER API on KIS (model `fastino/gliner2-multi-v1`), which looks for seven kinds of personal data: + +* person +* e-mail address +* phone number +* address +* AHV number +* IBAN +* date of birth + +```mermaid +flowchart LR + A[Tool call] --> B[GLiNER API] + B -->|no PII found| C[Allow automatically] + B -->|PII found or check failed| D[Hold and ask the user] + D -->|Confirm| E[Run the tool] + D -->|Cancel or no answer| F[Refuse, tell the model] +``` + +* **No personal data found.** The call runs at once and the user sees nothing extra. A check takes about 30 ms. +* **Personal data found.** A dialog "Personendaten im Tool-Aufruf" lists what was found, for example `Person: «Hans Muster»`, and asks the user to confirm only if the call contains no personal data. Confirm runs the call. Cancel refuses it, and the model gets an error telling it not to send the data again. A status line above the answer records the decision ("erlaubt" or "abgelehnt"). +* **GLiNER unreachable.** The user is asked as well, with a dialog saying the check failed. +* **No answer.** After 10 minutes, or without an open browser tab, the call is refused. + +**Why not a filter or Open WebUI's approval.** No Open WebUI filter runs between the model choosing a tool call and the call being sent. Open WebUI 0.13 has its own approval card, but in our approval mode a forced approval ends the chat with an error, and the card has no room for our own text. The hook uses Open WebUI's generic confirmation dialog instead. + +**The descriptions GLiNER reads.** The labels and names come from anony-mate. For `person` the hook uses anony-mate's long description, which also covers "Herr Müller" and initials. The other six use short descriptions. With anony-mate's long descriptions for all seven, GLiNER found 8 of 13 items in short tool-call texts and missed every e-mail address, AHV number and IBAN. With the current set it found 13 of 13, with no false alarms on six texts without personal data. + +GLiNER also flags public persons. "Interpellation von Grossrätin Sarah Wyss" asks the user, too. A server whose queries are mostly about public persons can be left out of the check. + +The check is off by default (`DCC_ENABLE_PII_TOOL_APPROVAL`). Details, settings and the test cases are in `docs/pii-tool-approval.md` of the `kdkp-open-web-ui` repository. + For implementation details and endpoints of the DCC servers, see the [MCP section](/mcp/index.md). ## Built-in tools