io.github.agent-polis/impact-preview

AI 与智能体

by agent-polis

Impact preview for AI agents - see what changes before any action executes.

什么是 io.github.agent-polis/impact-preview

Impact preview for AI agents - see what changes before any action executes.

README

🔍 Agent Polis

Impact Preview for AI Agents - "Terraform plan" for autonomous AI actions

<!-- mcp-name: io.github.agent-polis/impact-preview -->

License: MIT Python 3.11+

See exactly what will change before any AI agent action executes.

Agent Polis intercepts proposed actions from autonomous AI agents, analyzes their impact, shows you a diff preview of what will change, and only executes after human approval. Stop worrying about your AI agent deleting your production database.

🎯 The Problem

Autonomous AI agents are powerful but dangerous. Recent incidents:

  • Replit Agent deleted a production database, then lied about it
  • Cursor YOLO mode deleted an entire system including itself
  • Claude Code learned to bypass safety restrictions via shell scripts

Developers want to use AI agents but don't trust them. Current solutions show what agents want to do, not what will happen. There's no "terraform plan" equivalent for AI agent actions.

🚀 The Solution

code
AI Agent proposes action → Agent Polis analyzes impact → Human reviews diff → Approve/Reject → Execute
diff
# Example: Agent wants to write to config.yaml
- database_url: postgresql://localhost:5432/dev
+ database_url: postgresql://prod-server:5432/production
! WARNING: Production database URL detected (CRITICAL RISK)

✨ Features

  • Impact Preview: See file diffs, risk assessment, and warnings before execution
  • Approval Workflow: Approve, reject, or modify proposed actions
  • Risk Assessment: Automatic detection of high-risk operations (production data, system files, etc.)
  • Audit Trail: Event-sourced log of every proposed and executed action
  • SDK Integration: Easy @require_approval decorator for your agent code
  • Dashboard: Streamlit UI for reviewing and approving actions

🚀 Quick Start (2 minutes)

The fastest way to try Agent Polis is the MCP server with Claude Desktop or Cursor.

1. Install & Run

bash
pip install impact-preview
impact-preview-mcp

2. Configure Claude Desktop

Add to your config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

json
{
    "mcpServers": {
        "impact-preview": {
            "url": "http://localhost:8000/mcp"
        }
    }
}

3. Try It

Ask Claude to edit a file - it now has these tools:

ToolWhat it does
preview_file_writeShows diff before any edit
preview_file_deleteShows what will be lost
preview_shell_commandFlags dangerous commands
check_path_riskQuick risk check for any path

Example prompt:

"Preview what would happen if you changed the database URL in config.yaml to point to production"

Claude will show you the diff and risk assessment before making changes.


📦 Full Server Installation

For the complete approval workflow with dashboard and API:

bash
# Using Docker (recommended)
docker-compose up -d

# Or locally
pip install impact-preview
impact-preview

Register an Agent

bash
curl -X POST http://localhost:8000/api/v1/agents/register \
  -H "Content-Type: application/json" \
  -d '{"name": "my-agent", "description": "My AI coding assistant"}'

Submit Action → Review → Approve

bash
# Submit
curl -X POST http://localhost:8000/api/v1/actions \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action_type": "file_write", "target": "/app/config.yaml", "description": "Update DB URL", "payload": {"content": "db: prod"}}'

# Preview
curl http://localhost:8000/api/v1/actions/ACTION_ID/preview -H "X-API-Key: YOUR_API_KEY"

# Approve (or reject)
curl -X POST http://localhost:8000/api/v1/actions/ACTION_ID/approve -H "X-API-Key: YOUR_API_KEY"

Audit Trail (Events)

You can retrieve the complete audit trail for an action:

bash
curl http://localhost:8000/api/v1/actions/ACTION_ID/events -H "X-API-Key: YOUR_API_KEY"

ActionPreviewGenerated event payload includes machine-readable governance context:

  • data.governance.policy.decision / data.governance.policy.matched_rule_id
  • data.governance.scanner.reason_ids / data.governance.scanner.max_severity

🐍 SDK Integration

Wrap your agent's dangerous operations:

python
from agent_polis import AgentPolisClient

client = AgentPolisClient(api_url="http://localhost:8000", api_key="YOUR_KEY")

# Decorator approach - blocks until human approves
@client.require_approval(action_type="file_write")
def write_config(path: str, content: str):
    with open(path, 'w') as f:
        f.write(content)

# This will: submit → wait for approval → execute only if approved
write_config("/etc/myapp/config.yaml", "new content")

🖥️ Dashboard

Launch the Streamlit dashboard to review pending actions:

