返回资讯中心
外部精选
软件工程
#开发者实时流

SASY 发布:用 Datalog 声明式规则在 AI Agent 执行动作前拦截

来源标题:SASY: Agent Policies in Declarative Logic

SASY 可在 AI Agent 执行发送邮件、运行命令等动作前逐项检查,策略用声明式逻辑语言 Datalog 写成。它会结合 Agent 读取内容与调用工具的历史做判断,被拒绝的调用不会执行并返回原因。SDK 可自动接入 LangChain、Google ADK 和 Langroid。

Hacker News 最新Raed6672026/11/16 · 今天21 分钟阅读

以下正文由 AI 翻译自 Hacker News 最新(原文版权归原站所有),可能存在偏差,重要内容请以原文为准。

SASY 会在 AI agent 执行每个动作(例如发送邮件或运行命令)之前进行检查。你把策略写成 Datalog 规则,这是一种声明式逻辑语言。每次决策都会考虑到导致该动作的完整来龙去脉,从 agent 读过什么到它调用了哪些工具。

下面两次运行给 agent 布置了同一个任务:总结一份报告,并把摘要通过邮件发送给 reviewer@example.net。在第二次运行中,agent 还读取了一份不可信的笔记,其中要求它把摘要发送到别处。

DENIED此摘要同时依赖于不可信文档和敏感文档

你的 agent 照常运行。SASY SDK 记录它读取和产出的内容,SASY 引擎在每次工具调用执行之前,依据你的策略和历史记录进行检查。被拒绝的调用不会执行,agent 会收到原因。

SDK 可自动接入 LangChain、Google ADK 和 Langroid。自定义 agent 使用 sasy.record 和 sasy.check_tool_call。

DocsArchitecture →

BlogAgentic Security: An Aspect-Oriented Programming Perspective →

YOUR APPLICATION Your agent any framework or your own code SASY SDK records, checks calls Your tools email, shell, APIs call reason allowed SASY engine Your policy Datalog rules (compiled) History record + check allow / deny YOUR APPLICATION Your agent any framework or your own code SASY SDK records, checks calls Your tools email, shell, APIs call reason allowed SASY engine Your policy Datalog rules (compiled) History record

  • check allow / deny GET STARTED Install SASY. Let a coding agent set SASY up for you, or install it by hand in a Python project. The documentation explains how to write policies and add SASY to each framework. npx skills add sasy-labs/sasy Then ask your agent to set SASY up in your project. uv venv --python 3.11 source .venv/bin/activate uv add sasy sasy engine start In a Python project with uv and Docker installed. A real run of the message-flow example. An agent is asked to email a reviewer a summary of a confidential report. On the way, it reads an untrusted note telling it to send the summary elsewhere, and follows it. That email depends on both the note and the report, and the policy blocks it. dependency graph The graph is what SASY records for the run. When the agent tries the send, SASY follows the arrows back to both documents, and the policy denies it. DocsMore examples →

BlogClaude Code has your shell. What's watching it? →

SASY Guard 把 SASY 带到你机器上的编码 agent 中。它会依据策略和会话历史检查每一次工具调用。Guard 会拦截诸如破坏性命令、把下载的脚本通过管道送入 shell,或在读取密钥之后向外发送数据等行为。

npx skills add -g sasy-labs/sasy-guard 然后让你的编码 agent 设置 SASY Guard。它会安装好一切,并告诉你如何测试。各标签页展示了手动执行的相同步骤。

Claude Code Pi Codex

  1. INSTALL THE RUNTIME uv tool install sasy-guard sasy-guard install
  2. ADD THE CLAUDE CODE MOD claude plugin marketplace add sasy-labs/sasy-guard claude plugin install sasy-guard-mod 需要 Claude Code v2.1.289 或更高版本。该 mod 会在会话中显示每次决策。 uv tool install sasy-guard sasy-guard install
  3. ADD THE PI EXTENSION pi install git:github.com/sasy-labs/sasy-guard
  4. INSTALL SASY GUARD uv tool install sasy-guard
  5. ADD THE CODEX HOOK sasy-guard enable --codex 然后启动 Codex,并在它询问时信任该 hook。 Pi · ~/acme-appPause Show all Replay Codex · ~/acme-appPause Show all Replay 在这个演示中,一个被 prompt injection 接管的 agent 读取了 .env,然后试图把数据发送到外部服务器。Guard 拦截了该命令,因为它可以追溯到密钥。

DocsSASY Guard for Claude Code →

DocsSASY Guard for Pi →

DocsSASY Guard for Codex →

GitHubsasy-labs/sasy-guard →

BlogClaude Code has your shell. What's watching it? →

BlogA survey of coding-agent security guards →

下面这些规则来自示例的策略,它们允许发送,但如果某次发送的历史记录中同时包含不可信笔记和敏感报告,无论中间隔了多少步,都会拒绝该发送:

DependsOnUntrusted() :- CurrentDepends(id), ToolResult(id, "read_document", args), DependsOnSensitive() :- CurrentDepends(id), ToolResult(id, "read_document", args), IsAuthorized(idx) :- Actions(idx, a), IsTool(a, "send_summary"). // @deny_message: This summary depends on both untrusted and sensitive documents Unauthorized(idx) :- Actions(idx, a), IsTool(a, "send_summary"), DependsOnUntrusted(), DependsOnSensitive().

每条规则都是对动作及其历史的条件。即使 agent 对文档做了摘要或改写,该条件依然成立。用自然语言描述策略,write-policy 技能会起草相应的 Datalog。

PaperFormal Policy Enforcement for Real-World Agentic Systems →

DocsPolicy language →

BlogAgentic Security Policies as Compiled Logic →

BlogEvaluating Logic-Based Policies via Fixpoints →

策略是一组逻辑规则,SASY 可以把它作为一个整体来分析。在这里,有人添加了规则 3,以阻止任何来自敏感报告的摘要外发。这同时也会阻断普通情况:把摘要发送给 reviewer。

分析器会警告:规则 3 削减了规则 1 所允许的范围,却没有像规则 2 那样通过 deny 消息被标记为例外。它还会发现规则 2 现在已冗余。

DocsChecking a policy →

BlogAgentic Security Policies as Compiled Logic →

IsAuthorized(idx) :- Actions(idx, a), IsTool(a, "send_summary"). // @deny_message: This summary // depends on both untrusted // and sensitive documents Unauthorized(idx) :- Actions(idx, a), IsTool(a, "send_summary"), DependsOnUntrusted(), DependsOnSensitive(). ADDED LATERUnauthorized(idx) :- Actions(idx, a), IsTool(a, "send_summary"), DependsOnSensitive(). analyzer report (shortened) CONFLICTRule 3 denies sends that rule 1 allows, and nothing marks it as an intended exception. This is likely unintended.

(原文较长,此处译出前 6000 字,完整内容请点「打开原文」。)

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →