Skip to content

feat: add opt-in AgentSentry V3 moderation - #1177

Merged
yaozheng-fang merged 1 commit into
volcengine:mainfrom
YuWeihung:feat/agentsentry-v3-integration
Oct 21, 2026
Merged

yaozheng-fang merged 1 commit into
volcengine:mainfrom
YuWeihung:feat/agentsentry-v3-integration

Conversation

@YuWeihung

@YuWeihung YuWeihung commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

改动内容

为 VeADK 的 LLMShieldPlugin 新增混合云 AgentSentry V3 适配,通过独立的 AGENTSENTRY_* 环境变量配置服务地址、接入点凭据和开关,复用官方 V4 签名器发送审核请求。公有云继续使用原有 LLM Shield 配置与调用逻辑。

新增功能

  • 用户输入审核:在模型调度前通过 before_dispatch 送检当前用户文本,命中拦截策略时返回拦截提示。
  • 工具执行前审核:收集模型可见执行计划和工具调用信息,通过 before_tool_call 送检,命中策略时阻止工具执行。
  • 汇总多个文本 Part 并过滤隐藏思考片段,避免工具循环中重复送检同一条用户输入。
  • 支持 AGENTSENTRY_ENABLED=false 独立关闭 AgentSentry。
  • 统一处理审核拒绝、服务异常、缺少可见计划等情况,并记录 hook、RequestId 和审核决策。

使用方式

  1. 安装包含本次改动的 VeADK 版本,并在 AgentSentry 为接入点配置防护策略。
  2. 在应用运行环境中配置以下变量,AK/SK 使用接入点数据面凭据:
AGENTSENTRY_ENABLED=true
AGENTSENTRY_URL=https://<agentsentry-host>/OpenTOP/V3/Lumen/Moderate
AGENTSENTRY_ACCOUNT_ID=<account-id>
AGENTSENTRY_INSTANCE_ID=<instance-id>
AGENTSENTRY_AK=<endpoint-ak>
AGENTSENTRY_SK=<endpoint-sk>
AGENTSENTRY_REGION=cn-private
  1. 创建插件并在 Agent 上挂载三个回调:
from veadk import Agent
from veadk.tools.builtin_tools.llm_shield import LLMShieldPlugin

shield = LLMShieldPlugin()
agent = Agent(
    name="secured_agent",
    instruction="调用工具前,先用可见文本说明执行计划。",
    tools=[your_tool],
    before_model_callback=shield.before_model_callback,
    after_model_callback=shield.after_model_callback,
    before_tool_callback=shield.before_tool_callback,
)

your_tool 替换为业务工具,模型沿用应用原有配置。after_model_callback 用于收集计划,实际远程送检发生在用户输入和工具执行前两个阶段。部署到 Runtime 时,将上述环境变量同步配置到 Runtime。

@YuWeihung
YuWeihung force-pushed the feat/agentsentry-v3-integration branch from 0dabe9e to 80f0871 Compare October 20, 2026 13:51
@YuWeihung
YuWeihung force-pushed the feat/agentsentry-v3-integration branch from 80f0871 to 7b9b60b Compare October 21, 2026 03:56
@yaozheng-fang
yaozheng-fang merged commit 5e5deb6 into volcengine:main Oct 21, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants