惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
C
Cybersecurity and Infrastructure Security Agency CISA
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
T
Threat Research - Cisco Blogs
C
Cisco Blogs
Recent Announcements
Recent Announcements
S
Securelist
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
P
Privacy & Cybersecurity Law Blog
宝玉的分享
宝玉的分享
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 热门话题
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
月光博客
月光博客
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LINUX DO - 最新话题
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
H
Help Net Security
Spread Privacy
Spread Privacy
PCI Perspectives
PCI Perspectives
Project Zero
Project Zero
I
Intezer
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
MyScale Blog
MyScale Blog
V
Vulnerabilities – Threatpost
Recorded Future
Recorded Future
T
Tenable Blog
Jina AI
Jina AI
D
DataBreaches.Net
阮一峰的网络日志
阮一峰的网络日志

博客园 - yi-sheng

AMD Rademo RX 7900 48G显存 单卡环境部署Qwen3.6-35B-A3B AMD开发者中心Notebook开SSH与WEB外网访问 ROCm 环境多模态开发开源项目汇总 国产曦云C500双卡vllm框架本地部署qwen3.6-35B模型 国产曦云C500驱动安装 国产曦云C500双卡本地部署qwen3.6-35B模型 NVIDIA GeForce RTX 3080 魔改20G 运行大模型 FusionXpark_GB10救砖教程 ARM 架构NVIDIA GB10 Grace Blackwell环境中部署 Qwen3.6-35B 推理服务 Rufus的4.4制作ubuntu-24.04.4安装U盘 常用办公终端NEC 莱斯双盘位桌面存储阵列2代-LaCie 2big v2设置RAID1 常用办公终端配置信息 H3C LinSeer MegaCube灵犀MegaCube工作站使用笔记 4090多卡使用sglang推理框架docker布署qwen3.6-35B 国产曦云C500双卡本地部署qwen3.5-35B模型 国产GPU沐曦GPU系统曦云C500体验笔记 ARM 架构NVIDIA GB10 Grace Blackwell 芯片环境下安装conda FusionXpark GB10盒子开箱笔记 Python 3.11.6 + Oracle 11g​开发环境配置 Teachable Machine安装 Qwen2.5-1.5B + LoRA 单张显卡 微调实战 Qwen2.5-1.5B + LoRA 微调实战 大模型基建实战:使用序列猴子数据集定制 BPE Tokenizer 老年小龙虾soul.md示例 低幻觉医疗大模型Baichuan-M2-32B本地部署笔记 小龙虾本地算力RTX 4090 (24G) 四卡本地SGLang框架跑qwen3.5-35B模型 MCP工具粒度的权衡 DELL XPS 13-7390 重装系统方法 搭建私有 Matrix 聊天服务器 OpenClaw小龙虾软件原理解析 小龙虾本地算力 RTX 4090 (24G) 四卡本地运行 Qwen2.5-27B​ 模型 OpenClaw 飞书平台配置指南 MacBook Air A1534 系统安装指南:从 macOS 到 Windows
MCP开发技巧:静态参数作为行为提醒(Reminder Pattern)
yi-sheng · 2026-04-01 · via 博客园 - yi-sheng

这是一个巧妙的技巧:设计一个静态参数,它的值永远是固定的,但在描述中包含重要的行为提醒。当 LLM 按顺序生成工具调用参数时,它必须「输出」这个固定值,相当于在执行前进行了一次自我确认。

{
  "type": "object",
  "properties": {
    "file_path": {
      "type": "string",
      "description": "要写入的文件路径"
    },
    "content": {
      "type": "string",
      "description": "要写入的文件内容"
    },
    "CONFIRM_OVERWRITE": {
      "type": "string",
      "enum": [
        "I confirm this will overwrite existing content"
      ],
      "description": "确认提醒:此参数的值必须是 'I confirm this will overwrite existing content'。在输出此参数前,请确认:1) 你已经读取过原文件内容 2) 你确定要覆盖而非追加 3) 用户明确要求了此操作"
    }
  },
  "required": [
    "file_path",
    "content",
    "CONFIRM_OVERWRITE"
  ]
}

工作原理:

LLM 在生成工具调用时会按顺序输出每个参数。当它输出到 CONFIRM_OVERWRITE 参数时:

  1. 它必须输出固定值 "I confirm this will overwrite existing content"

  2. 在「决定」输出这个值的过程中,描述中的提醒会被「重新处理」一遍

  3. 这相当于在关键操作前设置了一个「检查点」

{
  "delete_resource": {
    "type": "object",
    "properties": {
      "resource_id": {
        "type": "string",
        "description": "要删除的资源 ID"
      },
      "SAFETY_CHECK": {
        "type": "string",
        "enum": ["CONFIRMED_PERMANENT_DELETE"],
        "description": "安全检查:此参数必须填写 'CONFIRMED_PERMANENT_DELETE'。在填写前请确认:1) 这是不可逆操作 2) 已告知用户删除后果 3) 用户明确确认要删除"
      }
    },
    "required": ["resource_id", "SAFETY_CHECK"]
  },

  "send_message": {
    "type": "object",
    "properties": {
      "recipient": {
        "type": "string"
      },
      "message": {
        "type": "string"
      },
      "TONE_CHECK": {
        "type": "string",
        "enum": ["professional_tone_verified"],
        "description": "语气检查:此参数必须填写 'professional_tone_verified'。在填写前请检查消息内容:1) 语气是否专业友好 2) 是否有拼写错误 3) 是否包含敏感信息"
      }
    },
    "required": ["recipient", "message", "TONE_CHECK"]
  },

  "execute_code": {
    "type": "object",
    "properties": {
      "code": {
        "type": "string"
      },
      "ENVIRONMENT_CHECK": {
        "type": "string",
        "enum": ["sandbox_environment_confirmed"],
        "description": "环境确认:此参数必须填写 'sandbox_environment_confirmed'。请确认代码将在沙箱环境执行,不会影响生产数据"
      }
    },
    "required": ["code", "ENVIRONMENT_CHECK"]
  }
}

为什么这个技巧有效?

  1. 强制「思考」:LLM 必须处理描述文本才能确定输出什么值

  2. 打断自动化倾向:防止 LLM 「惯性」地快速生成工具调用而忽略重要细节

  3. 可审计:工具调用日志中会包含这个确认参数,便于追溯

  4. 零实现成本:工具实现端只需要验证参数值是否正确即可

使用建议:

  • 将此类参数放在参数列表的最后,让 LLM 在填完所有实际参数后再进行确认

  • 使用 enum 限制值域,确保 LLM 必须输出完全正确的值

  • 参数名使用大写(如 CONFIRM_XXXSAFETY_CHECK),使其在视觉上突出

  • 不要滥用此技巧,只用于真正需要谨慎处理的关键操作