{"id":122874,"date":"2026-11-05T22:24:54","date_gmt":"2026-11-05T14:24:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/122874.html"},"modified":"2026-11-05T22:24:54","modified_gmt":"2026-11-05T14:24:54","slug":"llm-%e4%b8%8d%e6%98%af%e7%a8%8b%e5%ba%8f%e5%91%98%ef%bc%9aagent-%e5%b7%a5%e5%85%b7%e8%b0%83%e7%94%a8%e5%a4%b1%e8%b4%a5%e7%9a%84-6-%e7%a7%8d%e6%ad%bb%e6%b3%95%e4%b8%8e-7-%e5%b1%82%e8%a7%a3%e8%8d%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/122874.html","title":{"rendered":"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li>\u5f00\u573a&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u5230\u8ba9\u4eba\u5934\u79c3\u7684\u573a\u666f<\/li>\n<li>\u5148\u5206\u7c7b&#xff1a;\u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd&#034;\u6b7b\u6cd5&#034;<\/li>\n<li>\u4e03\u5c42\u9632\u5fa1\u4f53\u7cfb<\/li>\n<li>\n<ul>\n<li>L1 \u9884\u9632\u5c42&#xff1a;\u628a\u5de5\u5177\u8bf4\u660e\u4e66\u5199\u5230 LLM \u4e0d\u72af\u9519<\/li>\n<li>L2 \u6821\u9a8c\u5c42&#xff1a;\u53c2\u6570\u95e8\u7981&#xff08;Pydantic&#xff09;<\/li>\n<li>L3 \u6355\u83b7\u5c42&#xff1a;\u7edf\u4e00\u5f02\u5e38\u5305\u88c5<\/li>\n<li>L4 \u91cd\u8bd5\u5c42&#xff1a;\u53ea\u91cd\u8bd5&#034;\u8be5\u91cd\u8bd5\u7684&#034;<\/li>\n<li>L5 \u964d\u7ea7\u5c42&#xff1a;Fallback \u5de5\u5177\u94fe<\/li>\n<li>L6 \u81ea\u6108\u5c42&#xff08;Agent \u72ec\u6709&#xff0c;\u5168\u6587\u6700\u5173\u952e&#xff09;&#xff1a;\u628a\u9519\u8bef\u5582\u56de\u53bb<\/li>\n<li>L7 \u515c\u5e95\u5c42&#xff1a;\u8bda\u5b9e\u5931\u8d25<\/li>\n<\/ul>\n<\/li>\n<li>\u4e00\u4e2a\u5b8c\u6574\u53ef\u8dd1\u7684\u4f8b\u5b50<\/li>\n<li>\u76d1\u63a7\u4e0e\u53ef\u89c2\u6d4b<\/li>\n<li>\u603b\u7ed3&#xff1a;\u4e00\u5f20\u56fe &#043; \u4e09\u53e5\u8bdd<\/li>\n<li>\u9644&#xff1a;\u81ea\u67e5\u6e05\u5355&#xff08;\u5efa\u8bae\u6536\u85cf&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4f20\u7edf\u7a0b\u5e8f\u91cc&#xff0c;\u5f02\u5e38\u662f Bug&#xff1b;Agent \u91cc&#xff0c;\u5f02\u5e38\u662f\u6b63\u5e38\u8f93\u5165\u3002<\/p>\n<h3>\u5f00\u573a&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u5230\u8ba9\u4eba\u5934\u79c3\u7684\u573a\u666f<\/h3>\n<p>\u5047\u8bbe\u4f60\u5728\u505a\u4e00\u4e2a\u8ba2\u5355\u67e5\u8be2\u5ba2\u670d Agent&#xff0c;\u5de5\u5177\u5b9a\u4e49\u5f88\u7b80\u5355&#xff1a;<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">get_order<\/span><span class=\"token punctuation\">(<\/span>order_id<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token builtin\">dict<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;\u67e5\u8ba2\u5355\u8be6\u60c5&#034;&#034;&#034;<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><\/p>\n<p>\u7528\u6237\u8bf4&#xff1a;\u201c\u5e2e\u6211\u770b\u770b\u5f20\u4e09\u7684\u8ba2\u5355\u5230\u54ea\u4e86\u3002\u201d<\/p>\n<p>LLM \u628a order_id \u4f20\u6210\u4e86 &#034;\u5f20\u4e09&#034; \u2014\u2014 \u56e0\u4e3a\u5b83\u89c9\u5f97&#034;\u5f20\u4e09&#034;\u5c31\u662f\u8981\u67e5\u7684\u4e1c\u897f\u3002\u5de5\u5177\u629b\u4e86 OrderNotFound\u3002\u6b64\u65f6 Agent \u901a\u5e38\u6709\u4e24\u79cd\u6b7b\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\u6b7b\u6cd5 A&#xff1a;\u6574\u4e2a\u6d41\u7a0b\u5d29\u4e86&#xff0c;\u8fd4\u56de 500&#xff0c;\u7528\u6237\u4e00\u8138\u61f5&#xff1b;<\/li>\n<li>\u6b7b\u6cd5 B&#xff1a;LLM \u4e3a\u4e86&#034;\u5b8c\u6210\u4efb\u52a1&#034;&#xff0c;\u7f16\u9020\u4e86\u4e00\u4e2a\u8ba2\u5355\u53f7&#xff0c;\u8fd4\u56de\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684&#034;\u5df2\u7b7e\u6536&#034;\u3002<\/li>\n<\/ul>\n<p>\u7b2c\u4e8c\u79cd\u6700\u53ef\u6015\u3002\u5b83\u8868\u9762\u6210\u529f&#xff0c;\u5b9e\u5219\u6492\u8c0e&#xff0c;\u6bd4\u62a5\u9519\u5371\u5bb3\u5927\u4e00\u767e\u500d\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u4f20\u7edf\u7a0b\u5e8f\u6ca1\u8fd9\u4e2a\u95ee\u9898&#xff1f;\u56e0\u4e3a\u4f60\u5199 requests.get() \u62a5\u9519&#xff0c;\u662f\u4f60\u5199\u9519\u4e86&#xff0c;\u6539\u4ee3\u7801\u5c31\u884c\u3002\u4f46 Agent \u91cc&#xff0c;\u662f LLM \u52a8\u6001\u51b3\u5b9a\u8c03\u54ea\u4e2a\u5de5\u5177\u3001\u4f20\u4ec0\u4e48\u53c2\u6570\u2014\u2014\u4f60\u6c38\u8fdc\u65e0\u6cd5\u7a77\u4e3e\u5b83\u4f1a\u4f20\u4ec0\u4e48\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;Agent \u7684\u5f02\u5e38\u5904\u7406&#xff0c;\u601d\u8def\u8981\u4ece&#034;\u4fee Bug&#034;\u5207\u6362\u5230&#034;\u8bbe\u8ba1\u5bb9\u9519\u7cfb\u7edf&#034;\u3002\u4e0b\u9762\u8fd9\u5957\u4e03\u5c42\u9632\u7ebf&#xff0c;\u5c31\u662f\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u5b8c\u6574\u65b9\u6848\u3002<\/p>\n<hr \/>\n<h3>\u5148\u5206\u7c7b&#xff1a;\u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd&#034;\u6b7b\u6cd5&#034;<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105142452-6aec91b46b76e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u62ff\u5230\u95ee\u9898\u5148\u5206\u7c7b&#xff0c;\u624d\u80fd\u5bf9\u75c7\u4e0b\u836f\u3002\u7edd\u5927\u591a\u6570\u5931\u8d25\u90fd\u80fd\u5f52\u8fdb\u8fd9\u5f20\u8868&#xff1a;<\/p>\n<table>\n<tr>#\u5931\u8d25\u7c7b\u578b\u5178\u578b\u8868\u73b0\u6839\u56e0\u89e3\u51b3\u5c42<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>\u53c2\u6570\u5e7b\u89c9<\/td>\n<td>LLM \u7f16\u9020\u4e0d\u5b58\u5728\u7684\u5b57\u6bb5\u540d\u3001\u4f20\u9519\u683c\u5f0f<\/td>\n<td>\u5de5\u5177\u63cf\u8ff0\u5199\u5f97\u70c2<\/td>\n<td>L1\/L2 \u9884\u9632&#043;\u6821\u9a8c<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>\u4e1a\u52a1\u5f02\u5e38<\/td>\n<td>\u8ba2\u5355\u4e0d\u5b58\u5728\u3001\u4f59\u989d\u4e0d\u8db3\u3001\u65e0\u6743\u9650<\/td>\n<td>\u4e0b\u6e38\u4e1a\u52a1\u89c4\u5219<\/td>\n<td>L3 \u6355\u83b7<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>\u7f51\u7edc\/\u8d85\u65f6<\/td>\n<td>500\u3001ConnectionError\u3001read timeout<\/td>\n<td>\u4e0b\u6e38\u4e0d\u7a33\u5b9a<\/td>\n<td>L4 \u91cd\u8bd5<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>\u8fd4\u56de\u683c\u5f0f\u810f<\/td>\n<td>\u8fd4\u56de\u4e86 HTML \u9519\u8bef\u9875\u3001JSON \u6df7\u6ce8\u91ca<\/td>\n<td>\u4e0b\u6e38\u4e0d\u89c4\u8303<\/td>\n<td>L3 \u6355\u83b7<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>\u51b3\u7b56\u9519\u8bef<\/td>\n<td>\u8be5\u67e5\u5929\u6c14&#xff0c;\u5374\u8c03\u4e86\u8ba1\u7b97\u5668<\/td>\n<td>\u5de5\u5177\u9009\u62e9\u6df7\u6dc6<\/td>\n<td>L1 \u5199\u597d\u63cf\u8ff0<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>\u8d44\u6e90\u8017\u5c3d<\/td>\n<td>\u914d\u989d\u3001\u9650\u6d41\u3001\u7194\u65ad<\/td>\n<td>\u5916\u90e8\u4f9d\u8d56\u96ea\u5d29<\/td>\n<td>L4\/L5 \u91cd\u8bd5&#043;\u964d\u7ea7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u53e5\u8bdd\u8bb0\u5fc6&#xff1a;\u524d 2 \u7c7b\u9760&#034;\u5199\u597d\u5de5\u5177&#034;\u89e3\u51b3&#xff0c;\u4e2d\u95f4 2 \u7c7b\u9760&#034;\u5de5\u7a0b\u515c\u5e95&#034;\u89e3\u51b3&#xff0c;\u6700\u540e 2 \u7c7b\u9760&#034;\u7cfb\u7edf\u8bbe\u8ba1&#034;\u89e3\u51b3\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u5c42\u9632\u5fa1\u4f53\u7cfb<\/h3>\n<p>\u5148\u7528\u4e00\u5f20\u56fe\u5efa\u7acb\u5168\u5c40\u8ba4\u77e5&#xff0c;\u540e\u9762\u6bcf\u4e00\u5c42\u9010\u4e00\u5c55\u5f00&#xff1a;<\/p>\n<p>  #mermaid-svg-NymIWboKu5Aepg2A{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-NymIWboKu5Aepg2A .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-NymIWboKu5Aepg2A .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-NymIWboKu5Aepg2A .error-icon{fill:#552222;}#mermaid-svg-NymIWboKu5Aepg2A .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-NymIWboKu5Aepg2A .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-NymIWboKu5Aepg2A .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-NymIWboKu5Aepg2A .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-NymIWboKu5Aepg2A .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-NymIWboKu5Aepg2A .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-NymIWboKu5Aepg2A .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-NymIWboKu5Aepg2A .marker{fill:#333333;stroke:#333333;}#mermaid-svg-NymIWboKu5Aepg2A .marker.cross{stroke:#333333;}#mermaid-svg-NymIWboKu5Aepg2A svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-NymIWboKu5Aepg2A p{margin:0;}#mermaid-svg-NymIWboKu5Aepg2A .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-NymIWboKu5Aepg2A .cluster-label text{fill:#333;}#mermaid-svg-NymIWboKu5Aepg2A .cluster-label span{color:#333;}#mermaid-svg-NymIWboKu5Aepg2A .cluster-label span p{background-color:transparent;}#mermaid-svg-NymIWboKu5Aepg2A .label text,#mermaid-svg-NymIWboKu5Aepg2A span{fill:#333;color:#333;}#mermaid-svg-NymIWboKu5Aepg2A .node rect,#mermaid-svg-NymIWboKu5Aepg2A .node circle,#mermaid-svg-NymIWboKu5Aepg2A .node ellipse,#mermaid-svg-NymIWboKu5Aepg2A .node polygon,#mermaid-svg-NymIWboKu5Aepg2A .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-NymIWboKu5Aepg2A .rough-node .label text,#mermaid-svg-NymIWboKu5Aepg2A .node .label text,#mermaid-svg-NymIWboKu5Aepg2A .image-shape .label,#mermaid-svg-NymIWboKu5Aepg2A .icon-shape .label{text-anchor:middle;}#mermaid-svg-NymIWboKu5Aepg2A .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-NymIWboKu5Aepg2A .rough-node .label,#mermaid-svg-NymIWboKu5Aepg2A .node .label,#mermaid-svg-NymIWboKu5Aepg2A .image-shape .label,#mermaid-svg-NymIWboKu5Aepg2A .icon-shape .label{text-align:center;}#mermaid-svg-NymIWboKu5Aepg2A .node.clickable{cursor:pointer;}#mermaid-svg-NymIWboKu5Aepg2A .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-NymIWboKu5Aepg2A .arrowheadPath{fill:#333333;}#mermaid-svg-NymIWboKu5Aepg2A .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-NymIWboKu5Aepg2A .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-NymIWboKu5Aepg2A .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-NymIWboKu5Aepg2A .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-NymIWboKu5Aepg2A .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-NymIWboKu5Aepg2A .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-NymIWboKu5Aepg2A .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-NymIWboKu5Aepg2A .cluster text{fill:#333;}#mermaid-svg-NymIWboKu5Aepg2A .cluster span{color:#333;}#mermaid-svg-NymIWboKu5Aepg2A div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-NymIWboKu5Aepg2A .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-NymIWboKu5Aepg2A rect.text{fill:none;stroke-width:0;}#mermaid-svg-NymIWboKu5Aepg2A .icon-shape,#mermaid-svg-NymIWboKu5Aepg2A .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-NymIWboKu5Aepg2A .icon-shape p,#mermaid-svg-NymIWboKu5Aepg2A .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-NymIWboKu5Aepg2A .icon-shape .label rect,#mermaid-svg-NymIWboKu5Aepg2A .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-NymIWboKu5Aepg2A .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-NymIWboKu5Aepg2A .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-NymIWboKu5Aepg2A :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u662f<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u5426<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u6709<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u65e0<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u80fd<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u4e0d\u80fd<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>LLM \u51b3\u7b56\u8c03\u7528\u5de5\u5177<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>L1 \u5de5\u5177\u63cf\u8ff0\u4e0e Schema \u95e8\u7981<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>L2 \u53c2\u6570 Pydantic \u6821\u9a8c<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>L3 try-except \u7edf\u4e00\u5305\u88c5<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>L4 \u53ef\u91cd\u8bd5?<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u6307\u6570\u9000\u907f\u91cd\u8bd5<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>L5 \u6709 Fallback?<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u964d\u7ea7\u5230\u5907\u7528\u5de5\u5177<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>L6 \u9519\u8bef\u4fe1\u606f\u56de\u5582 LLM<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>LLM \u80fd\u5426\u81ea\u6211\u4fee\u6b63?<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>L7 \u515c\u5e95: \u8f6c\u4eba\u5de5 \/ \u8bda\u5b9e\u56de\u7b54<\/p>\n<p><\/span><\/p>\n<hr \/>\n<h4>L1 \u9884\u9632\u5c42&#xff1a;\u628a\u5de5\u5177\u8bf4\u660e\u4e66\u5199\u5230 LLM \u4e0d\u72af\u9519<\/h4>\n<p>\u9884\u9632\u6c38\u8fdc\u4f18\u4e8e\u8865\u6551\u3002 \u5927\u90e8\u5206\u53c2\u6570\u5e7b\u89c9&#xff0c;\u662f\u5de5\u5177\u63cf\u8ff0\u5199\u5f97\u4e0d\u591f\u6e05\u695a\u9020\u6210\u7684\u3002<\/p>\n<p>\u274c \u53cd\u4f8b&#xff1a;<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">get_order<\/span><span class=\"token punctuation\">(<\/span>order_id<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;\u67e5\u8ba2\u5355&#034;&#034;&#034;<\/span><\/p>\n<p>\u2705 \u6b63\u4f8b&#xff1a;\u4e3b\u52a8\u5199&#034;\u4e0d\u8981\u505a\u4ec0\u4e48&#034;&#xff0c;\u628a\u683c\u5f0f\u7ea6\u675f\u5199\u6b7b&#xff1a;<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">get_order<\/span><span class=\"token punctuation\">(<\/span>order_id<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;<br \/>\n    \u6839\u636e\u8ba2\u5355\u53f7\u67e5\u8be2\u8ba2\u5355\u8be6\u60c5\u3002<\/p>\n<p>    \u6ce8\u610f&#xff1a;<br \/>\n    &#8211; order_id \u5fc5\u987b\u662f 18 \u4f4d\u5b57\u7b26&#xff0c;\u4ee5 ORD \u5f00\u5934&#xff08;\u5982 ORD20241020000123&#xff09;&#xff1b;<br \/>\n    &#8211; \u4e0d\u8981\u4f20\u7528\u6237\u59d3\u540d\u3001\u624b\u673a\u53f7\u6216 ID&#xff1b;<br \/>\n    &#8211; \u5982\u679c\u5bf9\u8bdd\u91cc\u6ca1\u6709\u8ba2\u5355\u53f7&#xff0c;\u5148\u5411\u7528\u6237\u7d22\u8981&#xff0c;\u4e0d\u8981\u731c\u6d4b\u3002<br \/>\n    &#034;&#034;&#034;<\/span><\/p>\n<p>\u7ecf\u9a8c&#xff1a;\u5de5\u5177\u63cf\u8ff0\u91cc&#034;\u4e0d\u8981\u505a\u4ec0\u4e48&#034;&#xff0c;\u6bd4\u53ea\u5199&#034;\u505a\u4ec0\u4e48&#034;\u66f4\u7ba1\u7528\u3002LLM \u662f\u6982\u7387\u6a21\u578b&#xff0c;\u4f60\u628a\u6b67\u4e49\u7a7a\u95f4\u7f29\u5c0f&#xff0c;\u5b83\u72af\u9519\u6982\u7387\u5c31\u4e0b\u964d\u3002<\/p>\n<hr \/>\n<h4>L2 \u6821\u9a8c\u5c42&#xff1a;\u53c2\u6570\u95e8\u7981&#xff08;Pydantic&#xff09;<\/h4>\n<p>\u5373\u4f7f\u63cf\u8ff0\u5199\u5f97\u597d&#xff0c;\u4e5f\u8981\u5728\u672c\u5730\u505a\u786c\u6821\u9a8c\u3002LLM \u4f20\u9519\u53c2\u6570&#xff0c;\u6211\u4eec\u5728\u53d1\u8d77\u4e0b\u6e38\u8c03\u7528\u4e4b\u524d\u5c31\u62e6\u4f4f&#xff0c;\u628a\u6821\u9a8c\u9519\u8bef\u56de\u5582\u7ed9\u5b83&#xff1a;<\/p>\n<p><span class=\"token keyword\">from<\/span> pydantic <span class=\"token keyword\">import<\/span> BaseModel<span class=\"token punctuation\">,<\/span> Field<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">GetOrderInput<\/span><span class=\"token punctuation\">(<\/span>BaseModel<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    order_id<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span> <span class=\"token operator\">&#061;<\/span> Field<span class=\"token punctuation\">(<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        pattern<span class=\"token operator\">&#061;<\/span><span class=\"token string\">r&#034;^ORD\\\\d{15}$&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        description<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\u8ba2\u5355\u53f7\u683c\u5f0f: ORD &#043; 15\u4f4d\u6570\u5b57&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd9\u6837 get_order(order_id&#061;&#034;\u5f20\u4e09&#034;) \u5728\u8fdb\u5165\u51fd\u6570\u524d\u5c31\u88ab Pydantic \u62e6\u622a&#xff0c;\u8fd4\u56de\u6821\u9a8c\u9519\u8bef\u3002\u4e0b\u6e38\u4e00\u4e2a\u8bf7\u6c42\u90fd\u6ca1\u53d1\u51fa&#xff0c;\u5c31\u4e0d\u5b58\u5728&#034;\u70e7\u94b1\u5931\u8d25&#034;\u7684\u95ee\u9898\u3002<\/p>\n<hr \/>\n<h4>L3 \u6355\u83b7\u5c42&#xff1a;\u7edf\u4e00\u5f02\u5e38\u5305\u88c5<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105142453-6aec91b50ddda.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e0d\u8981\u628a\u539f\u59cb\u7684 Traceback \u76f4\u63a5\u7529\u7ed9 LLM\u2014\u2014\u5b83\u8bfb\u4e0d\u61c2&#xff0c;\u800c\u4e14\u539f\u59cb\u9519\u8bef\u6587\u672c\u8fd8\u53ef\u80fd\u88ab\u6ce8\u5165\u5229\u7528\u3002\u6b63\u786e\u505a\u6cd5\u662f\u628a\u5f02\u5e38\u7ed3\u6784\u5316&#xff1a;<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">ToolError<\/span><span class=\"token punctuation\">(<\/span>Exception<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> code<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">,<\/span> message<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">,<\/span> retryable<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">bool<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token builtin\">super<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>__init__<span class=\"token punctuation\">(<\/span>message<span class=\"token punctuation\">)<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>code <span class=\"token operator\">&#061;<\/span> code        <span class=\"token comment\"># \u4f8b\u5982 ORDER_NOT_FOUND \/ TIMEOUT \/ UPSTREAM<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>message <span class=\"token operator\">&#061;<\/span> message  <span class=\"token comment\"># \u7ed9\u4eba \/ \u7ed9 LLM \u770b\u7684\u5b89\u5168\u6587\u6848<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>retryable <span class=\"token operator\">&#061;<\/span> retryable  <span class=\"token comment\"># \u662f\u5426\u503c\u5f97\u91cd\u8bd5<\/span><\/p>\n<p>\u6838\u5fc3\u8bbe\u8ba1&#xff1a;\u7ed9\u6bcf\u4e2a\u9519\u8bef\u6253\u4e0a retryable \u6807\u7b7e\u3002\u8fd9\u662f\u540e\u9762\u91cd\u8bd5\u3001\u964d\u7ea7\u3001\u81ea\u6108\u51b3\u7b56\u7684\u57fa\u7840\u3002<\/p>\n<hr \/>\n<h4>L4 \u91cd\u8bd5\u5c42&#xff1a;\u53ea\u91cd\u8bd5&#034;\u8be5\u91cd\u8bd5\u7684&#034;<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105142453-6aec91b55dbb0.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e0d\u662f\u6240\u6709\u9519\u8bef\u90fd\u503c\u5f97\u91cd\u8bd5\u3002\u91cd\u8bd5\u8981\u82b1\u94b1&#xff08;token &#043; \u65f6\u95f4&#xff09;&#xff0c;\u5fc5\u987b\u514b\u5236\u3002<\/p>\n<table>\n<tr>\u8be5\u91cd\u8bd5&#xff08;retryable&#061;True&#xff09;\u4e0d\u8be5\u91cd\u8bd5&#xff08;retryable&#061;False&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u7f51\u7edc\u6296\u52a8<\/td>\n<td>\u53c2\u6570\u9519\u8bef<\/td>\n<\/tr>\n<tr>\n<td>5xx \u670d\u52a1\u7aef\u9519\u8bef<\/td>\n<td>404 \u4e0d\u5b58\u5728<\/td>\n<\/tr>\n<tr>\n<td>\u8d85\u65f6<\/td>\n<td>\u4e1a\u52a1\u62d2\u7edd<\/td>\n<\/tr>\n<tr>\n<td>\u9650\u6d41 429<\/td>\n<td>\u9274\u6743\u5931\u8d25<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6307\u6570\u9000\u907f &#043; \u6296\u52a8&#xff0c;\u907f\u514d\u6240\u6709\u5ba2\u6237\u7aef\u540c\u65f6\u91cd\u8bd5\u6253\u5d29\u4e0b\u6e38&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> random<span class=\"token punctuation\">,<\/span> time<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">retry_with_backoff<\/span><span class=\"token punctuation\">(<\/span>fn<span class=\"token punctuation\">,<\/span> max_attempts<span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> attempt <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">range<\/span><span class=\"token punctuation\">(<\/span>max_attempts<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> fn<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">except<\/span> ToolError <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> e<span class=\"token punctuation\">.<\/span>retryable <span class=\"token keyword\">or<\/span> attempt <span class=\"token operator\">&#061;&#061;<\/span> max_attempts <span class=\"token operator\">&#8211;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token keyword\">raise<\/span><br \/>\n            sleep <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">min<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span> <span class=\"token operator\">**<\/span> attempt<span class=\"token punctuation\">,<\/span> <span class=\"token number\">30<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span> random<span class=\"token punctuation\">.<\/span>uniform<span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            time<span class=\"token punctuation\">.<\/span>sleep<span class=\"token punctuation\">(<\/span>sleep<span class=\"token punctuation\">)<\/span><\/p>\n<p>\u94c1\u5f8b&#xff1a;\u6700\u591a\u91cd\u8bd5 2~3 \u6b21\u3002\u522b\u8ba9 Agent \u65e0\u9650\u91cd\u8bd5\u628a\u9884\u7b97\u70e7\u5149\u3002<\/p>\n<hr \/>\n<h4>L5 \u964d\u7ea7\u5c42&#xff1a;Fallback \u5de5\u5177\u94fe<\/h4>\n<p>Agent \u4e0d\u8be5\u56e0\u4e3a\u4e00\u4e2a\u4e0b\u6e38\u6302\u6389\u5c31\u6574\u4e2a\u762b\u75ea\u3002\u8bbe\u8ba1\u5907\u7528\u8def\u5f84&#xff1a;<\/p>\n<ul>\n<li>\u4e3b\u8ba2\u5355\u5e93\u8d85\u65f6 \u2192 \u67e5\u53ea\u8bfb\u526f\u672c \/ \u7f13\u5b58<\/li>\n<li>\u5b9e\u65f6\u5929\u6c14 API \u6302\u4e86 \u2192 \u8fd4\u56de\u6628\u65e5\u7f13\u5b58 &#043; \u63d0\u793a&#034;\u6570\u636e\u975e\u5b9e\u65f6&#034;<\/li>\n<li>\u5185\u90e8 RAG \u68c0\u7d22\u5931\u8d25 \u2192 \u9000\u56de\u901a\u7528 LLM \u80fd\u529b\u56de\u7b54<\/li>\n<\/ul>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">search_catalog<\/span><span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> internal_rag<span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">except<\/span> ToolError<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u964d\u7ea7&#xff1a;\u9000\u5230\u57fa\u7840 LLM \u77e5\u8bc6\u56de\u7b54&#xff0c;\u5e76\u660e\u786e\u544a\u77e5\u7528\u6237<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;source&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;llm_fallback&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;answer&#034;<\/span><span class=\"token punctuation\">:<\/span> llm_ask<span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5173\u952e&#xff1a;\u964d\u7ea7\u65f6\u5fc5\u987b\u8bda\u5b9e\u6807\u6ce8\u6765\u6e90&#xff0c;\u522b\u8ba9\u7528\u6237\u8bef\u4ee5\u4e3a\u770b\u5230\u4e86\u5b9e\u65f6\u6743\u5a01\u6570\u636e\u3002<\/p>\n<hr \/>\n<h4>L6 \u81ea\u6108\u5c42&#xff08;Agent \u72ec\u6709&#xff0c;\u5168\u6587\u6700\u5173\u952e&#xff09;&#xff1a;\u628a\u9519\u8bef\u5582\u56de\u53bb<\/h4>\n<p>\u8fd9\u662f Agent \u533a\u522b\u4e8e\u4f20\u7edf\u7a0b\u5e8f\u7684\u672c\u8d28\u5dee\u5f02\u3002\u4f20\u7edf\u7a0b\u5e8f\u62a5\u9519\u5c31\u505c\u4e86&#xff1b;Agent \u62a5\u9519&#xff0c;\u8981\u628a\u9519\u8bef\u4f5c\u4e3a observation \u56de\u5582\u7ed9 LLM&#xff0c;\u8ba9\u5b83\u81ea\u5df1\u6539\u3002<\/p>\n<p>LangChain \u4e2d\u7684\u5b9e\u73b0\u2014\u2014\u628a\u9519\u8bef\u5305\u88c5\u6210 ToolMessage \u585e\u56de ReAct \u5faa\u73af&#xff1a;<\/p>\n<p>result <span class=\"token operator\">&#061;<\/span> agent_executor<span class=\"token punctuation\">.<\/span>invoke<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;input&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u67e5\u4e00\u4e0b ORD20241020000123 \u8fd9\u4e2a\u8ba2\u5355\u5230\u54ea\u4e86&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string\">&#034;chat_history&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5f53 LLM \u7b2c\u4e00\u6b21\u4f20\u9519&#xff0c;\u5de5\u5177\u8fd4\u56de\u7684\u4e0d\u662f\u5d29\u6e83&#xff0c;\u800c\u662f&#xff1a;<\/p>\n<p>System(observation):<br \/>\n\u5de5\u5177\u8c03\u7528\u5931\u8d25[ORDER_NOT_FOUND]: \u8ba2\u5355\u53f7\u683c\u5f0f\u5e94\u4e3a ORD&#043;15\u4f4d\u6570\u5b57&#xff0c;<br \/>\n\u4f60\u4f20\u5165\u7684\u662f\u7528\u6237\u59d3\u540d&#034;\u5f20\u4e09&#034;\u3002\u8bf7\u4ece\u5bf9\u8bdd\u5386\u53f2\u4e2d\u63d0\u53d6\u6b63\u786e\u7684\u8ba2\u5355\u53f7&#xff0c;<br \/>\n\u5982\u679c\u6ca1\u6709\u5c31\u5411\u7528\u6237\u786e\u8ba4&#xff0c;\u4e0d\u8981\u731c\u6d4b\u3002<\/p>\n<p>\u9519\u8bef\u4fe1\u606f\u91cc\u5fc5\u987b\u5305\u542b\u4e09\u8981\u7d20&#xff0c;LLM \u624d\u80fd\u771f\u6b63\u81ea\u6211\u4fee\u6b63&#xff1a;<\/p>\n<li>\u4f60\u9519\u5728\u54ea&#xff08;\u4f60\u4f20\u5165\u7684\u662f\u59d3\u540d&#xff09;<\/li>\n<li>\u4e0b\u4e00\u6b65\u600e\u4e48\u505a&#xff08;\u4ece\u5bf9\u8bdd\u5386\u53f2\u63d0\u53d6 \/ \u5411\u7528\u6237\u786e\u8ba4&#xff09;<\/li>\n<li>\u7981\u6b62\u884c\u4e3a&#xff08;\u4e0d\u8981\u731c\u6d4b&#xff09;<\/li>\n<p>\u7ecf\u9a8c&#xff1a;\u9519\u8bef\u4fe1\u606f\u5199\u5f97\u8d8a\u597d&#xff0c;\u81ea\u6108\u6210\u529f\u7387\u8d8a\u9ad8\u3002\u8fd9\u672c\u8d28\u4e0a\u662f&#034;\u7ed9 LLM \u5199\u66f4\u597d\u7684 Prompt&#034;\u3002<\/p>\n<hr \/>\n<h4>L7 \u515c\u5e95\u5c42&#xff1a;\u8bda\u5b9e\u5931\u8d25<\/h4>\n<p>\u91cd\u8bd5 3 \u6b21\u3001\u964d\u7ea7\u4e5f\u5931\u8d25\u3001LLM \u4e5f\u6539\u4e0d\u5bf9&#xff1f;\u90a3\u5c31\u653e\u5f03&#xff0c;\u4f46\u4e0d\u8981\u7f16\u7b54\u6848\u3002<\/p>\n<p><span class=\"token keyword\">if<\/span> state<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;attempts&#034;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string\">&#034;messages&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><br \/>\n            AIMessage<span class=\"token punctuation\">(<\/span><br \/>\n                content<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\u6211\u6682\u65f6\u65e0\u6cd5\u67e5\u8be2\u5230\u8fd9\u4e2a\u8ba2\u5355\u7684\u72b6\u6001\u3002&#034;<\/span><br \/>\n                        <span class=\"token string\">&#034;\u53ef\u80fd\u662f\u7cfb\u7edf\u7e41\u5fd9\u6216\u8ba2\u5355\u53f7\u6709\u8bef&#xff0c;&#034;<\/span><br \/>\n                        <span class=\"token string\">&#034;\u9700\u8981\u6211\u5e2e\u4f60\u8f6c\u63a5\u4eba\u5de5\u5ba2\u670d\u5417&#xff1f;&#034;<\/span><br \/>\n            <span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u662f\u4fe1\u4efb\u95ee\u9898&#xff1a;\u4e00\u6b21\u778e\u7f16\u8ba2\u5355\u53f7\u7684\u4ee3\u4ef7&#xff0c;\u8fdc\u5927\u4e8e\u5766\u8bda\u8bf4&#034;\u67e5\u4e0d\u5230&#034;\u3002\u5b81\u53ef\u8f6c\u4eba\u5de5&#xff0c;\u4e0d\u53ef\u7ed9\u5047\u7b54\u6848\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u4e2a\u5b8c\u6574\u53ef\u8dd1\u7684\u4f8b\u5b50<\/h3>\n<p>\u628a L2~L7 \u4e32\u8d77\u6765&#xff0c;\u770b\u4e00\u6b21\u771f\u5b9e\u7684&#034;\u5931\u8d25 \u2192 \u81ea\u6108 \u2192 \u6210\u529f&#034;\u95ed\u73af&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> time<br \/>\n<span class=\"token keyword\">from<\/span> langgraph<span class=\"token punctuation\">.<\/span>graph <span class=\"token keyword\">import<\/span> StateGraph<br \/>\n<span class=\"token keyword\">from<\/span> langchain_core<span class=\"token punctuation\">.<\/span>messages <span class=\"token keyword\">import<\/span> AIMessage<span class=\"token punctuation\">,<\/span> ToolMessage<\/p>\n<p><span class=\"token decorator annotation punctuation\">&#064;tool<\/span><span class=\"token punctuation\">(<\/span>args_schema<span class=\"token operator\">&#061;<\/span>GetOrderInput<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">get_order<\/span><span class=\"token punctuation\">(<\/span>order_id<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token builtin\">dict<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        resp <span class=\"token operator\">&#061;<\/span> requests<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;https:\/\/api.shop.com\/orders\/<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>order_id<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">,<\/span> timeout<span class=\"token operator\">&#061;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        resp<span class=\"token punctuation\">.<\/span>raise_for_status<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> resp<span class=\"token punctuation\">.<\/span>json<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">except<\/span> requests<span class=\"token punctuation\">.<\/span>Timeout<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">raise<\/span> ToolError<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;TIMEOUT&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u8ba2\u5355\u63a5\u53e3\u8d85\u65f6&#034;<\/span><span class=\"token punctuation\">,<\/span> retryable<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">except<\/span> requests<span class=\"token punctuation\">.<\/span>HTTPError <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> e<span class=\"token punctuation\">.<\/span>response<span class=\"token punctuation\">.<\/span>status_code <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">404<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">raise<\/span> ToolError<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;NOT_FOUND&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u8ba2\u5355\u4e0d\u5b58\u5728&#034;<\/span><span class=\"token punctuation\">,<\/span> retryable<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">False<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">raise<\/span> ToolError<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;UPSTREAM&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u4e0a\u6e38\u9519\u8bef: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">,<\/span> retryable<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">call_tool_node<\/span><span class=\"token punctuation\">(<\/span>state<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;LangGraph \u4e2d\u7684\u5de5\u5177\u8c03\u7528\u8282\u70b9&#xff0c;\u5185\u7f6e\u91cd\u8bd5 &#043; \u9519\u8bef\u56de\u5582&#034;&#034;&#034;<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> attempt <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">range<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            result <span class=\"token operator\">&#061;<\/span> get_order<span class=\"token punctuation\">.<\/span>invoke<span class=\"token punctuation\">(<\/span>state<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;tool_input&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;messages&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span>ToolMessage<span class=\"token punctuation\">(<\/span>content<span class=\"token operator\">&#061;<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">(<\/span>result<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">except<\/span> ToolError <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> e<span class=\"token punctuation\">.<\/span>retryable <span class=\"token keyword\">or<\/span> attempt <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token comment\"># \u7ed3\u6784\u5316\u9519\u8bef\u56de\u5582\u7ed9 LLM&#xff0c;\u8ba9\u5b83\u81ea\u5df1\u4fee\u6b63<\/span><br \/>\n                <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;messages&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span>ToolMessage<span class=\"token punctuation\">(<\/span>content<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span><br \/>\n                    <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u5de5\u5177\u8c03\u7528\u5931\u8d25[<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">.<\/span>code<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">]: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">.<\/span>message<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">. &#034;<\/span><\/span><br \/>\n                    <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u8bf7\u4fee\u6b63\u53c2\u6570\u6216\u5411\u7528\u6237\u786e\u8ba4&#xff0c;\u4e0d\u8981\u731c\u6d4b\u3002&#034;<\/span><\/span><br \/>\n                <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">}<\/span><br \/>\n            time<span class=\"token punctuation\">.<\/span>sleep<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span> <span class=\"token operator\">**<\/span> attempt<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;messages&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span>ToolMessage<span class=\"token punctuation\">(<\/span>content<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\u91cd\u8bd5\u8017\u5c3d&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u628a call_tool_node \u63a5\u8fdb StateGraph&#xff0c;\u914d\u4e0a LLM \u51b3\u7b56\u8282\u70b9\u5373\u53ef<\/span><\/p>\n<p>\u8fd0\u884c\u65e5\u5fd7&#xff08;\u4f53\u73b0\u5b8c\u6574\u95ed\u73af&#xff09;&#xff1a;<\/p>\n<p>[1] LLM: \u8c03\u7528 get_order(order_id&#061;&#034;\u5f20\u4e09&#034;)<br \/>\n[2] \u5de5\u5177: [ORDER_NOT_FOUND] \u683c\u5f0f\u5e94\u4e3a ORD&#043;15\u4f4d\u6570\u5b57, \u4f20\u5165\u7684\u662f\u59d3\u540d<br \/>\n[3] LLM: \u91cd\u65b0\u89e3\u6790\u7528\u6237\u95ee\u9898&#8230; \u4ece\u5bf9\u8bdd\u5386\u53f2\u63d0\u53d6\u8ba2\u5355\u53f7 ORD20241020000123<br \/>\n[4] \u5de5\u5177: \u8fd4\u56de\u8ba2\u5355\u72b6\u6001 &#034;\u5df2\u53d1\u8d27, \u9884\u8ba1\u660e\u5929\u5230\u8fbe&#034;<br \/>\n[5] \u5b8c\u6210 \u2705<\/p>\n<p>\u4ece&#034;\u4f20\u9519&#034;\u5230&#034;\u6539\u5bf9&#034;&#xff0c;\u5168\u7a0b\u6ca1\u6709\u4eba\u5de5\u4ecb\u5165\u2014\u2014\u8fd9\u5c31\u662f Agent \u81ea\u6108\u80fd\u529b\u7684\u4ef7\u503c\u3002<\/p>\n<hr \/>\n<h3>\u76d1\u63a7\u4e0e\u53ef\u89c2\u6d4b<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105142453-6aec91b589e43.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5bb9\u9519\u7cfb\u7edf\u4e0d\u505a\u76d1\u63a7&#xff0c;\u7b49\u4e8e\u6ca1\u505a\u3002\u4f60\u65e0\u6cd5\u77e5\u9053&#034;\u81ea\u6108\u5230\u5e95\u6210\u529f\u4e86\u591a\u5c11\u6b21&#034;\u3002<\/p>\n<p>\u5fc5\u987b\u8bb0\u5f55\u6bcf\u6b21\u5de5\u5177\u8c03\u7528\u7684&#xff1a;<\/p>\n<ul>\n<li>tool_name \/ input \/ output<\/li>\n<li>latency&#xff08;\u5ef6\u8fdf&#xff09;<\/li>\n<li>error_code&#xff08;\u9519\u8bef\u7801&#xff09;<\/li>\n<li>attempts&#xff08;\u91cd\u8bd5\u6b21\u6570&#xff09;<\/li>\n<\/ul>\n<p>\u6838\u5fc3\u6307\u6807&#xff1a;<\/p>\n<table>\n<tr>\u6307\u6807\u542b\u4e49\u5f02\u5e38\u4fe1\u53f7<\/tr>\n<tbody>\n<tr>\n<td>\u5de5\u5177\u6210\u529f\u7387<\/td>\n<td>\u8c03\u7528\u6210\u529f\u6bd4\u4f8b<\/td>\n<td>\u7a81\u964d<\/td>\n<\/tr>\n<tr>\n<td>\u91cd\u8bd5\u7387<\/td>\n<td>\u89e6\u53d1\u91cd\u8bd5\u7684\u6bd4\u4f8b<\/td>\n<td>\u6301\u7eed\u5347\u9ad8 \u2192 \u4e0b\u6e38\u4e0d\u7a33<\/td>\n<\/tr>\n<tr>\n<td>\u81ea\u6108\u6210\u529f\u7387<\/td>\n<td>LLM \u6536\u5230\u9519\u8bef\u540e\u662f\u5426\u6539\u5bf9<\/td>\n<td>\u964d\u4f4e \u2192 \u9519\u8bef\u4fe1\u606f\u5199\u5f97\u5dee<\/td>\n<\/tr>\n<tr>\n<td>\u515c\u5e95\u7387<\/td>\n<td>\u6700\u7ec8\u8f6c\u4eba\u5de5\/\u5931\u8d25\u6bd4\u4f8b<\/td>\n<td>\u5347\u9ad8 \u2192 \u9884\u8b66<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u544a\u8b66\u8bef\u533a&#xff1a;\u67d0\u5de5\u5177\u5931\u8d25\u7387\u7a81\u7136 &gt; 20%&#xff0c;\u591a\u534a\u662f\u4e0b\u6e38\u6302\u4e86&#xff0c;\u4e0d\u662f LLM \u53d8\u7b28\u4e86\u3002\u5148\u67e5\u4f9d\u8d56\u670d\u52a1&#xff0c;\u522b\u6025\u7740\u8c03 Prompt\u3002<\/p>\n<p>\u94fe\u8def\u8ffd\u8e2a\u7528 LangSmith \/ Langfuse&#xff0c;\u80fd\u770b\u5230\u5b8c\u6574 ReAct \u8f68\u8ff9\u548c\u6bcf\u6b21\u81ea\u6108\u7684\u6765\u9f99\u53bb\u8109\u3002<\/p>\n<hr \/>\n<h3>\u603b\u7ed3&#xff1a;\u4e00\u5f20\u56fe &#043; \u4e09\u53e5\u8bdd<\/h3>\n<p>\u6838\u5fc3\u4e00\u53e5\u8bdd&#xff1a;<\/p>\n<p>Agent \u7684\u5f02\u5e38\u5904\u7406\u4e0d\u662f try-catch&#xff0c;\u800c\u662f&#034;\u5de5\u7a0b\u5bb9\u9519 &#043; LLM \u81ea\u6108&#034;\u7684\u7ec4\u5408\u62f3\u3002<\/p>\n<p>\u4e09\u539f\u5219&#xff1a;<\/p>\n<li>\u80fd\u5728\u672c\u5730\u62e6\u4f4f\u7684\u9519\u8bef&#xff0c;\u522b\u53d1\u5230\u4e0b\u6e38&#xff08;L1\/L2 \u9884\u9632\u6821\u9a8c&#xff09;<\/li>\n<li>\u80fd\u91cd\u8bd5\u7684\u522b\u62a5\u9519&#xff0c;\u80fd\u964d\u7ea7\u7684\u522b\u786c\u521a&#xff08;L4\/L5&#xff09;<\/li>\n<li>\u80fd\u8ba9 LLM \u81ea\u5df1\u6539\u7684\u522b\u8f6c\u4eba\u5de5&#xff0c;\u6539\u4e0d\u4e86\u5c31\u8bda\u5b9e\u5931\u8d25&#xff08;L6\/L7&#xff09;<\/li>\n<hr \/>\n<h3>\u9644&#xff1a;\u81ea\u67e5\u6e05\u5355&#xff08;\u5efa\u8bae\u6536\u85cf&#xff09;<\/h3>\n<p>\u7ed9\u6b63\u5728\u505a Agent \u7684\u4f60\u9010\u6761\u6253\u52fe&#xff1a;<\/p>\n<ul>\n<li class=\"task-list-item\"> \u6bcf\u4e2a\u5de5\u5177\u7684 description \u662f\u5426\u5199\u6e05\u4e86\u53c2\u6570\u683c\u5f0f\u548c&#034;\u4e0d\u8981\u505a\u4ec0\u4e48&#034;&#xff1f;<\/li>\n<li class=\"task-list-item\"> \u53c2\u6570\u662f\u5426\u6709 Pydantic \u672c\u5730\u6821\u9a8c&#xff0c;\u907f\u514d\u65e0\u6548\u4e0b\u6e38\u8c03\u7528&#xff1f;<\/li>\n<li class=\"task-list-item\"> \u5f02\u5e38\u662f\u5426\u7edf\u4e00\u5305\u88c5&#xff0c;\u5e76\u533a\u5206\u4e86 retryable \/ \u975e retryable&#xff1f;<\/li>\n<li class=\"task-list-item\"> \u91cd\u8bd5\u4e0a\u9650\u662f\u591a\u5c11&#xff1f;\u4f1a\u4e0d\u4f1a\u65e0\u9650\u91cd\u8bd5\u70e7 token&#xff1f;<\/li>\n<li class=\"task-list-item\"> \u662f\u5426\u4e3a\u4e3b\u5de5\u5177\u8bbe\u8ba1\u4e86\u964d\u7ea7\u8def\u5f84&#xff1f;<\/li>\n<li class=\"task-list-item\"> \u9519\u8bef\u4fe1\u606f\u662f\u5426\u56de\u5582\u7ed9\u4e86 LLM&#xff1f;\u662f\u5426\u5305\u542b&#034;\u9519\u5728\u54ea &#043; \u600e\u4e48\u505a&#034;&#xff1f;<\/li>\n<li class=\"task-list-item\"> \u6700\u7ec8\u5931\u8d25\u65f6&#xff0c;Agent \u662f\u8bda\u5b9e\u56de\u7b54&#xff0c;\u8fd8\u662f\u5728\u778e\u7f16&#xff1f;<\/li>\n<li class=\"task-list-item\"> \u662f\u5426\u76d1\u63a7\u4e86\u81ea\u6108\u6210\u529f\u7387\u8fd9\u4e2a\u5173\u952e\u6307\u6807&#xff1f;<\/li>\n<\/ul>\n<hr \/>\n<p>\u628a\u8fd9\u5957\u4e03\u5c42\u9632\u7ebf\u88c5\u8fdb\u4f60\u7684 Agent&#xff0c;\u5b83\u5c31\u4e0d\u518d\u662f&#034;\u8c03\u5de5\u5177\u7684\u8106\u76ae&#034;&#xff0c;\u800c\u662f\u4e00\u4e2a\u80fd\u81ea\u5df1\u722c\u8d77\u6765\u3001\u4e5f\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u8be5\u6c42\u52a9\u7684\u9760\u8c31\u52a9\u624b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u76ee\u5f55\u5f00\u573a&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u5230\u8ba9\u4eba\u5934\u79c3\u7684\u573a\u666f\u5148\u5206\u7c7b&#xff1a;\u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\\&#8221;\u6b7b\u6cd5\\&#8221;\u4e03\u5c42\u9632\u5fa1\u4f53\u7cfbL1 \u9884\u9632\u5c42&#xff1a;\u628a\u5de5\u5177\u8bf4\u660e\u4e66\u5199\u5230 LLM \u4e0d\u72af\u9519L2 \u6821\u9a8c\u5c42&#xff1a;\u53c2\u6570\u95e8\u7981&#xff08;Pydantic&#xff09;L3 \u6355\u83b7\u5c42&#xff1a;\u7edf\u4e00\u5f02\u5e38\u5305\u88c5L4 \u91cd\u8bd5\u5c42&#xff1a;\u53ea\u91cd\u8bd5\\&#8221;\u8be5\u91cd\u8bd5\u7684\\&#8221;L5 \u964d\u7ea7\u5c42&#xff1a;Fallback \u5de5\u5177\u94feL6 \u81ea\u6108\u5c42&#xff08;Agent \u72ec\u6709&#xff0c;\u5168\u6587\u6700\u5173\u952e&amp;#xff0<\/p>\n","protected":false},"author":2,"featured_media":122870,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14034,14033,14032,74,75],"topic":[],"class_list":["post-122874","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-14034","tag-14033","tag-14032","tag-agent","tag-llm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/122874.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u76ee\u5f55\u5f00\u573a&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u5230\u8ba9\u4eba\u5934\u79c3\u7684\u573a\u666f\u5148\u5206\u7c7b&#xff1a;\u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd&quot;\u6b7b\u6cd5&quot;\u4e03\u5c42\u9632\u5fa1\u4f53\u7cfbL1 \u9884\u9632\u5c42&#xff1a;\u628a\u5de5\u5177\u8bf4\u660e\u4e66\u5199\u5230 LLM \u4e0d\u72af\u9519L2 \u6821\u9a8c\u5c42&#xff1a;\u53c2\u6570\u95e8\u7981&#xff08;Pydantic&#xff09;L3 \u6355\u83b7\u5c42&#xff1a;\u7edf\u4e00\u5f02\u5e38\u5305\u88c5L4 \u91cd\u8bd5\u5c42&#xff1a;\u53ea\u91cd\u8bd5&quot;\u8be5\u91cd\u8bd5\u7684&quot;L5 \u964d\u7ea7\u5c42&#xff1a;Fallback \u5de5\u5177\u94feL6 \u81ea\u6108\u5c42&#xff08;Agent \u72ec\u6709&#xff0c;\u5168\u6587\u6700\u5173\u952e&amp;#xff0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/122874.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-05T14:24:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105142452-6aec91b46b76e.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122874.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/122874.html\",\"name\":\"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-05T14:24:54+00:00\",\"dateModified\":\"2026-11-05T14:24:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/122874.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/122874.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122874.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/122874.html","og_locale":"zh_CN","og_type":"article","og_title":"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u76ee\u5f55\u5f00\u573a&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u5230\u8ba9\u4eba\u5934\u79c3\u7684\u573a\u666f\u5148\u5206\u7c7b&#xff1a;\u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\"\u6b7b\u6cd5\"\u4e03\u5c42\u9632\u5fa1\u4f53\u7cfbL1 \u9884\u9632\u5c42&#xff1a;\u628a\u5de5\u5177\u8bf4\u660e\u4e66\u5199\u5230 LLM \u4e0d\u72af\u9519L2 \u6821\u9a8c\u5c42&#xff1a;\u53c2\u6570\u95e8\u7981&#xff08;Pydantic&#xff09;L3 \u6355\u83b7\u5c42&#xff1a;\u7edf\u4e00\u5f02\u5e38\u5305\u88c5L4 \u91cd\u8bd5\u5c42&#xff1a;\u53ea\u91cd\u8bd5\"\u8be5\u91cd\u8bd5\u7684\"L5 \u964d\u7ea7\u5c42&#xff1a;Fallback \u5de5\u5177\u94feL6 \u81ea\u6108\u5c42&#xff08;Agent \u72ec\u6709&#xff0c;\u5168\u6587\u6700\u5173\u952e&amp;#xff0","og_url":"https:\/\/www.wsisp.com\/helps\/122874.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-05T14:24:54+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105142452-6aec91b46b76e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/122874.html","url":"https:\/\/www.wsisp.com\/helps\/122874.html","name":"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-05T14:24:54+00:00","dateModified":"2026-11-05T14:24:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/122874.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/122874.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/122874.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"LLM \u4e0d\u662f\u7a0b\u5e8f\u5458\uff1aAgent \u5de5\u5177\u8c03\u7528\u5931\u8d25\u7684 6 \u79cd\u6b7b\u6cd5\u4e0e 7 \u5c42\u89e3\u836f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=122874"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122874\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/122870"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=122874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=122874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=122874"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=122874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}