[{"data":1,"prerenderedAt":135},["ShallowReactive",2],{"article-other\u002Fagent_tool_select":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"body":13,"_type":129,"_id":130,"_source":131,"_file":132,"_stem":133,"_extension":134},"\u002Farticles\u002Fother\u002Fagent_tool_select","other",false,"","AI Agent 如何动态选择工具：Skill 匹配与三种筛选模式","解读 AI 制药 Agent 的工具预筛选机制：先以 Skill 锁定必需工具，再通过 LLM、embedding 或全量注入选择额外工具，并分析其与普通 Agent 的区别。","2026-08-12",[12],"随笔",{"type":14,"children":15,"toc":120},"root",[16,24,39,44,51,56,66,71,76,96,102,107,115],{"type":17,"tag":18,"props":19,"children":21},"element","h2",{"id":20},"起因",[22],{"type":23,"value":20},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28,30],{"type":23,"value":29},"读了一篇AI制药Agent的论文(",{"type":17,"tag":31,"props":32,"children":36},"a",{"href":33,"rel":34},"https:\u002F\u002Fwww.biorxiv.org\u002Fcontent\u002F10.1101\u002F2025.04.03.646459v1.full#F15)%EF%BC%8C%E5%AE%83%E5%9C%A8%E5%B7%A5%E5%85%B7%E9%80%89%E6%8B%A9%E7%9A%84%E8%AE%BE%E8%AE%A1%E4%B8%8A%E8%AE%A9%E6%88%91%E5%8D%B0%E8%B1%A1%E6%B7%B1%E5%88%BB%E3%80%82",[35],"nofollow",[37],{"type":23,"value":38},"https:\u002F\u002Fwww.biorxiv.org\u002Fcontent\u002F10.1101\u002F2025.04.03.646459v1.full#F15)，它在工具选择的设计上让我印象深刻。",{"type":17,"tag":18,"props":40,"children":42},{"id":41},"解读",[43],{"type":23,"value":41},{"type":17,"tag":45,"props":46,"children":48},"h3",{"id":47},"此agent的工具选择机制",[49],{"type":23,"value":50},"此Agent的工具选择机制",{"type":17,"tag":25,"props":52,"children":53},{},[54],{"type":23,"value":55},"流程示意图",{"type":17,"tag":57,"props":58,"children":60},"pre",{"code":59},"用户问题\n   ↓\nSkill 匹配\n   ↓\n提取 Skill 中要求使用的工具\n   ↓\n根据模式选择额外工具\n   ├─ llm：让 LLM 判断\n   ├─ embedding：计算语义相似度\n   └─ all：直接全部使用\n   ↓\n将工具说明和参数注入上下文\n   ↓\n规划 LLM 生成 \u003Cact> Python\u002FBash 代码\n   ↓\n执行代码\n",[61],{"type":17,"tag":62,"props":63,"children":64},"code",{"__ignoreMap":7},[65],{"type":23,"value":59},{"type":17,"tag":25,"props":67,"children":68},{},[69],{"type":23,"value":70},"它有个tool的动态选择机制，每次新用户问题进来，先匹配 skill 模板，再选择工具，工具选择支持三种模式(llm、embedding、all)。\n具体来说，它先使用一个skill template匹配用户问题，然后根据匹配到的skill(某个标准流程，会指定这个流程固定要使用的工具),并从模版中提取必需的工具，然后再根据模式选择额外的工具。始终保留的核心工具\"execute_python\",\"execute_bash\",\"inspect_tool_code\",\"query_pubmed\",\"web_search\"，也就是不管用户提出什么问题，tool_selection是什么模型，这几个工具都会保留。",{"type":17,"tag":25,"props":72,"children":73},{},[74],{"type":23,"value":75},"工具选择的三种模式：",{"type":17,"tag":77,"props":78,"children":79},"ol",{},[80,86,91],{"type":17,"tag":81,"props":82,"children":83},"li",{},[84],{"type":23,"value":85},"llm：简单来说就是把问题和现有工具描述交给大模型，让大模型决定使用哪些工具。它这块有个细节就是它只把工具描述的第一句交给大模型以节省token的消耗，这对工具的第一句描述提出了挺高的要求，并且也增加的选不准工具的风险，个人觉得这种对准确性和严谨性很高的任务，token费点就费点吧。",{"type":17,"tag":81,"props":87,"children":88},{},[89],{"type":23,"value":90},"embedding：参考的RAG那块的思想，根据问题和工具描述的相似度返回要使用的工具。",{"type":17,"tag":81,"props":92,"children":93},{},[94],{"type":23,"value":95},"all：把所有工具都塞进上下文窗口。all 并不一定最准确。工具越多，模型的“选择注意力”越容易被稀释。",{"type":17,"tag":45,"props":97,"children":99},{"id":98},"与普通agent的区别",[100],{"type":23,"value":101},"与普通Agent的区别",{"type":17,"tag":25,"props":103,"children":104},{},[105],{"type":23,"value":106},"没有单独的工具检索模块时，典型做法就是：",{"type":17,"tag":57,"props":108,"children":110},{"code":109},"用户问题\n+ 所有工具的名称\n+ 所有工具的描述\n+ 所有工具的参数 Schema\n        ↓\n交给主 LLM\n        ↓\nLLM 决定调用哪个工具\n",[111],{"type":17,"tag":62,"props":112,"children":113},{"__ignoreMap":7},[114],{"type":23,"value":109},{"type":17,"tag":25,"props":116,"children":117},{},[118],{"type":23,"value":119},"此Agent增加了预筛选步骤",{"title":7,"searchDepth":121,"depth":121,"links":122},2,[123,124],{"id":20,"depth":121,"text":20},{"id":41,"depth":121,"text":41,"children":125},[126,128],{"id":47,"depth":127,"text":50},3,{"id":98,"depth":127,"text":101},"markdown","content:articles:other:agent_tool_select.md","content","articles\u002Fother\u002Fagent_tool_select.md","articles\u002Fother\u002Fagent_tool_select","md",1789465115004]