bash
pip install impact-preview[ui]
streamlit run src/agent_polis/ui/app.py

📚 API Reference

Actions API

EndpointMethodDescription
/api/v1/actionsPOSTSubmit action for approval
/api/v1/actionsGETList your actions
/api/v1/actions/pendingGETList pending approvals
/api/v1/actions/{id}GETGet action details
/api/v1/actions/{id}/previewGETGet impact preview
/api/v1/actions/{id}/diffGETGet diff output
/api/v1/actions/{id}/approvePOSTApprove action
/api/v1/actions/{id}/rejectPOSTReject action
/api/v1/actions/{id}/executePOSTExecute approved action

Action Types

  • file_write - Write content to a file
  • file_create - Create a new file
  • file_delete - Delete a file
  • file_move - Move/rename a file
  • db_query - Execute a database query (read)
  • db_execute - Execute a database statement (write)
  • api_call - Make an HTTP request
  • shell_command - Run a shell command
  • custom - Custom action type

Risk Levels

  • Low: Read operations, safe changes
  • Medium: Write operations to non-critical files
  • High: Delete operations, system files
  • Critical: Production data, irreversible changes

🔧 Configuration

bash
# .env
SECRET_KEY=your-secret-key
DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/agent_polis
REDIS_URL=redis://localhost:6379/0

# Optional
FREE_TIER_ACTIONS_PER_MONTH=100
LOG_LEVEL=INFO

🗺️ Roadmap

VersionFocusStatus
v0.2.0File operation previewCurrent
v0.3.0Database operation previewPlanned
v0.4.0API call previewPlanned
v0.5.0IDE integrations (Cursor, VS Code)Planned
v1.0.0Production readyPlanned

🤝 Contributing

bash
git clone https://github.com/agent-polis/impact-preview.git
cd impact-preview
pip install -e .[dev]
pre-commit install
pytest

📄 License

MIT License - see LICENSE for details.


Built for developers who want AI agents they can actually trust.

常见问题

io.github.agent-polis/impact-preview 是什么?

Impact preview for AI agents - see what changes before any action executes.

相关 Skills

Claude接口

by anthropics

Universal
热门

面向接入 Claude API、Anthropic SDK 或 Agent SDK 的开发场景,自动识别项目语言并给出对应示例与默认配置,快速搭建 LLM 应用。

想把Claude能力接进应用或智能体,用claude-api上手快、兼容Anthropic与Agent SDK,集成路径清晰又省心

AI 与智能体
未扫描114.1k

RAG架构师

by alirezarezvani

Universal
热门

聚焦生产级RAG系统设计与优化,覆盖文档切块、检索链路、索引构建、召回评估等关键环节,适合搭建可扩展、高准确率的知识库问答与检索增强应用。

面向RAG落地,把知识库、向量检索和生成链路系统串联起来,做架构设计时更清晰,也更少踩坑。

AI 与智能体
未扫描10.2k

计算机视觉

by alirezarezvani

Universal
热门

聚焦目标检测、图像分割与视觉系统落地,覆盖 YOLO、DETR、Mask R-CNN、SAM 等方案,适合定制数据集训练、推理优化及 ONNX/TensorRT 部署。

把目标检测、图像分割到推理部署串成完整工程链路,主流框架与 YOLO、DETR、SAM 等方案都覆盖,落地视觉 AI 会省心很多。

AI 与智能体
未扫描10.2k

相关 MCP Server

顺序思维

编辑精选

by Anthropic

热门

Sequential Thinking 是让 AI 通过动态思维链解决复杂问题的参考服务器。

这个服务器展示了如何让 Claude 像人类一样逐步推理,适合开发者学习 MCP 的思维链实现。但注意它只是个参考示例,别指望直接用在生产环境里。

AI 与智能体
83.4k

知识图谱记忆

编辑精选

by Anthropic

热门

Memory 是一个基于本地知识图谱的持久化记忆系统,让 AI 记住长期上下文。

帮 AI 和智能体补上“记不住”的短板,用本地知识图谱沉淀长期上下文,连续对话更聪明,数据也更可控。

AI 与智能体
83.4k

PraisonAI

编辑精选

by mervinpraison

热门

PraisonAI 是一个支持自反思和多 LLM 的低代码 AI 智能体框架。

如果你需要快速搭建一个能 24/7 运行的 AI 智能体团队来处理复杂任务(比如自动研究或代码生成),PraisonAI 的低代码设计和多平台集成(如 Telegram)让它上手极快。但作为非官方项目,它的生态成熟度可能不如 LangChain 等主流框架,适合愿意尝鲜的开发者。

AI 与智能体
6.8k

评论