You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -55,14 +55,16 @@ A API implementa uma camada determinística de policy antes da execução de too
55
55
|`send_notification`| exige aprovação humana |
56
56
|`delete_record`| bloqueada no exemplo |
57
57
58
+
O fluxo `POST /v1/run-demo` também retorna um **audit event estruturado**. O `correlation_id` é derivado do `request_id`, permitindo ligar decisão, execução e diagnóstico operacional sem armazenar conversa privada.
59
+
58
60
Endpoints:
59
61
60
62
-`GET /health`
61
63
-`POST /v1/tool-check`
62
64
-`POST /v1/run-demo`
63
65
- documentação OpenAPI em `/docs`
64
66
65
-
Os testes verificam same-tenant access, cross-tenant denial, approval gate e bloqueio de ação destrutiva.
67
+
Os testes verificam same-tenant access, cross-tenant denial, approval gate, bloqueio destrutivo e correlação de auditoria para ações permitidas e negadas.
66
68
67
69
## Modelo de produção
68
70
@@ -75,7 +77,8 @@ USE CASE
75
77
→ RAG / MEMORY
76
78
→ EVALS
77
79
→ HUMAN APPROVAL
78
-
→ DEPLOY
80
+
→ EXECUTION
81
+
→ AUDIT + CORRELATION
79
82
→ TRACE
80
83
→ INCIDENT RESPONSE
81
84
→ IMPROVE
@@ -91,8 +94,10 @@ flowchart TB
91
94
O --> T[Tool Registry]
92
95
T --> A[Approval Gate]
93
96
A --> S[Business Systems]
97
+
S --> AU[Audit Event + Correlation ID]
94
98
O --> H[Human Handoff]
95
99
O --> X[Tracing / Evals / Metrics]
100
+
AU --> X
96
101
```
97
102
98
103
## Checklist essencial
@@ -115,6 +120,7 @@ flowchart TB
115
120
-[ ] task success, tool selection e argumentos avaliados;
116
121
-[ ] testes de segurança/autorização;
117
122
-[ ] tracing, custo, latência e taxa de erro observáveis;
123
+
-[ ] audit event correlacionado por execução crítica;
Copy file name to clipboardExpand all lines: examples/safe-agent-api/README.md
+28-16Lines changed: 28 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,32 @@
1
1
# Safe Agent API
2
2
3
-
Projeto executável do **AI Agent Production Checklist**. Ele demonstra uma camada determinística de autorização para tools de agentes sem depender de LLM ou API key.
3
+
Projeto executável do **AI Agent Production Checklist**. Demonstra uma camada determinística de autorização, aprovação e auditoria para tools de agentes sem depender de LLM ou API key.
cd AI-Agent-Production-Checklist/examples/safe-agent-api
23
+
docker compose up --build
24
+
```
25
+
26
+
Abra:
27
+
28
+
- API docs: `http://127.0.0.1:8000/docs`
29
+
- health: `http://127.0.0.1:8000/health`
14
30
15
31
## Clonar e abrir no VS Code
16
32
@@ -20,15 +36,13 @@ cd AI-Agent-Production-Checklist/examples/safe-agent-api
20
36
code .
21
37
```
22
38
23
-
Crie o ambiente e instale:
24
-
25
39
### Windows PowerShell
26
40
27
41
```powershell
28
42
py -m venv .venv
29
43
.\.venv\Scripts\Activate.ps1
30
44
python -m pip install -e ".[dev]"
31
-
fastapi dev
45
+
fastapi dev app/main.py
32
46
```
33
47
34
48
### Linux/macOS
@@ -37,21 +51,16 @@ fastapi dev
37
51
python3 -m venv .venv
38
52
source .venv/bin/activate
39
53
python -m pip install -e ".[dev]"
40
-
fastapi dev
54
+
fastapi dev app/main.py
41
55
```
42
56
43
-
Abra:
44
-
45
-
- API docs: `http://127.0.0.1:8000/docs`
46
-
- health: `http://127.0.0.1:8000/health`
47
-
48
57
## Executar testes
49
58
50
59
```bash
51
60
pytest
52
61
```
53
62
54
-
## Exemplo de política
63
+
## Políticas
55
64
56
65
| Tool | Regra |
57
66
|---|---|
@@ -61,20 +70,23 @@ pytest
61
70
62
71
A autorização é executada **fora do prompt/modelo**. Um LLM pode sugerir uma ação, mas não concede a si mesmo permissão para executá-la.
63
72
64
-
## Teste manual
73
+
## Audit + correlation
74
+
75
+
`POST /v1/run-demo` recebe um `request_id`. A resposta inclui um `audit_event` cujo `correlation_id` usa o mesmo identificador. Assim uma decisão permitida ou negada pode ser ligada à execução e ao diagnóstico operacional.
65
76
66
-
POST `/v1/tool-check`:
77
+
Exemplo:
67
78
68
79
```json
69
80
{
81
+
"request_id": "req-demo-002",
70
82
"actor_tenant_id": "alpha",
71
83
"resource_tenant_id": "alpha",
72
84
"tool": "send_notification",
73
-
"human_approved": false
85
+
"human_approved": true
74
86
}
75
87
```
76
88
77
-
O resultado deve indicar `human_approval_required`.
89
+
A resposta registra `allowed`, `executed`, `reason`, tenants, tool e `human_approved`, sem armazenar prompt ou conteúdo de conversa.
0 commit comments