{"id":92688,"date":"2026-08-10T22:48:44","date_gmt":"2026-08-10T14:48:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/92688.html"},"modified":"2026-08-10T22:48:44","modified_gmt":"2026-08-10T14:48:44","slug":"ai-agent-%e6%9e%b6%e6%9e%84%e8%ae%be%e8%ae%a1%e4%b8%8e%e5%a4%9a-agent-%e5%8d%8f%e4%bd%9c%e7%b3%bb%e7%bb%9f%e6%90%ad%e5%bb%ba%ef%bc%9a%e5%88%ab%e8%ae%a9%e6%bc%94%e7%a4%ba%e6%95%88%e6%9e%9c%e9%aa%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/92688.html","title":{"rendered":"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60"},"content":{"rendered":"<h2>AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa&#xff1a;\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60<\/h2>\n<h3>1. \u6f14\u793a\u6548\u679c\u4e0e\u751f\u4ea7\u8c03\u8bd5\u7684\u5de5\u7a0b\u9e3f\u6c9f<\/h3>\n<p>\u5728\u591a Agent \u534f\u4f5c\u6392\u67e5\u6570\u636e\u5e93\u6b7b\u9501\u6216\u590d\u6742\u7cfb\u7edf\u6545\u969c\u7684\u6f14\u793a\u573a\u666f\u4e2d&#xff0c;\u6a21\u578b\u901a\u5e38\u80fd\u591f\u987a\u5229\u8f93\u51fa\u6b63\u786e\u7684 SQL \u4f18\u5316\u6307\u4ee4\u4e0e\u8bca\u65ad\u6b65\u9aa4\u3002\u7136\u800c\u5728\u672c\u5730\u5f00\u53d1\u4e0e\u5b9e\u9645\u8c03\u8bd5\u9636\u6bb5&#xff0c;\u76f4\u63a5\u8fd0\u884c\u4ee3\u7801\u6781\u6613\u629b\u51fa KeyError: &#039;tool_calls&#039;\u3001\u63a5\u53e3\u8d85\u65f6\u4ee5\u53ca Agent \u54cd\u5e94\u504f\u79bb\u9884\u671f\u8def\u5f84\u7b49\u786e\u5b9a\u6027\u7f3a\u5931\u95ee\u9898\u3002<\/p>\n<p>\u8fd9\u662f Agent \u7cfb\u7edf\u5de5\u7a0b\u5316\u843d\u5730\u4e2d\u6700\u5e38\u9047\u5230\u7684\u6280\u672f\u74f6\u9888\u3002\u5927\u8bed\u8a00\u6a21\u578b\u672c\u8eab\u5177\u5907\u8f93\u51fa\u968f\u673a\u6027&#xff0c;HTTP \u7f51\u7edc\u8bf7\u6c42\u5b58\u5728\u4e0d\u786e\u5b9a\u6027\u6296\u52a8&#xff0c;\u5f53\u591a\u4e2a Agent \u76f8\u4e92\u7a7f\u63d2\u8c03\u7528\u4e0e\u4f20\u9012\u4e0a\u4e0b\u6587\u65f6&#xff0c;\u82e5\u7f3a\u4e4f\u786e\u5b9a\u6027\u7684\u672c\u5730\u9694\u79bb\u4e0e\u5f55\u5236\u56de\u653e\u673a\u5236&#xff0c;\u5f00\u53d1\u8005\u96be\u4ee5\u5224\u65ad\u662f Prompt \u7ed3\u6784\u8bbe\u8ba1\u5408\u7406\u6027\u4e0d\u8db3&#xff0c;\u8fd8\u662f\u4e0a\u6e38 API \u7f51\u7edc\u6ce2\u52a8&#xff0c;\u4ea6\u6216\u662f Agent \u8fdb\u5165\u4e86\u6b7b\u5faa\u73af\u72b6\u6001\u3002<\/p>\n<p>\u6f14\u793a\u6548\u679c\u65e0\u6cd5\u4ee3\u8868\u751f\u4ea7\u73af\u5883\u7684\u5de5\u7a0b\u7a33\u5b9a\u6027\u3002\u4e3a\u4e86\u5728\u672c\u5730\u5c06 Agent \u7684\u6d4b\u8bd5\u4e0e\u8c03\u8bd5\u6d41\u7a0b\u63a8\u5411\u4e25\u5bc6\u53ef\u9760&#xff0c;\u5fc5\u987b\u91c7\u7528\u786e\u5b9a\u6027\u7684\u5de5\u7a0b\u624b\u6bb5\u53bb\u62e6\u622a\u3001\u6cbb\u7406\u8fd9\u4e9b\u4e0d\u786e\u5b9a\u6027\u56e0\u7d20\u3002<\/p>\n<p>flowchart TD<br \/>\n    A[Agent \u8fd0\u884c\u5165\u53e3] &#8211;&gt; B{\u8fd0\u884c\u6a21\u5f0f\u63a7\u5236}<br \/>\n    B &#8212; Record \u6a21\u5f0f &#8211;&gt; C[\u771f\u5b9e LLM API \/ \u5916\u90e8\u5de5\u5177]<br \/>\n    C &#8211;&gt; D[HTTP \u54cd\u5e94 &amp; Tool Call \u62e6\u622a\u5668]<br \/>\n    D &#8211;&gt; E[(\u4fdd\u5b58 JSON Tape \u5f55\u5236\u6587\u4ef6)]<br \/>\n    B &#8212; Replay \u6a21\u5f0f &#8211;&gt; F[(\u8bfb\u53d6 JSON Tape \u5f55\u5236\u6587\u4ef6)]<br \/>\n    F &#8211;&gt; G[Mock \u54cd\u5e94\u6ce8\u5165\u4e0e\u72b6\u6001\u65ad\u8a00]<br \/>\n    E &#8211;&gt; H[\u8f93\u51fa\u786e\u5b9a\u6027\u8bc4\u6d4b\u62a5\u544a]<br \/>\n    G &#8211;&gt; H<\/p>\n<hr \/>\n<h3>2. \u4e0d\u786e\u5b9a\u6027\u9694\u79bb&#xff1a;\u5f55\u5236\u4e0e\u91cd\u653e&#xff08;VCR&#xff09;\u673a\u5236\u8bbe\u8ba1<\/h3>\n<p>\u6cbb\u7406 Agent \u968f\u673a\u6027\u7684\u6838\u5fc3\u5de5\u7a0b\u601d\u60f3\u5728\u4e8e&#xff1a;\u5728\u672c\u5730\u5f00\u53d1\u8c03\u8bd5\u9636\u6bb5&#xff0c;\u5c06 LLM API \u7684\u8f93\u5165\u8f93\u51fa\u4ee5\u53ca\u5916\u90e8\u5de5\u5177&#xff08;\u5982 Search API\u3001\u6570\u636e\u5e93 Client&#xff09;\u7684\u8fd4\u56de\u7ed3\u679c\u7edf\u4e00\u5e8f\u5217\u5316\u62e6\u622a\u5e76\u5b58\u50a8&#xff0c;\u5f62\u6210\u53ef\u968f\u65f6\u91cd\u653e\u7684\u79bb\u7ebf\u6570\u636e\u78c1\u5e26&#xff08;Tape&#xff09;\u3002<\/p>\n<p>\u5f53\u4fee\u6539 Agent \u5185\u90e8\u7684\u8def\u7531\u8c03\u5ea6\u903b\u8f91\u3001\u63d0\u793a\u8bcd\u5de5\u7a0b\u6216\u72b6\u6001\u673a\u8fc1\u79fb\u6761\u4ef6\u65f6&#xff0c;\u65e0\u9700\u6bcf\u6b21\u90fd\u53d1\u8d77\u771f\u5b9e\u7684\u8fdc\u7a0b\u5927\u6a21\u578b\u63a5\u53e3\u8c03\u7528\u3002\u5728\u91cd\u653e&#xff08;Replay&#xff09;\u6a21\u5f0f\u4e0b\u76f4\u63a5\u52a0\u8f7d\u5148\u524d\u5f55\u5236\u7684\u79bb\u7ebf\u6570\u636e&#xff0c;\u80fd\u591f\u7cbe\u51c6\u6821\u9a8c Agent \u662f\u5426\u6309\u9884\u671f\u9009\u62e9\u7279\u5b9a\u5de5\u5177\u3002\u8fd9\u79cd\u65b9\u5f0f\u6d88\u9664\u4e86\u5bf9\u8fdc\u7a0b API \u8c03\u7528\u7684\u7b49\u5f85\u5ef6\u8fdf\u4e0e Token \u5f00\u9500&#xff0c;\u540c\u65f6\u5c06\u590d\u6742\u7684\u5206\u5e03\u5f0f\u8c03\u7528\u94fe\u6536\u62e2\u4e3a\u786e\u5b9a\u6027\u7684\u672c\u5730\u5355\u5143\u6d4b\u8bd5\u3002<\/p>\n<p>\u5de5\u7a0b\u5b9e\u8df5\u4e2d\u9700\u8981\u6784\u5efa\u4e09\u9053\u9632\u62a4\u5c4f\u853d\u7ebf&#xff1a;<\/p>\n<li>\u6a21\u578b Seed \u4e0e Temperature \u53c2\u6570\u786c\u6027\u6536\u53e3&#xff1a;\u5728\u672c\u5730\u5f00\u53d1\u914d\u7f6e\u4e2d&#xff0c;\u5f3a\u884c\u9501\u5b9a Seed \u503c\u4e0e\u96f6\u6e29\u53c2\u6570&#xff0c;\u6536\u655b\u91c7\u6837\u6982\u7387\u5206\u5e03\u3002<\/li>\n<li>Tool Calling \u534f\u8bae\u5c42\u7f51\u7edc\u62e6\u622a&#xff1a;\u8bb0\u5f55\u5b8c\u6574 Request Hash \u4e0e\u539f\u59cb Response Body&#xff0c;\u907f\u514d HTTP \u72b6\u6001\u7801\u6ce2\u52a8\u6216 Header \u5b57\u6bb5\u53d8\u5316\u5bfc\u81f4\u89e3\u91ca\u5668\u89e3\u6790\u5931\u8d25\u3002<\/li>\n<li>\u72b6\u6001\u673a\u8f6c\u6362\u5feb\u7167\u6821\u9a8c&#xff1a;\u5728 Agent \u5b8c\u6210\u9636\u6bb5\u6027\u4efb\u52a1\u5e76\u4ea4\u63a5\u63a7\u5236\u6743\u65f6&#xff0c;\u81ea\u52a8\u5bfc\u51fa\u5185\u5b58 State \u7684 JSON \u955c\u50cf&#xff0c;\u4f5c\u4e3a\u903b\u8f91\u65ad\u8a00\u7684\u6807\u51c6\u4f9d\u636e\u3002<\/li>\n<hr \/>\n<h3>3. \u751f\u4ea7\u7ea7\u672c\u5730\u811a\u624b\u67b6\u5b9e\u73b0&#xff08;Python&#xff09;<\/h3>\n<p>\u4ee5\u4e0b\u4e3a Agent \u786e\u5b9a\u6027\u5b9e\u9a8c\u811a\u624b\u67b6\u7684\u6838\u5fc3\u5de5\u7a0b\u4ee3\u7801\u3002\u4ee3\u7801\u91c7\u7528 Decorator \u4e0e ContextManager \u8bbe\u8ba1\u6a21\u5f0f&#xff0c;\u5b9e\u73b0 LLM \u4ea4\u4e92\u4e0e Tool \u8c03\u7528\u7684\u81ea\u52a8\u5316\u6355\u83b7\u3001\u5e8f\u5217\u5316\u4e0e\u79bb\u7ebf\u91cd\u653e\u3002<\/p>\n<p>import json<br \/>\nimport hashlib<br \/>\nimport os<br \/>\nfrom typing import Dict, Any, Callable, Optional<br \/>\nfrom functools import wraps<\/p>\n<p>class AgentTapeRunner:<br \/>\n    &#034;&#034;&#034;<br \/>\n    Agent \u786e\u5b9a\u6027\u5b9e\u9a8c\u811a\u624b\u67b6&#xff1a;\u652f\u6301 Record&#xff08;\u5f55\u5236&#xff09;\u4e0e Replay&#xff08;\u91cd\u653e&#xff09;<br \/>\n    &#034;&#034;&#034;<br \/>\n    def __init__(self, tape_path: str, mode: str &#061; &#034;replay&#034;):<br \/>\n        self.tape_path &#061; tape_path<br \/>\n        self.mode &#061; mode.lower()<br \/>\n        self.tape_data: Dict[str, Any] &#061; {}<\/p>\n<p>        if self.mode &#061;&#061; &#034;replay&#034;:<br \/>\n            self._load_tape()<br \/>\n        elif self.mode &#061;&#061; &#034;record&#034;:<br \/>\n            # \u786e\u4fdd\u4fdd\u5b58\u76ee\u5f55\u5b58\u5728<br \/>\n            os.makedirs(os.path.dirname(os.path.abspath(tape_path)), exist_ok&#061;True)<\/p>\n<p>    def _load_tape(self):<br \/>\n        if not os.path.exists(self.tape_path):<br \/>\n            raise FileNotFoundError(f&#034;\u78c1\u5e26\u6587\u4ef6\u4e0d\u5b58\u5728&#xff0c;\u65e0\u6cd5\u91cd\u653e: {self.tape_path}&#034;)<br \/>\n        with open(self.tape_path, &#034;r&#034;, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\n            self.tape_data &#061; json.load(f)<\/p>\n<p>    def save_tape(self):<br \/>\n        if self.mode &#061;&#061; &#034;record&#034;:<br \/>\n            with open(self.tape_path, &#034;w&#034;, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\n                json.dump(self.tape_data, f, indent&#061;2, ensure_ascii&#061;False)<\/p>\n<p>    def _generate_key(self, prompt: str, kwargs: Dict[str, Any]) -&gt; str:<br \/>\n        # \u751f\u6210\u57fa\u4e8e\u8bf7\u6c42\u5185\u5bb9\u7684\u54c8\u5e0c\u6458\u8981<br \/>\n        payload &#061; f&#034;{prompt}:{json.dumps(kwargs, sort_keys&#061;True)}&#034;<br \/>\n        return hashlib.sha256(payload.encode(&#034;utf-8&#034;)).hexdigest()[:16]<\/p>\n<p>    def mock_llm_call(self, real_llm_func: Callable, prompt: str, **kwargs) -&gt; Dict[str, Any]:<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u62e6\u622a LLM \u8c03\u7528\u7684\u5173\u952e\u4ee3\u7406\u51fd\u6570<br \/>\n        &#034;&#034;&#034;<br \/>\n        key &#061; self._generate_key(prompt, kwargs)<\/p>\n<p>        if self.mode &#061;&#061; &#034;replay&#034;:<br \/>\n            if key not in self.tape_data:<br \/>\n                raise KeyError(f&#034;[Replay \u5931\u8d25] \u672a\u5728\u78c1\u5e26\u4e2d\u5339\u914d\u5230\u8f93\u5165\u8bf7\u6c42: key&#061;{key}, prompt&#061;{prompt[:30]}&#8230;&#034;)<br \/>\n            print(f&#034;[Replay] \u547d\u4e2d\u79bb\u7ebf\u78c1\u5e26, key&#061;{key}&#034;)<br \/>\n            return self.tape_data[key]<\/p>\n<p>        elif self.mode &#061;&#061; &#034;record&#034;:<br \/>\n            print(f&#034;[Record] \u53d1\u8d77\u771f\u5b9e LLM \u8bf7\u6c42, key&#061;{key}&#034;)<br \/>\n            # \u5f3a\u5236\u8bbe\u5b9a\u786e\u5b9a\u6027\u53c2\u6570&#xff0c;\u9632\u6b62\u6a21\u578b\u6d6e\u52a8\u8fc7\u5927<br \/>\n            kwargs[&#034;temperature&#034;] &#061; kwargs.get(&#034;temperature&#034;, 0.0)<br \/>\n            kwargs[&#034;seed&#034;] &#061; kwargs.get(&#034;seed&#034;, 42)<\/p>\n<p>            response &#061; real_llm_func(prompt, **kwargs)<br \/>\n            self.tape_data[key] &#061; response<br \/>\n            return response<\/p>\n<p>        else:<br \/>\n            # passthrough \u6a21\u5f0f&#xff1a;\u76f4\u63a5\u900f\u4f20<br \/>\n            return real_llm_func(prompt, **kwargs)<\/p>\n<p># \u4f7f\u7528\u793a\u4f8b\u4e0e Agent \u8c03\u4f18\u65ad\u8a00\u6d4b\u8bd5<br \/>\ndef dummy_real_llm(prompt: str, **kwargs) -&gt; Dict[str, Any]:<br \/>\n    &#034;&#034;&#034;\u6a21\u62df\u771f\u5b9e\u7684\u5916\u90e8 API \u8c03\u7528&#034;&#034;&#034;<br \/>\n    return {<br \/>\n        &#034;status&#034;: &#034;success&#034;,<br \/>\n        &#034;choice&#034;: &#034;execute_sql&#034;,<br \/>\n        &#034;arguments&#034;: {&#034;sql&#034;: &#034;SELECT * FROM locks WHERE state &#061; &#039;BLOCKED&#039;&#034;},<br \/>\n        &#034;tokens_used&#034;: 142<br \/>\n    }<\/p>\n<p>def run_agent_experiment(mode: str, tape_file: str):<br \/>\n    runner &#061; AgentTapeRunner(tape_path&#061;tape_file, mode&#061;mode)<\/p>\n<p>    prompt_input &#061; &#034;\u6570\u636e\u5e93\u54cd\u5e94\u53d8\u6162&#xff0c;\u5e2e\u6211\u67e5\u4e00\u4e0b\u662f\u5426\u6709\u6b7b\u9501\u4e8b\u52a1&#034;<\/p>\n<p>    try:<br \/>\n        result &#061; runner.mock_llm_call(<br \/>\n            real_llm_func&#061;dummy_real_llm,<br \/>\n            prompt&#061;prompt_input,<br \/>\n            model&#061;&#034;gpt-4o&#034;,<br \/>\n            temperature&#061;0.0<br \/>\n        )<\/p>\n<p>        # \u5de5\u7a0b\u65ad\u8a00&#xff1a;\u9a8c\u8bc1\u5de5\u5177\u9009\u62e9\u903b\u8f91<br \/>\n        assert result[&#034;choice&#034;] &#061;&#061; &#034;execute_sql&#034;, f&#034;Agent \u51b3\u7b56\u504f\u79bb\u9884\u671f: {result[&#039;choice&#039;]}&#034;<br \/>\n        assert &#034;BLOCKED&#034; in result[&#034;arguments&#034;][&#034;sql&#034;], &#034;\u751f\u6210 SQL \u7f3a\u5931\u6838\u5fc3\u72b6\u6001\u8fc7\u6ee4\u6761\u4ef6&#034;<\/p>\n<p>        print(&#034;Agent \u6b65\u9aa4\u65ad\u8a00\u5b8c\u5168\u6821\u9a8c\u901a\u8fc7&#xff01;&#034;)<\/p>\n<p>    finally:<br \/>\n        if mode &#061;&#061; &#034;record&#034;:<br \/>\n            runner.save_tape()<br \/>\n            print(f&#034;\u5b9e\u9a8c\u6570\u636e\u5df2\u6301\u4e45\u5316\u5199\u5165\u78c1\u76d8: {tape_file}&#034;)<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    tape_location &#061; &#034;.\/tests\/fixtures\/agent_deadlock_tape.json&#034;<\/p>\n<p>    print(&#034;&#061;&#061;&#061; \u7b2c\u4e00\u6b65&#xff1a;\u8fd0\u884c Record \u6a21\u5f0f&#xff08;\u5f55\u5236&#xff09; &#061;&#061;&#061;&#034;)<br \/>\n    run_agent_experiment(mode&#061;&#034;record&#034;, tape_file&#061;tape_location)<\/p>\n<p>    print(&#034;\\\\n&#061;&#061;&#061; \u7b2c\u4e8c\u6b65&#xff1a;\u8fd0\u884c Replay \u6a21\u5f0f&#xff08;\u65ad\u7f51\u91cd\u653e\u6d4b\u8bd5&#xff09; &#061;&#061;&#061;&#034;)<br \/>\n    run_agent_experiment(mode&#061;&#034;replay&#034;, tape_file&#061;tape_location)<\/p>\n<hr \/>\n<h3>4. \u5173\u952e\u8e29\u5751\u70b9\u4e0e\u5de5\u7a0b\u9632\u5fa1\u673a\u5236<\/h3>\n<p>\u5728\u6784\u5efa\u672c\u5730 Agent \u811a\u624b\u67b6\u7684\u5de5\u7a0b\u5b9e\u8df5\u4e2d&#xff0c;\u5fc5\u987b\u9488\u5bf9\u4ee5\u4e0b\u9690\u853d\u6280\u672f\u70b9\u5efa\u7acb\u9632\u5fa1\u673a\u5236&#xff1a;<\/p>\n<h4>\u52a8\u6001\u53c2\u6570\u8131\u654f\u4e0e\u54c8\u5e0c\u5bf9\u9f50<\/h4>\n<p>\u5927\u90e8\u5206 Agent \u5728\u6784\u9020\u7cfb\u7edf\u63d0\u793a\u8bcd&#xff08;System Prompt&#xff09;\u65f6&#xff0c;\u5e38\u5305\u542b\u5f53\u524d\u65f6\u95f4\u6233&#xff08;\u4f8b\u5982 Current Time: 2026-08-10 10:15:30&#xff09;\u6216\u552f\u4e00\u7684\u94fe\u8def Trace ID\u3002\u82e5\u76f4\u63a5\u5c06\u5305\u542b\u52a8\u6001\u53c2\u6570\u7684\u6587\u672c\u4f20\u5165 Request \u8fdb\u884c Hash \u8ba1\u7b97&#xff0c;\u4f1a\u5bfc\u81f4\u5f55\u5236\u78c1\u5e26\u5728\u8de8\u5929\u6216\u8de8\u6b21\u8fd0\u884c\u91cd\u653e\u65f6\u5168\u90e8\u5931\u6548\u3002\u811a\u624b\u67b6\u5fc5\u987b\u5728\u8ba1\u7b97 Request Key \u4e4b\u524d\u63d2\u5165\u8fc7\u6ee4\u7ba1\u9053&#xff0c;\u901a\u8fc7\u6b63\u5219\u5316\u62b9\u5e73\u52a8\u6001\u65f6\u95f4\u6233\u3001UUID \u53ca\u4e34\u65f6 Token\u3002<\/p>\n<h4>\u5de5\u5177\u5f02\u5e38\u8c03\u7528\u7684\u5e42\u7b49\u6027\u5f55\u5236<\/h4>\n<p>Agent \u7cfb\u7edf\u7684\u6838\u5fc3\u4f18\u52bf\u5728\u4e8e\u9762\u5bf9\u5de5\u5177\u8c03\u7528\u5931\u8d25\u65f6\u7684\u81ea\u52a8\u91cd\u8bd5\u4e0e\u81ea\u6211\u4fee\u6b63\u80fd\u529b&#xff08;Self-Correction&#xff09;\u3002\u79bb\u7ebf\u6d4b\u8bd5\u811a\u624b\u67b6\u4e0d\u4ec5\u9700\u8981\u5f55\u5236\u6210\u529f\u7684 API \u54cd\u5e94&#xff0c;\u8fd8\u5fc5\u987b\u5c06\u5916\u90e8\u5de5\u5177\u629b\u51fa\u7684 ConnectionRefusedError\u3001HTTP 403 \u6216 Timeout \u5b8c\u6574\u4f5c\u4e3a Trace \u8282\u70b9\u6355\u83b7\u5e76\u843d\u76d8\u3002\u82e5\u4ec5\u8bb0\u5f55\u6210\u529f\u54cd\u5e94&#xff0c;\u5f53 Agent \u5728\u5206\u652f\u8def\u5f84\u4e2d\u89e6\u53d1\u5f02\u5e38\u515c\u5e95\u903b\u8f91\u65f6&#xff0c;\u6d4b\u8bd5\u65ad\u8a00\u6d41\u7a0b\u5c06\u76f4\u63a5\u4e2d\u65ad\u5d29\u6e83\u3002<\/p>\n<h4>\u591a Agent \u534f\u540c\u7684\u5168\u5c40\u72b6\u6001\u9694\u79bb<\/h4>\n<p>\u5728\u591a Agent \u534f\u540c\u4f53\u7cfb\u4e2d&#xff0c;\u6bcf\u4e2a Agent \u90fd\u62e5\u6709\u72ec\u7acb\u7684\u4e0a\u4e0b\u6587\u4e2d\u67a2\u3002\u5728\u672c\u5730\u91cd\u653e\u9636\u6bb5&#xff0c;\u82e5\u5168\u5c40\u53d8\u91cf\u6216 Shared Memory \u672a\u5728\u6bcf\u6b21\u5b9e\u9a8c\u8fd0\u884c\u524d\u540e\u6e05\u9664&#xff0c;\u540e\u4e00\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u5c06\u6c61\u67d3\u524d\u4e00\u4e2a\u7528\u4f8b\u7684\u72b6\u6001\u5feb\u7167\u3002\u901a\u8fc7\u5728\u811a\u624b\u67b6\u4e2d\u5f15\u5165\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u4e0e\u9694\u79bb\u6c99\u76d2&#xff0c;\u786e\u4fdd\u6bcf\u4e2a\u5fae\u5b9e\u9a8c\u7684\u6267\u884c\u73af\u5883\u5f7c\u6b64\u72ec\u7acb\u3002<\/p>\n<hr \/>\n<h3>5. \u603b\u7ed3<\/h3>\n<p>\u8c03\u8bd5 Agent \u7cfb\u7edf\u4e0d\u80fd\u4f9d\u8d56\u91cd\u590d\u8fd0\u884c\u8bd5\u9a8c\u7684\u5076\u7136\u6210\u529f\u3002\u5c06\u968f\u673a\u7684 API \u4ea4\u4e92\u6536\u53e3\u81f3\u672c\u5730\u53ef\u63a7\u7684\u78c1\u5e26\u5b58\u50a8\u4f53\u7cfb\u4e2d&#xff0c;\u914d\u5408\u4e25\u683c\u7684 Schema \u68c0\u67e5\u4e0e\u65ad\u8a00\u673a\u5236&#xff0c;\u662f\u63d0\u5347\u591a Agent \u7cfb\u7edf\u9c81\u68d2\u6027\u7684\u6807\u51c6\u5de5\u7a0b\u8def\u5f84\u3002\u5f53\u7cfb\u7edf\u80fd\u591f\u5728\u65ad\u7f51\u9694\u79bb\u73af\u5883\u4e2d&#xff0c;\u4ee5\u6beb\u79d2\u7ea7\u8017\u65f6\u7a33\u5b9a\u901a\u8fc7\u4e0a\u767e\u4e2a\u81ea\u52a8\u5316\u6d4b\u8bd5\u7528\u4f8b\u65f6&#xff0c;\u65b9\u53ef\u5177\u5907\u63a8\u5411\u751f\u4ea7\u73af\u5883\u7684\u6280\u672f\u6761\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa&#xff1a;\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60<br \/>\n1. \u6f14\u793a\u6548\u679c\u4e0e\u751f\u4ea7\u8c03\u8bd5\u7684\u5de5\u7a0b\u9e3f\u6c9f<br \/>\n\u5728\u591a Agent \u534f\u4f5c\u6392\u67e5\u6570\u636e\u5e93\u6b7b\u9501\u6216\u590d\u6742\u7cfb\u7edf\u6545\u969c\u7684\u6f14\u793a\u573a\u666f\u4e2d&#xff0c;\u6a21\u578b\u901a\u5e38\u80fd\u591f\u987a\u5229\u8f93\u51fa\u6b63\u786e\u7684 SQL \u4f18\u5316\u6307\u4ee4\u4e0e\u8bca\u65ad\u6b65\u9aa4\u3002\u7136\u800c\u5728\u672c\u5730\u5f00\u53d1\u4e0e\u5b9e\u9645\u8c03\u8bd5\u9636\u6bb5&#xff0c;\u76f4\u63a5\u8fd0\u884c\u4ee3\u7801\u6781\u6613\u629b\u51fa KeyError: tool_calls\u3001\u63a5\u53e3\u8d85\u65f6\u4ee5\u53ca Agent \u54cd\u5e94\u504f\u79bb\u9884\u671f\u8def\u5f84\u7b49\u786e\u5b9a\u6027\u7f3a\u5931\u95ee\u9898\u3002<br \/>\n\u8fd9\u662f Agent \u7cfb\u7edf\u5de5\u7a0b\u5316\u843d\u5730\u4e2d\u6700\u5e38\u9047\u5230\u7684\u6280\u672f<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[745,746,292,5370],"topic":[],"class_list":["post-92688","post","type-post","status-publish","format-standard","hentry","category-server","tag-go","tag-golang","tag-292","tag-5370"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 - \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\/92688.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa&#xff1a;\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 1. \u6f14\u793a\u6548\u679c\u4e0e\u751f\u4ea7\u8c03\u8bd5\u7684\u5de5\u7a0b\u9e3f\u6c9f \u5728\u591a Agent \u534f\u4f5c\u6392\u67e5\u6570\u636e\u5e93\u6b7b\u9501\u6216\u590d\u6742\u7cfb\u7edf\u6545\u969c\u7684\u6f14\u793a\u573a\u666f\u4e2d&#xff0c;\u6a21\u578b\u901a\u5e38\u80fd\u591f\u987a\u5229\u8f93\u51fa\u6b63\u786e\u7684 SQL \u4f18\u5316\u6307\u4ee4\u4e0e\u8bca\u65ad\u6b65\u9aa4\u3002\u7136\u800c\u5728\u672c\u5730\u5f00\u53d1\u4e0e\u5b9e\u9645\u8c03\u8bd5\u9636\u6bb5&#xff0c;\u76f4\u63a5\u8fd0\u884c\u4ee3\u7801\u6781\u6613\u629b\u51fa KeyError: tool_calls\u3001\u63a5\u53e3\u8d85\u65f6\u4ee5\u53ca Agent \u54cd\u5e94\u504f\u79bb\u9884\u671f\u8def\u5f84\u7b49\u786e\u5b9a\u6027\u7f3a\u5931\u95ee\u9898\u3002 \u8fd9\u662f Agent \u7cfb\u7edf\u5de5\u7a0b\u5316\u843d\u5730\u4e2d\u6700\u5e38\u9047\u5230\u7684\u6280\u672f\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/92688.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-10T14:48:44+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92688.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/92688.html\",\"name\":\"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-10T14:48:44+00:00\",\"dateModified\":\"2026-08-10T14:48:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/92688.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/92688.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92688.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60\"}]},{\"@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":"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 - \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\/92688.html","og_locale":"zh_CN","og_type":"article","og_title":"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa&#xff1a;\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 1. \u6f14\u793a\u6548\u679c\u4e0e\u751f\u4ea7\u8c03\u8bd5\u7684\u5de5\u7a0b\u9e3f\u6c9f \u5728\u591a Agent \u534f\u4f5c\u6392\u67e5\u6570\u636e\u5e93\u6b7b\u9501\u6216\u590d\u6742\u7cfb\u7edf\u6545\u969c\u7684\u6f14\u793a\u573a\u666f\u4e2d&#xff0c;\u6a21\u578b\u901a\u5e38\u80fd\u591f\u987a\u5229\u8f93\u51fa\u6b63\u786e\u7684 SQL \u4f18\u5316\u6307\u4ee4\u4e0e\u8bca\u65ad\u6b65\u9aa4\u3002\u7136\u800c\u5728\u672c\u5730\u5f00\u53d1\u4e0e\u5b9e\u9645\u8c03\u8bd5\u9636\u6bb5&#xff0c;\u76f4\u63a5\u8fd0\u884c\u4ee3\u7801\u6781\u6613\u629b\u51fa KeyError: tool_calls\u3001\u63a5\u53e3\u8d85\u65f6\u4ee5\u53ca Agent \u54cd\u5e94\u504f\u79bb\u9884\u671f\u8def\u5f84\u7b49\u786e\u5b9a\u6027\u7f3a\u5931\u95ee\u9898\u3002 \u8fd9\u662f Agent \u7cfb\u7edf\u5de5\u7a0b\u5316\u843d\u5730\u4e2d\u6700\u5e38\u9047\u5230\u7684\u6280\u672f","og_url":"https:\/\/www.wsisp.com\/helps\/92688.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-10T14:48:44+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/92688.html","url":"https:\/\/www.wsisp.com\/helps\/92688.html","name":"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-10T14:48:44+00:00","dateModified":"2026-08-10T14:48:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/92688.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/92688.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/92688.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"AI Agent \u67b6\u6784\u8bbe\u8ba1\u4e0e\u591a Agent \u534f\u4f5c\u7cfb\u7edf\u642d\u5efa\uff1a\u522b\u8ba9\u6f14\u793a\u6548\u679c\u9a97\u4e86\u4f60"}]},{"@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\/92688","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=92688"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92688\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=92688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=92688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=92688"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=92688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}