Design discussion: OPA policy integration for agent model and tool calls
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 8/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Attiva
- Stack tecnologico
- go, kubernetes
- Ambito
- ai-infra-agents, backend, security
Direzione di ricerca
This is a design proposal, not a task: it asks for agreement on the input and decision format between Tapas and the rules, and lists five open questions for a meeting. Read the boundary section and the questions, and note that Tapas's own authorization lives in internal/authz, which the rules may not override. There is no code change to start from yet, so wait for the discussion to settle before picking up any part of it.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
This is a starting point for discussing how Open Policy Agent fits into Tapas for the Intelligence Hub. It covers the shape of the system and where the boundaries sit, not how to build it. Everything here is a proposal.
What we want
Every action an agent takes gets checked against company rules before it happens. Rules are written in Rego, live in git, and can be changed without redeploying Tapas. A rule can allow an action, block it with a plain-English reason, or hold it until a person approves the exact action. Every decision is recorded.
Two kinds of agent traffic need checking:
- Model calls: what an agent sends to a model. Example rule: no US Social Security numbers go to an outside AI vendor.
- Tool calls: what an agent asks a connector (Slack, Gmail, Greenhouse, Frames) to do. Example rules: only the recruiting group can read from Greenhouse; sending email needs the owner's approval.
The shape
flowchart LR
client["Claude / Codex / Collab<br/>(person's laptop)"]
subgraph cluster["Nebari cluster"]
subgraph tapas["Tapas gateway"]
mg["Model gateway"]
tg["Tool gateway"]
mcp["MCP endpoint<br/>(for outside clients)"]
opa[("OPA<br/>embedded")]
log[("Decision log")]
plans["Approvals<br/>(plans)"]
end
agent["Agent pod<br/>(holds no credentials)"]
rules["Rules ConfigMap"]
lsp["llm-serving-pack"]
frames["Frames, our own connectors"]
end
gitops[("GitOps repo<br/>rules/")]
vendors["Vendor MCP servers<br/>Slack, Notion, HubSpot, Greenhouse"]
models["AI vendors and<br/>self-hosted models"]
client -- MCP --> mcp
mcp --> agent
agent -- model calls --> mg
agent -- tool calls --> tg
mg --> lsp --> models
tg --> vendors
tg --> frames
mg & tg & mcp -. ask .-> opa
opa -.-> log
tg -- needs approval --> plans
gitops -- ArgoCD --> rules -- mounted, reloaded --> opa
- Tapas is the only way out for an agent. Model calls and tool calls both go through the gateway. Agents never hold a model key, a vendor token or a Keycloak token, so they can't go around it.
- OPA runs inside Tapas as a library, not as a separate service. Nothing extra to deploy, no "OPA is down" case. Another hub component that wants the same rules can run its own OPA on the same rules.
- Rules come from the GitOps repo. ArgoCD syncs them into a ConfigMap mounted into the gateway, and Tapas reloads them when the mount changes. A merged PR is live in about a minute.
Where checks happen
| Checkpoint | What is checked | Possible outcomes |
|---|---|---|
| Model request | the prompt an agent sends to a model | allow, deny |
| Model response | the answer coming back | see open questions |
| Tool call | which connector and tool, with what arguments | allow, deny, needs approval |
| Tool result | what a connector returns to the agent | allow, deny |
| MCP response | what Tapas returns to an outside client such as Claude desktop (that content goes to the client's vendor) | allow, deny |
| Memory write | what would be stored in a person's memory (mem0) | allow, deny |
Every checkpoint asks OPA the same kind of question, so one rule can apply across several checkpoints ("no SSNs leave for an outside vendor" covers model requests, MCP responses and memory writes).
The boundary between Tapas and the rules
This is the part we need to agree on first, since it lets the two sides be built in parallel.
flowchart LR
subgraph tapasSide["Tapas (Amit)"]
collect["Gather who, where, what"]
detect["Detectors<br/>(SSN, card numbers, secrets)"]
enforce["Enforce the decision<br/>block / forward / hold"]
end
subgraph rulesSide["Rules (Chuck)"]
lib["Shared Rego library"]
rego["Company rules<br/>with plain-English titles"]
end
collect --> input["Input document"]
detect --> input
input --> rego
lib --> rego
rego --> decision["Decision"]
decision --> enforce
What Tapas sends (the input). One document per check, the same shape at every checkpoint:
- who: the agent's owner and their groups; later, the person talking to the agent if that's someone else
- which agent: the agent and its template, and whether it's a scheduled run
- where: the checkpoint, and the destination (which model, or which connector and tool)
- what: the content (messages, tool arguments or results), normalized so a rule never cares whether the request was in OpenAI or Anthropic format
- findings: what the detectors spotted and where
What comes back (the decision). Allow, deny, or needs approval, with the title and message of each rule that fired, and the revision of the rules that decided.
Ground rules on each side:
- Detectors find things; rules decide. A detector never blocks anything on its own.
- Every rule carries a plain-English title and description in Rego's
# METADATA. The UI shows them as the rule list, and the same text is the message a person sees when a rule blocks them. CI fails a rule without them. - Rules write into two namespaces: one for the rules from git, and one kept empty for rules admins will later edit in a Tapas UI. Tapas collects decisions from both.
- If rules can't be loaded or evaluated, Tapas refuses the call. It fails closed.
- OPA only restricts. Who may use an app or template is still decided by Tapas's own authorization (
internal/authz), and a rule can't grant what that refuses.
How a rule goes live
sequenceDiagram
participant Dev as Rule author
participant Git as GitOps repo
participant CI as CI
participant Argo as ArgoCD
participant Tapas as Tapas gateway
Dev->>Git: PR adds or edits a rule
Git->>CI: opa test, METADATA check
CI-->>Git: pass
Dev->>Git: merge
Git->>Argo: sync
Argo->>Tapas: ConfigMap updated, mount changes
Tapas->>Tapas: reload rules (keep the old ones if the new ones fail)
Note over Tapas: decisions now carry the new revision
How a held tool call works
sequenceDiagram
participant Agent
participant Tapas as Tapas tool gateway
participant OPA
participant Owner as Agent's owner (browser)
participant Gmail as Connector
Agent->>Tapas: send this email
Tapas->>OPA: input (tool call)
OPA-->>Tapas: needs approval: "Email sends need a person's OK"
Tapas-->>Agent: pending, id X
Owner->>Tapas: approve X
Tapas->>Gmail: the exact stored call, once, as the owner
Agent->>Tapas: status of X?
Tapas-->>Agent: applied, with the result
The agent never makes the approved call itself, so nothing can change between approval and sending. This builds on the propose-and-approve flow Tapas already has for its own actions.
Who owns what
| Area | Owner |
|---|---|
| The input and decision format, the rule namespaces | Amit and Chuck, together, first |
| Calling OPA at each checkpoint and enforcing the decision; reloading rules; the decision log; the rule list and decision APIs; holding and applying approved tool calls | Amit (Tapas) |
| The Rego library, the default rules and their tests, CI in the GitOps repo, the rules ConfigMap | Chuck |
| Detectors (a self-contained package in Tapas) | Chuck |
| Screens for the rule list, the decision log and approvals | Johnny and Nat |
Not in the first version
- Rewriting content (redaction). A matching rule blocks.
- Filtering parts of a tool result.
- Approvers other than the agent's owner.
- Editing rules in the Tapas UI (the second namespace is kept for it).
Questions for the meeting
- Should a rule be able to block a model's answer, or only log it? Answers stream, so blocking means holding the whole answer or cutting the stream partway.
- Rules check the owner's groups, and Tapas only refreshes those when the person signs in. Do we refresh them from Keycloak when an agent acts on the person's behalf, so rules see current groups?
- How do we test the boundary? One idea: a shared set of example input documents that Tapas's tests produce and the Rego tests consume, so neither side drifts.
- Does the input above carry enough for the rules we expect in the first month? Anything that needs outside facts, such as time of day or spend so far?
- Does anything about OPA running inside Tapas worry you, compared with a separate OPA service?
- Lingua principale
- Go
- Stelle
- 5
- Fork
- 0
- Merge medio
- 21h 13m
- PR unite (30g)
- 53
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nebari-dev/tapas
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
nebari-dev/tapas#124 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nebari-dev/tapas#121 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
nebari-dev/tapas#32 ·
I maintainer di solito rispondono entro 1 giorno
-
Suggest saving a memory when a chat message holds something worth rememberingForse già presa @jbouder l’ha presa oggi. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
nebari-dev/tapas#137 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
nebari-dev/tapas#136 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di nebari-dev/tapas
Issue simili
-
area: pipeline priority: low type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
prime-radiant-inc/evener#8335 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
ui: OnTextKey on SearchField never sees keys (it does not reach the inner input)Forse già presa @szluyu99 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100