{"id":86087,"date":"2026-07-28T04:40:54","date_gmt":"2026-07-27T20:40:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/86087.html"},"modified":"2026-07-28T04:40:54","modified_gmt":"2026-07-27T20:40:54","slug":"agent-%e5%bf%83%e8%b7%b3%e4%b8%8e%e5%81%a5%e5%ba%b7%e6%a3%80%e6%9f%a5%ef%bc%9a%e9%95%bf%e8%bf%9e%e6%8e%a5%e5%9c%ba%e6%99%af%e4%b8%8b%e7%9a%84%e4%bc%9a%e8%af%9d%e7%8a%b6%e6%80%81%e7%9b%91%e6%8e%a7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/86087.html","title":{"rendered":"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7"},"content":{"rendered":"<h2>Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5&#xff1a;\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7<\/h2>\n<p>Agent \u8fde\u7740\u8fde\u7740\u5c31\u6ca1\u4e86\u53cd\u5e94\u2014\u2014\u4f60\u4e0d\u77e5\u9053\u5b83\u662f\u771f\u7684\u5728\u601d\u8003&#xff0c;\u8fd8\u662f\u5df2\u7ecf\u6084\u6084\u6302\u4e86\u3002<\/p>\n<h3>\u4e00\u3001\u573a\u666f\u75db\u70b9<\/h3>\n<p>\u4f60\u7684 Agent \u7cfb\u7edf\u7528 WebSocket \u7ef4\u6301\u957f\u8fde\u63a5&#xff0c;\u7528\u6237\u53d1\u4e00\u6761\u6d88\u606f\u540e Agent \u9700\u8981\u8c03\u7528\u591a\u4e2a\u5de5\u5177&#xff0c;\u8017\u65f6\u53ef\u80fd 10-60 \u79d2\u3002\u95ee\u9898\u6765\u4e86&#xff1a;\u8fd9 60 \u79d2\u91cc&#xff0c;\u7528\u6237\u4e0d\u77e5\u9053 Agent \u662f\u5728\u5904\u7406\u8fd8\u662f\u5df2\u7ecf\u6302\u4e86\u3002\u5982\u679c Agent \u8fdb\u7a0b\u5d29\u6e83&#xff0c;WebSocket \u8fde\u63a5\u4e0d\u4f1a\u81ea\u52a8\u65ad\u5f00\u2014\u2014\u5ba2\u6237\u7aef\u4e00\u76f4\u7b49\u7740&#xff0c;\u7b49\u5230\u8d85\u65f6\u624d\u62a5\u9519&#xff0c;\u4f46\u6b64\u65f6\u7528\u6237\u5df2\u7ecf\u4ee5\u4e3a\u7cfb\u7edf\u5361\u6b7b\u4e86\u3002<\/p>\n<p>\u4f60\u52a0\u4e86\u4e00\u4e2a\u8fdb\u5ea6\u6761&#xff0c;\u6bcf 5 \u79d2\u63a8\u9001\u4e00\u6761&#034;\u8fd8\u5728\u5904\u7406\u4e2d&#034;\u7684\u6d88\u606f\u3002\u4f46 Agent \u771f\u7684\u6302\u4e86\u7684\u65f6\u5019&#xff0c;\u8fdb\u5ea6\u6761\u8fd8\u5728\u8f6c\u2014\u2014\u56e0\u4e3a\u63a8\u9001\u7ebf\u7a0b\u548c Agent \u6267\u884c\u7ebf\u7a0b\u662f\u72ec\u7acb\u7684&#xff0c;Agent \u6302\u4e86\u63a8\u9001\u7ebf\u7a0b\u8fd8\u5728\u8dd1\u3002<\/p>\n<p>\u66f4\u68d8\u624b\u7684\u662f\u4f1a\u8bdd\u6062\u590d\u3002Agent \u5904\u7406\u5230\u7b2c 3 \u6b65\u65f6\u5d29\u6e83\u4e86&#xff0c;\u7528\u6237\u91cd\u8fde\u540e\u4ece\u7b2c 1 \u6b65\u91cd\u65b0\u5f00\u59cb\u2014\u2014\u524d\u4e24\u6b65\u7684\u7ed3\u679c\u5168\u90e8\u4e22\u5931\u3002\u5982\u679c\u662f\u4ed8\u8d39\u573a\u666f&#xff08;\u6bcf\u6b21\u8c03\u7528\u6d88\u8017 token&#xff09;&#xff0c;\u91cd\u590d\u6267\u884c\u7684\u6210\u672c\u76f4\u63a5\u7ffb\u500d\u3002<\/p>\n<p>\u6838\u5fc3\u77db\u76fe&#xff1a;\u957f\u8fde\u63a5\u573a\u666f\u4e0b&#xff0c;Agent \u7684\u5b58\u6d3b\u72b6\u6001\u548c\u5904\u7406\u8fdb\u5ea6\u5fc5\u987b\u88ab\u6301\u7eed\u76d1\u63a7&#xff0c;\u4e0d\u80fd\u9760&#034;\u8fde\u63a5\u8fd8\u5728\u5c31\u4ee5\u4e3a\u8fd8\u6d3b\u7740&#034;\u3002<\/p>\n<h3>\u4e8c\u3001\u5e95\u5c42\u673a\u5236\u4e0e\u539f\u7406\u5256\u6790<\/h3>\n<h4>2.1 \u5fc3\u8df3\u673a\u5236\u7684\u5c42\u6b21<\/h4>\n<h4>2.2 \u5fc3\u8df3\u6570\u636e\u6a21\u578b<\/h4>\n<p>\u8fdb\u7a0b\u5fc3\u8df3\u4e0d\u53ea\u662f&#034;\u6211\u8fd8\u6d3b\u7740&#034;&#xff0c;\u5b83\u5305\u542b\u5904\u7406\u72b6\u6001&#xff1a;<\/p>\n<table>\n<tr>\u5b57\u6bb5\u542b\u4e49\u7528\u9014<\/tr>\n<tbody>\n<tr>\n<td>agent_id<\/td>\n<td>Agent \u5b9e\u4f8b\u6807\u8bc6<\/td>\n<td>\u5173\u8054\u4f1a\u8bdd\u4e0e\u5b9e\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>session_id<\/td>\n<td>\u4f1a\u8bdd\u6807\u8bc6<\/td>\n<td>\u6062\u590d\u4f1a\u8bdd\u65f6\u4f7f\u7528<\/td>\n<\/tr>\n<tr>\n<td>status<\/td>\n<td>idle\/processing\/error<\/td>\n<td>\u533a\u5206\u72b6\u6001<\/td>\n<\/tr>\n<tr>\n<td>current_step<\/td>\n<td>\u5f53\u524d\u6267\u884c\u6b65\u9aa4<\/td>\n<td>\u8fdb\u5ea6\u8ffd\u8e2a<\/td>\n<\/tr>\n<tr>\n<td>total_steps<\/td>\n<td>\u603b\u6b65\u9aa4\u6570<\/td>\n<td>\u8fdb\u5ea6\u767e\u5206\u6bd4\u8ba1\u7b97<\/td>\n<\/tr>\n<tr>\n<td>cpu_percent<\/td>\n<td>CPU \u4f7f\u7528\u7387<\/td>\n<td>\u8d44\u6e90\u76d1\u63a7<\/td>\n<\/tr>\n<tr>\n<td>memory_mb<\/td>\n<td>\u5185\u5b58\u5360\u7528<\/td>\n<td>\u8d44\u6e90\u76d1\u63a7<\/td>\n<\/tr>\n<tr>\n<td>last_tool_call<\/td>\n<td>\u6700\u8fd1\u4e00\u6b21\u5de5\u5177\u8c03\u7528\u4fe1\u606f<\/td>\n<td>\u5361\u4f4f\u5b9a\u4f4d<\/td>\n<\/tr>\n<tr>\n<td>timestamp<\/td>\n<td>\u5fc3\u8df3\u65f6\u95f4\u6233<\/td>\n<td>\u5224\u65ad\u662f\u5426\u8fc7\u671f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.3 \u5065\u5eb7\u68c0\u67e5\u7684\u5224\u5b9a\u903b\u8f91<\/h4>\n<p>\u5065\u5eb7\u5224\u5b9a\u4e0d\u662f\u7b80\u5355\u7684&#034;\u5fc3\u8df3\u5728\u5c31\u5065\u5eb7&#034;\u3002\u9700\u8981\u6839\u636e\u5fc3\u8df3\u95f4\u9694\u548c\u4e1a\u52a1\u72b6\u6001\u7efc\u5408\u5224\u65ad&#xff1a;<\/p>\n<ul>\n<li>\u5065\u5eb7&#xff1a;\u5fc3\u8df3\u95f4\u9694 &lt; \u9884\u671f\u95f4\u9694 \u00d7 2&#xff0c;status \u4e0d\u662f error<\/li>\n<li>\u4e9a\u5065\u5eb7&#xff1a;\u5fc3\u8df3\u95f4\u9694 &gt; \u9884\u671f\u95f4\u9694 \u00d7 2 \u4f46 &lt; \u9884\u671f\u95f4\u9694 \u00d7 5&#xff0c;status \u662f processing \u4f46 current_step \u957f\u65f6\u95f4\u4e0d\u53d8<\/li>\n<li>\u4e0d\u5065\u5eb7&#xff1a;\u5fc3\u8df3\u95f4\u9694 &gt; \u9884\u671f\u95f4\u9694 \u00d7 5&#xff0c;\u6216 status \u662f error&#xff0c;\u6216\u8fde\u7eed 3 \u6b21\u5fc3\u8df3\u7f3a\u5931<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u751f\u4ea7\u7ea7\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<h4>3.1 Agent \u5fc3\u8df3\u4e0a\u62a5\u5668<\/h4>\n<p>\/\/ agent-heartbeat.ts \u2014\u2014 Agent \u8fdb\u7a0b\u5fc3\u8df3\u4e0a\u62a5\u5668<br \/>\nimport { EventEmitter } from &#039;events&#039;;<\/p>\n<p>export enum AgentStatus {<br \/>\n  IDLE &#061; &#039;idle&#039;,        \/\/ \u7b49\u5f85\u7528\u6237\u8f93\u5165<br \/>\n  PROCESSING &#061; &#039;processing&#039;,  \/\/ \u6b63\u5728\u5904\u7406\u7528\u6237\u8bf7\u6c42<br \/>\n  ERROR &#061; &#039;error&#039;,      \/\/ \u5904\u7406\u51fa\u9519&#xff0c;\u7b49\u5f85\u6062\u590d<br \/>\n  TERMINATING &#061; &#039;terminating&#039;,  \/\/ \u6b63\u5728\u4f18\u96c5\u5173\u95ed<br \/>\n}<\/p>\n<p>export interface HeartbeatPayload {<br \/>\n  agent_id: string;<br \/>\n  session_id: string;<br \/>\n  status: AgentStatus;<br \/>\n  current_step: number;<br \/>\n  total_steps: number;<br \/>\n  cpu_percent: number;<br \/>\n  memory_mb: number;<br \/>\n  last_tool_call: string | null;<br \/>\n  timestamp: number;  \/\/ Unix \u65f6\u95f4\u6233&#xff08;\u6beb\u79d2&#xff09;<br \/>\n}<\/p>\n<p>export class AgentHeartbeat extends EventEmitter {<br \/>\n  private agentId: string;<br \/>\n  private sessionId: string;<br \/>\n  private status: AgentStatus &#061; AgentStatus.IDLE;<br \/>\n  private currentStep: number &#061; 0;<br \/>\n  private totalSteps: number &#061; 0;<br \/>\n  private lastToolCall: string | null &#061; null;<\/p>\n<p>  private intervalMs: number;  \/\/ \u5fc3\u8df3\u95f4\u9694<br \/>\n  private maxMissedHeartbeats: number;  \/\/ \u5141\u8bb8\u7f3a\u5931\u7684\u6700\u5927\u5fc3\u8df3\u6570<br \/>\n  private heartbeatTimer: NodeJS.Timeout | null &#061; null;<\/p>\n<p>  \/\/ \u5fc3\u8df3\u53d1\u9001\u901a\u9053&#xff1a;WebSocket \/ HTTP \/ \u6d88\u606f\u961f\u5217<br \/>\n  private sender: (payload: HeartbeatPayload) &#061;&gt; Promise&lt;void&gt;;<\/p>\n<p>  constructor(<br \/>\n    agentId: string,<br \/>\n    sessionId: string,<br \/>\n    intervalMs: number &#061; 5000,  \/\/ \u9ed8\u8ba4 5 \u79d2\u5fc3\u8df3\u95f4\u9694<br \/>\n    maxMissedHeartbeats: number &#061; 3,<br \/>\n    sender: (payload: HeartbeatPayload) &#061;&gt; Promise&lt;void&gt;<br \/>\n  ) {<br \/>\n    super();<br \/>\n    this.agentId &#061; agentId;<br \/>\n    this.sessionId &#061; sessionId;<br \/>\n    this.intervalMs &#061; intervalMs;<br \/>\n    this.maxMissedHeartbeats &#061; maxMissedHeartbeats;<br \/>\n    this.sender &#061; sender;<br \/>\n  }<\/p>\n<p>  \/** \u542f\u52a8\u5fc3\u8df3\u5faa\u73af&#xff1a;\u5b9a\u65f6\u4e0a\u62a5\u72b6\u6001 *\/<br \/>\n  start(): void {<br \/>\n    if (this.heartbeatTimer) return;  \/\/ \u5df2\u542f\u52a8\u5219\u4e0d\u91cd\u590d\u542f\u52a8<\/p>\n<p>    \/\/ \u5b9a\u65f6\u53d1\u9001\u5fc3\u8df3&#xff1a;intervalMs \u95f4\u9694<br \/>\n    \/\/ \u5fc3\u8df3\u662f&#034;\u63a8&#034;\u6a21\u5f0f&#xff0c;\u4e0d\u662f&#034;\u62c9&#034;\u6a21\u5f0f\u2014\u2014\u670d\u52a1\u7aef\u4e0d\u9700\u8981\u8f6e\u8be2\u68c0\u67e5 Agent \u72b6\u6001<br \/>\n    this.heartbeatTimer &#061; setInterval(() &#061;&gt; {<br \/>\n      this.sendHeartbeat();<br \/>\n    }, this.intervalMs);<\/p>\n<p>    \/\/ \u7acb\u5373\u53d1\u9001\u4e00\u6b21\u5fc3\u8df3&#xff1a;\u542f\u52a8\u65f6\u8ba9\u670d\u52a1\u7aef\u77e5\u9053 Agent \u5df2\u4e0a\u7ebf<br \/>\n    this.sendHeartbeat();<br \/>\n  }<\/p>\n<p>  \/** \u505c\u6b62\u5fc3\u8df3\u5faa\u73af&#xff1a;\u4f18\u96c5\u5173\u95ed\u524d\u8c03\u7528 *\/<br \/>\n  stop(): void {<br \/>\n    if (this.heartbeatTimer) {<br \/>\n      clearInterval(this.heartbeatTimer);<br \/>\n      this.heartbeatTimer &#061; null;<br \/>\n    }<\/p>\n<p>    \/\/ \u53d1\u9001\u6700\u7ec8\u5fc3\u8df3&#xff1a;\u6807\u8bb0\u4e3a terminating&#xff0c;\u670d\u52a1\u7aef\u77e5\u9053 Agent \u6b63\u5728\u5173\u95ed<br \/>\n    this.status &#061; AgentStatus.TERMINATING;<br \/>\n    this.sendHeartbeat();<br \/>\n  }<\/p>\n<p>  \/** \u66f4\u65b0\u5904\u7406\u72b6\u6001&#xff1a;Agent \u6bcf\u5b8c\u6210\u4e00\u6b65\u8c03\u7528\u6b64\u65b9\u6cd5 *\/<br \/>\n  updateProgress(currentStep: number, totalSteps: number, toolCall: string): void {<br \/>\n    this.currentStep &#061; currentStep;<br \/>\n    this.totalSteps &#061; totalSteps;<br \/>\n    this.lastToolCall &#061; toolCall;<br \/>\n    this.status &#061; AgentStatus.PROCESSING;<\/p>\n<p>    \/\/ \u72b6\u6001\u53d8\u5316\u65f6\u7acb\u5373\u53d1\u9001\u4e00\u6b21\u5fc3\u8df3&#xff08;\u4e0d\u7b49\u5b9a\u65f6\u5668&#xff09;<br \/>\n    \/\/ \u7528\u6237\u5728\u7b49\u5f85\u7ed3\u679c&#xff0c;\u72b6\u6001\u53d8\u5316\u5e94\u8be5\u7b2c\u4e00\u65f6\u95f4\u544a\u77e5\u670d\u52a1\u7aef<br \/>\n    this.sendHeartbeat();<br \/>\n  }<\/p>\n<p>  \/** \u6807\u8bb0\u9519\u8bef\u72b6\u6001 *\/<br \/>\n  markError(): void {<br \/>\n    this.status &#061; AgentStatus.ERROR;<br \/>\n    this.sendHeartbeat();<br \/>\n  }<\/p>\n<p>  \/** \u6807\u8bb0\u7a7a\u95f2\u72b6\u6001 *\/<br \/>\n  markIdle(): void {<br \/>\n    this.status &#061; AgentStatus.IDLE;<br \/>\n    this.currentStep &#061; 0;<br \/>\n    this.totalSteps &#061; 0;<br \/>\n    this.lastToolCall &#061; null;<br \/>\n    this.sendHeartbeat();<br \/>\n  }<\/p>\n<p>  \/** \u53d1\u9001\u5fc3\u8df3&#xff1a;\u7ec4\u88c5 payload \u5e76\u8c03\u7528 sender *\/<br \/>\n  private async sendHeartbeat(): void {<br \/>\n    const payload: HeartbeatPayload &#061; {<br \/>\n      agent_id: this.agentId,<br \/>\n      session_id: this.sessionId,<br \/>\n      status: this.status,<br \/>\n      current_step: this.currentStep,<br \/>\n      total_steps: this.totalSteps,<br \/>\n      cpu_percent: this.getCpuUsage(),<br \/>\n      memory_mb: this.getMemoryUsage(),<br \/>\n      last_tool_call: this.lastToolCall,<br \/>\n      timestamp: Date.now(),<br \/>\n    };<\/p>\n<p>    try {<br \/>\n      await this.sender(payload);<br \/>\n      this.emit(&#039;heartbeat:sent&#039;, payload);<br \/>\n    } catch (err) {<br \/>\n      \/\/ \u5fc3\u8df3\u53d1\u9001\u5931\u8d25&#xff1a;\u4e0d\u4e2d\u65ad Agent \u5904\u7406\u6d41\u7a0b<br \/>\n      \/\/ \u5fc3\u8df3\u662f\u8f85\u52a9\u529f\u80fd&#xff0c;\u6838\u5fc3\u4e1a\u52a1\u4e0d\u80fd\u56e0\u4e3a\u5fc3\u8df3\u901a\u9053\u6545\u969c\u800c\u505c\u6b62<br \/>\n      this.emit(&#039;heartbeat:failed&#039;, { error: err, payload });<br \/>\n    }<br \/>\n  }<\/p>\n<p>  \/** \u83b7\u53d6 CPU \u4f7f\u7528\u7387&#xff1a;\u7b80\u5316\u5b9e\u73b0&#xff0c;\u751f\u4ea7\u73af\u5883\u7528 process.cpuUsage() *\/<br \/>\n  private getCpuUsage(): number {<br \/>\n    \/\/ Node.js \u7684 process.cpuUsage() \u8fd4\u56de\u5fae\u79d2\u7ea7\u7684 CPU \u65f6\u95f4<br \/>\n    const usage &#061; process.cpuUsage();<br \/>\n    const totalUsec &#061; usage.user &#043; usage.system;<br \/>\n    \/\/ \u8f6c\u6362\u4e3a\u767e\u5206\u6bd4&#xff08;\u8fd1\u4f3c\u503c&#xff0c;\u9700\u8981\u91c7\u6837\u95f4\u9694\u624d\u80fd\u7cbe\u786e\u8ba1\u7b97&#xff09;<br \/>\n    return Math.min(totalUsec \/ 1000 \/ this.intervalMs, 100);<br \/>\n  }<\/p>\n<p>  \/** \u83b7\u53d6\u5185\u5b58\u4f7f\u7528\u91cf *\/<br \/>\n  private getMemoryUsage(): number {<br \/>\n    return process.memoryUsage().heapUsed \/ 1024 \/ 1024;  \/\/ MB<br \/>\n  }<br \/>\n}<\/p>\n<h4>3.2 \u670d\u52a1\u7aef\u5065\u5eb7\u68c0\u67e5\u76d1\u63a7\u5668<\/h4>\n<p>\/\/ health-monitor.ts \u2014\u2014 \u670d\u52a1\u7aef Agent \u5065\u5eb7\u68c0\u67e5\u76d1\u63a7\u5668<br \/>\n\/\/ \u76d1\u63a7\u6240\u6709 Agent \u5b9e\u4f8b\u7684\u5fc3\u8df3&#xff0c;\u5224\u65ad\u5065\u5eb7\u72b6\u6001&#xff0c;\u89e6\u53d1\u544a\u8b66\u548c\u4f1a\u8bdd\u6062\u590d<\/p>\n<p>export enum HealthStatus {<br \/>\n  HEALTHY &#061; &#039;healthy&#039;,<br \/>\n  DEGRADED &#061; &#039;degraded&#039;,<br \/>\n  UNHEALTHY &#061; &#039;unhealthy&#039;,<br \/>\n  DEAD &#061; &#039;dead&#039;,<br \/>\n}<\/p>\n<p>interface AgentHealthRecord {<br \/>\n  agentId: string;<br \/>\n  sessionId: string;<br \/>\n  lastHeartbeat: HeartbeatPayload;<br \/>\n  lastHeartbeatTime: number;<br \/>\n  missedHeartbeats: number;<br \/>\n  healthStatus: HealthStatus;<br \/>\n  \/\/ \u505c\u6ede\u68c0\u6d4b&#xff1a;current_step \u8fde\u7eed N \u6b21\u5fc3\u8df3\u672a\u53d8\u5316<br \/>\n  stagnantCount: number;<br \/>\n}<\/p>\n<p>export class AgentHealthMonitor extends EventEmitter {<br \/>\n  private agents: Map&lt;string, AgentHealthRecord&gt; &#061; new Map();<br \/>\n  private intervalMs: number;<br \/>\n  private maxMissed: number;<br \/>\n  private stagnantThreshold: number;  \/\/ \u5fc3\u8df3\u505c\u6ede\u9608\u503c&#xff1a;step \u4e0d\u53d8\u7684\u6b21\u6570<br \/>\n  private checkTimer: NodeJS.Timeout | null &#061; null;<\/p>\n<p>  constructor(<br \/>\n    intervalMs: number &#061; 10000,  \/\/ \u6bcf 10 \u79d2\u68c0\u67e5\u4e00\u6b21\u6240\u6709 Agent<br \/>\n    maxMissed: number &#061; 3,<br \/>\n    stagnantThreshold: number &#061; 5  \/\/ 5 \u6b21\u5fc3\u8df3 step \u4e0d\u53d8\u5224\u5b9a\u4e3a\u505c\u6ede<br \/>\n  ) {<br \/>\n    super();<br \/>\n    this.intervalMs &#061; intervalMs;<br \/>\n    this.maxMissed &#061; maxMissed;<br \/>\n    this.stagnantThreshold &#061; stagnantThreshold;<br \/>\n  }<\/p>\n<p>  \/** \u63a5\u6536 Agent \u5fc3\u8df3&#xff1a;\u66f4\u65b0\u5065\u5eb7\u8bb0\u5f55 *\/<br \/>\n  receiveHeartbeat(payload: HeartbeatPayload): void {<br \/>\n    const existing &#061; this.agents.get(payload.agent_id);<\/p>\n<p>    if (existing) {<br \/>\n      \/\/ \u68c0\u67e5 current_step \u662f\u5426\u53d8\u5316&#xff1a;\u505c\u6ede\u68c0\u6d4b<br \/>\n      if (payload.current_step &#061;&#061;&#061; existing.lastHeartbeat.current_step<br \/>\n          &amp;&amp; payload.status &#061;&#061;&#061; AgentStatus.PROCESSING) {<br \/>\n        existing.stagnantCount&#043;&#043;;<br \/>\n      } else {<br \/>\n        existing.stagnantCount &#061; 0;<br \/>\n      }<\/p>\n<p>      \/\/ \u66f4\u65b0\u8bb0\u5f55<br \/>\n      existing.lastHeartbeat &#061; payload;<br \/>\n      existing.lastHeartbeatTime &#061; payload.timestamp;<br \/>\n      existing.missedHeartbeats &#061; 0;<\/p>\n<p>      \/\/ \u91cd\u65b0\u8bc4\u4f30\u5065\u5eb7\u72b6\u6001<br \/>\n      this.evaluateHealth(existing);<br \/>\n    } else {<br \/>\n      \/\/ \u65b0 Agent \u4e0a\u7ebf&#xff1a;\u521d\u59cb\u5316\u5065\u5eb7\u8bb0\u5f55<br \/>\n      this.agents.set(payload.agent_id, {<br \/>\n        agentId: payload.agent_id,<br \/>\n        sessionId: payload.session_id,<br \/>\n        lastHeartbeat: payload,<br \/>\n        lastHeartbeatTime: payload.timestamp,<br \/>\n        missedHeartbeats: 0,<br \/>\n        healthStatus: HealthStatus.HEALTHY,<br \/>\n        stagnantCount: 0,<br \/>\n      });<br \/>\n      this.emit(&#039;agent:registered&#039;, { agentId: payload.agent_id });<br \/>\n    }<br \/>\n  }<\/p>\n<p>  \/** \u542f\u52a8\u5065\u5eb7\u68c0\u67e5\u5faa\u73af *\/<br \/>\n  start(): void {<br \/>\n    this.checkTimer &#061; setInterval(() &#061;&gt; {<br \/>\n      this.checkAllAgents();<br \/>\n    }, this.intervalMs);<br \/>\n  }<\/p>\n<p>  \/** \u68c0\u67e5\u6240\u6709 Agent \u7684\u5065\u5eb7\u72b6\u6001 *\/<br \/>\n  private checkAllAgents(): void {<br \/>\n    const now &#061; Date.now();<br \/>\n    const expectedInterval &#061; 5000;  \/\/ Agent \u5fc3\u8df3\u95f4\u9694<\/p>\n<p>    for (const [agentId, record] of this.agents) {<br \/>\n      const elapsed &#061; now &#8211; record.lastHeartbeatTime;<\/p>\n<p>      \/\/ \u5fc3\u8df3\u7f3a\u5931\u68c0\u6d4b&#xff1a;\u8d85\u8fc7\u9884\u671f\u95f4\u9694\u5219\u8ba1\u6570 &#043;1<br \/>\n      if (elapsed &gt; expectedInterval * 2) {<br \/>\n        record.missedHeartbeats&#043;&#043;;<br \/>\n      }<\/p>\n<p>      \/\/ \u505c\u6ede\u68c0\u6d4b&#xff1a;step \u4e0d\u53d8\u7684\u6b21\u6570\u8d85\u8fc7\u9608\u503c<br \/>\n      if (record.stagnantCount &gt;&#061; this.stagnantThreshold) {<br \/>\n        \/\/ \u5de5\u5177\u8c03\u7528\u5361\u4f4f&#xff1a;Agent \u8fd8\u6d3b\u7740\u4f46\u5904\u7406\u505c\u6ede<br \/>\n        this.emit(&#039;agent:stagnant&#039;, {<br \/>\n          agentId,<br \/>\n          sessionId: record.sessionId,<br \/>\n          currentStep: record.lastHeartbeat.current_step,<br \/>\n          lastToolCall: record.lastHeartbeat.last_tool_call,<br \/>\n        });<br \/>\n      }<\/p>\n<p>      \/\/ \u91cd\u65b0\u8bc4\u4f30\u5065\u5eb7\u72b6\u6001<br \/>\n      this.evaluateHealth(record);<\/p>\n<p>      \/\/ \u4e0d\u5065\u5eb7\u6216\u6b7b\u4ea1&#xff1a;\u89e6\u53d1\u544a\u8b66<br \/>\n      if (record.healthStatus &#061;&#061;&#061; HealthStatus.UNHEALTHY) {<br \/>\n        this.emit(&#039;agent:unhealthy&#039;, {<br \/>\n          agentId,<br \/>\n          sessionId: record.sessionId,<br \/>\n          missedHeartbeats: record.missedHeartbeats,<br \/>\n        });<br \/>\n      }<\/p>\n<p>      if (record.healthStatus &#061;&#061;&#061; HealthStatus.DEAD) {<br \/>\n        this.emit(&#039;agent:dead&#039;, {<br \/>\n          agentId,<br \/>\n          sessionId: record.sessionId,<br \/>\n        });<\/p>\n<p>        \/\/ \u6b7b\u4ea1 Agent \u4ece\u76d1\u63a7\u5217\u8868\u79fb\u9664&#xff1a;\u4e0d\u518d\u7b49\u5f85\u5fc3\u8df3<br \/>\n        \/\/ \u4f46\u4f1a\u8bdd\u72b6\u6001\u4fdd\u7559&#xff0c;\u7528\u4e8e\u540e\u7eed\u6062\u590d<br \/>\n        this.agents.delete(agentId);<br \/>\n      }<br \/>\n    }<br \/>\n  }<\/p>\n<p>  \/** \u8bc4\u4f30\u5355\u4e2a Agent \u7684\u5065\u5eb7\u72b6\u6001 *\/<br \/>\n  private evaluateHealth(record: AgentHealthRecord): void {<br \/>\n    const previousStatus &#061; record.healthStatus;<\/p>\n<p>    if (record.missedHeartbeats &gt;&#061; this.maxMissed * 2) {<br \/>\n      \/\/ \u8fde\u7eed\u7f3a\u5931\u8d85\u8fc7 2 \u500d\u9608\u503c&#xff1a;\u5224\u5b9a\u6b7b\u4ea1<br \/>\n      record.healthStatus &#061; HealthStatus.DEAD;<br \/>\n    } else if (record.missedHeartbeats &gt;&#061; this.maxMissed) {<br \/>\n      \/\/ \u8fde\u7eed\u7f3a\u5931\u8d85\u8fc7\u9608\u503c&#xff1a;\u5224\u5b9a\u4e0d\u5065\u5eb7<br \/>\n      record.healthStatus &#061; HealthStatus.UNHEALTHY;<br \/>\n    } else if (record.missedHeartbeats &gt; 0 || record.stagnantCount &gt;&#061; this.stagnantThreshold) {<br \/>\n      \/\/ \u6709\u7f3a\u5931\u4f46\u672a\u8d85\u9608\u503c&#xff0c;\u6216\u5904\u7406\u505c\u6ede&#xff1a;\u4e9a\u5065\u5eb7<br \/>\n      record.healthStatus &#061; HealthStatus.DEGRADED;<br \/>\n    } else {<br \/>\n      \/\/ \u6b63\u5e38\u5fc3\u8df3\u4e14\u5904\u7406\u63a8\u8fdb\u4e2d&#xff1a;\u5065\u5eb7<br \/>\n      record.healthStatus &#061; HealthStatus.HEALTHY;<br \/>\n    }<\/p>\n<p>    \/\/ \u72b6\u6001\u53d8\u5316\u65f6\u53d1\u51fa\u4e8b\u4ef6&#xff1a;\u5916\u90e8\u7cfb\u7edf\u53ef\u4ee5\u8ba2\u9605\u505a\u81ea\u52a8\u6062\u590d<br \/>\n    if (previousStatus !&#061;&#061; record.healthStatus) {<br \/>\n      this.emit(&#039;health:changed&#039;, {<br \/>\n        agentId: record.agentId,<br \/>\n        from: previousStatus,<br \/>\n        to: record.healthStatus,<br \/>\n      });<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<h4>3.3 \u4f1a\u8bdd\u6062\u590d\u4e0e\u65ad\u70b9\u7eed\u4f20<\/h4>\n<p># session_recovery.py \u2014\u2014 Agent \u5d29\u6e83\u540e\u7684\u4f1a\u8bdd\u6062\u590d\u4e0e\u65ad\u70b9\u7eed\u4f20<br \/>\nimport json<br \/>\nimport logging<br \/>\nimport time<br \/>\nfrom datetime import datetime<\/p>\n<p>logger &#061; logging.getLogger(&#039;session-recovery&#039;)<\/p>\n<p>class SessionRecoveryManager:<br \/>\n    &#034;&#034;&#034;\u4f1a\u8bdd\u6062\u590d\u7ba1\u7406\u5668&#xff1a;Agent \u5d29\u6e83\u540e\u4ece\u65ad\u70b9\u7ee7\u7eed\u5904\u7406&#034;&#034;&#034;<\/p>\n<p>    def __init__(self, storage_client, heartbeat_monitor):<br \/>\n        self.storage &#061; storage_client<br \/>\n        self.monitor &#061; heartbeat_monitor<\/p>\n<p>    def save_checkpoint(self, session_id: str, step_index: int, step_results: dict):<br \/>\n        &#034;&#034;&#034;\u4fdd\u5b58\u68c0\u67e5\u70b9&#xff1a;\u6bcf\u5b8c\u6210\u4e00\u6b65\u5c31\u4fdd\u5b58&#xff0c;\u5d29\u6e83\u540e\u4ece\u68c0\u67e5\u70b9\u6062\u590d&#034;&#034;&#034;<br \/>\n        checkpoint &#061; {<br \/>\n            &#039;session_id&#039;: session_id,<br \/>\n            &#039;step_index&#039;: step_index,<br \/>\n            &#039;step_results&#039;: step_results,<br \/>\n            &#039;timestamp&#039;: datetime.utcnow().isoformat(),<br \/>\n        }<br \/>\n        # \u68c0\u67e5\u70b9\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8&#xff1a;\u6bd4\u6570\u636e\u5e93\u66f4\u5feb&#xff0c;\u4e14\u4e0d\u5f71\u54cd\u4e1a\u52a1\u8868<br \/>\n        key &#061; f&#034;checkpoints\/{session_id}\/step_{step_index}.json&#034;<br \/>\n        self.storage.put(key, json.dumps(checkpoint))<\/p>\n<p>    def recover_session(self, session_id: str) -&gt; dict:<br \/>\n        &#034;&#034;&#034;\u4ece\u6700\u65b0\u68c0\u67e5\u70b9\u6062\u590d\u4f1a\u8bdd&#034;&#034;&#034;<br \/>\n        # \u67e5\u627e\u8be5\u4f1a\u8bdd\u7684\u6240\u6709\u68c0\u67e5\u70b9&#xff0c;\u53d6\u6700\u65b0\u7684<br \/>\n        pattern &#061; f&#034;checkpoints\/{session_id}\/step_*.json&#034;<br \/>\n        checkpoints &#061; self.storage.list(pattern)<\/p>\n<p>        if not checkpoints:<br \/>\n            logger.warning(f&#034;No checkpoints found for session {session_id}&#034;)<br \/>\n            return {&#039;step_index&#039;: 0, &#039;step_results&#039;: {}}<\/p>\n<p>        # \u53d6\u6700\u65b0\u7684\u68c0\u67e5\u70b9&#xff08;step_index \u6700\u5927\u7684&#xff09;<br \/>\n        latest &#061; max(checkpoints, key&#061;lambda k: int(k.split(&#039;step_&#039;)[1].split(&#039;.&#039;)[0]))<br \/>\n        checkpoint_data &#061; self.storage.get(latest)<\/p>\n<p>        checkpoint &#061; json.loads(checkpoint_data)<br \/>\n        logger.info(<br \/>\n            f&#034;Recovered session {session_id} from step {checkpoint[&#039;step_index&#039;]}&#034;<br \/>\n        )<br \/>\n        return checkpoint<\/p>\n<p>    def handle_dead_agent(self, agent_id: str, session_id: str):<br \/>\n        &#034;&#034;&#034;\u5904\u7406\u6b7b\u4ea1 Agent&#xff1a;\u6062\u590d\u4f1a\u8bdd\u5e76\u5206\u914d\u65b0 Agent&#034;&#034;&#034;<br \/>\n        # 1. \u4ece\u68c0\u67e5\u70b9\u6062\u590d\u4f1a\u8bdd\u72b6\u6001<br \/>\n        checkpoint &#061; self.recover_session(session_id)<\/p>\n<p>        # 2. \u521b\u5efa\u65b0 Agent \u5b9e\u4f8b&#xff0c;\u4f20\u5165\u6062\u590d\u7684\u68c0\u67e5\u70b9<br \/>\n        # \u65b0 Agent \u4ece\u65ad\u70b9\u7ee7\u7eed&#xff0c;\u4e0d\u4ece\u7b2c 0 \u6b65\u91cd\u65b0\u5f00\u59cb<br \/>\n        new_agent &#061; self.create_agent_with_checkpoint(<br \/>\n            session_id, checkpoint<br \/>\n        )<\/p>\n<p>        # 3. \u901a\u77e5\u7528\u6237&#xff1a;\u4f1a\u8bdd\u6062\u590d&#xff0c;\u4ece\u7b2c N \u6b65\u7ee7\u7eed<br \/>\n        logger.info(<br \/>\n            f&#034;Session {session_id} recovered: &#034;<br \/>\n            f&#034;new agent {new_agent.agent_id}, &#034;<br \/>\n            f&#034;resuming from step {checkpoint[&#039;step_index&#039;]}&#034;<br \/>\n        )<\/p>\n<p>        # 4. \u6e05\u7406\u65e7 Agent \u7684\u6b8b\u7559\u8d44\u6e90&#xff08;\u5185\u5b58\u4e2d\u7684\u4f1a\u8bdd\u6570\u636e\u7b49&#xff09;<br \/>\n        self.cleanup_agent_resources(agent_id)<\/p>\n<p>        return new_agent<\/p>\n<p>    def create_agent_with_checkpoint(self, session_id: str, checkpoint: dict):<br \/>\n        &#034;&#034;&#034;\u521b\u5efa\u65b0 Agent \u5e76\u6ce8\u5165\u68c0\u67e5\u70b9\u6570\u636e&#034;&#034;&#034;<br \/>\n        # \u65b0 Agent \u542f\u52a8\u65f6\u63a5\u6536\u68c0\u67e5\u70b9&#xff0c;<br \/>\n        # \u4ece checkpoint[&#039;step_index&#039;] &#043; 1 \u5f00\u59cb\u6267\u884c<br \/>\n        # \u524d\u9762\u6b65\u9aa4\u7684\u7ed3\u679c\u4ece checkpoint[&#039;step_results&#039;] \u4e2d\u8bfb\u53d6<br \/>\n        agent_config &#061; {<br \/>\n            &#039;session_id&#039;: session_id,<br \/>\n            &#039;resume_from_step&#039;: checkpoint[&#039;step_index&#039;] &#043; 1,<br \/>\n            &#039;previous_results&#039;: checkpoint[&#039;step_results&#039;],<br \/>\n        }<br \/>\n        # \u8c03\u7528 Agent \u542f\u52a8\u63a5\u53e3<br \/>\n        return self.start_new_agent(agent_config)<\/p>\n<p>    def cleanup_agent_resources(self, agent_id: str):<br \/>\n        &#034;&#034;&#034;\u6e05\u7406\u6b7b\u4ea1 Agent \u7684\u6b8b\u7559\u8d44\u6e90&#034;&#034;&#034;<br \/>\n        # \u91ca\u653e\u5185\u5b58\u4e2d\u7684\u4f1a\u8bdd\u7f13\u5b58\u3001\u5173\u95ed\u672a\u5b8c\u6210\u7684\u5de5\u5177\u8c03\u7528\u8fde\u63a5\u7b49<br \/>\n        logger.info(f&#034;Cleaning up resources for dead agent {agent_id}&#034;)<\/p>\n<h3>\u56db\u3001\u8fb9\u754c\u5206\u6790\u4e0e\u67b6\u6784\u6743\u8861<\/h3>\n<h4>4.1 \u5fc3\u8df3\u95f4\u9694\u7684\u6743\u8861<\/h4>\n<p>\u5fc3\u8df3\u95f4\u9694\u592a\u77ed&#xff08;1 \u79d2&#xff09;&#xff1a;\u7f51\u7edc\u5f00\u9500\u5927&#xff0c;\u670d\u52a1\u7aef\u5904\u7406\u538b\u529b\u5927\u3002\u5fc3\u8df3\u95f4\u9694\u592a\u957f&#xff08;30 \u79d2&#xff09;&#xff1a;Agent \u6302\u4e86 30 \u79d2\u4f60\u624d\u77e5\u9053&#xff0c;\u7528\u6237\u5df2\u7ecf\u7b49\u4e86 30 \u79d2\u624d\u53d1\u73b0\u7cfb\u7edf\u6ca1\u54cd\u5e94\u3002<\/p>\n<p>\u6298\u4e2d&#xff1a;\u57fa\u7840\u5fc3\u8df3 5 \u79d2&#xff08;\u8986\u76d6\u5927\u90e8\u5206\u573a\u666f&#xff09;&#xff0c;\u72b6\u6001\u53d8\u5316\u65f6\u7acb\u5373\u53d1\u9001\u4e00\u6b21\u5373\u65f6\u5fc3\u8df3\u3002\u8fd9\u6837\u6b63\u5e38\u60c5\u51b5\u4e0b\u6bcf 5 \u79d2\u4e00\u6b21\u5fc3\u8df3&#xff0c;\u72b6\u6001\u53d8\u5316\u65f6\u79d2\u7ea7\u611f\u77e5\u3002<\/p>\n<h4>4.2 \u68c0\u67e5\u70b9\u7684\u5b58\u50a8\u9891\u7387<\/h4>\n<p>\u6bcf\u5b8c\u6210\u4e00\u6b65\u5c31\u4fdd\u5b58\u68c0\u67e5\u70b9&#xff0c;\u610f\u5473\u7740\u6bcf\u6b65\u90fd\u6709\u4e00\u6b21\u5b58\u50a8\u5199\u5165\u3002\u5982\u679c\u6b65\u9aa4\u6267\u884c\u5f88\u5feb&#xff08;\u6bcf\u6b65 1 \u79d2&#xff09;&#xff0c;\u5199\u5165\u9891\u7387\u5c31\u662f\u6bcf\u79d2\u4e00\u6b21\u3002\u5bf9\u8c61\u5b58\u50a8\u7684\u5199\u5165\u5ef6\u8fdf\u7ea6 50-100ms&#xff0c;\u4e0d\u5f71\u54cd\u6b65\u9aa4\u6267\u884c\u3002<\/p>\n<p>\u4f46\u5982\u679c\u6b65\u9aa4\u6267\u884c\u5f88\u6162&#xff08;\u6bcf\u6b65 10 \u79d2&#xff09;&#xff0c;\u4fdd\u5b58\u9891\u7387\u662f\u6bcf 10 \u79d2\u4e00\u6b21&#xff0c;\u5d29\u6e83\u540e\u6700\u591a\u4e22\u5931 10 \u79d2\u7684\u5de5\u4f5c\u91cf\u3002<\/p>\n<h4>4.3 \u9002\u7528\u8fb9\u754c\u4e0e\u7981\u7528\u573a\u666f<\/h4>\n<ul>\n<li>\u9002\u7528&#xff1a;WebSocket\/SSE \u957f\u8fde\u63a5\u7684 Agent \u7cfb\u7edf\u3001\u591a\u6b65\u9aa4\u5de5\u5177\u8c03\u7528\u94fe\u8def\u3001\u9700\u8981\u4f1a\u8bdd\u6062\u590d\u7684\u4ed8\u8d39\u573a\u666f<\/li>\n<li>\u7981\u7528&#xff1a;\u5355\u6b21\u8bf7\u6c42-\u54cd\u5e94\u7684\u7b80\u5355 Agent&#xff08;\u4e0d\u9700\u8981\u5fc3\u8df3&#xff09;\u3001\u77ed\u8fde\u63a5 HTTP API&#xff08;\u4e0d\u9700\u8981\u957f\u8fde\u63a5\u76d1\u63a7&#xff09;\u3001\u79bb\u7ebf\u6279\u5904\u7406 Agent&#xff08;\u4e0d\u9700\u8981\u5b9e\u65f6\u72b6\u6001&#xff09;<\/li>\n<\/ul>\n<h4>4.4 \u5fc3\u8df3\u901a\u9053\u4e0e\u4e1a\u52a1\u901a\u9053\u7684\u9694\u79bb<\/h4>\n<p>\u5fc3\u8df3\u6d88\u606f\u548c\u4e1a\u52a1\u6d88\u606f\u8d70\u540c\u4e00\u4e2a WebSocket \u8fde\u63a5\u65f6&#xff0c;\u5982\u679c\u4e1a\u52a1\u6d88\u606f\u963b\u585e&#xff08;\u6bd4\u5982\u5927\u7ed3\u679c\u4f20\u8f93&#xff09;&#xff0c;\u5fc3\u8df3\u4e5f\u4f1a\u5ef6\u8fdf\u3002\u89e3\u51b3\u65b9\u6848&#xff1a;\u5fc3\u8df3\u8d70\u72ec\u7acb\u8fde\u63a5\u6216\u72ec\u7acb\u7684\u6d88\u606f\u7c7b\u578b&#xff08;WebSocket \u7684 ping \u5e27\u4e0e\u6570\u636e\u5e27\u662f\u72ec\u7acb\u7684&#xff09;\u3002<\/p>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<p>Agent \u957f\u8fde\u63a5\u573a\u666f\u7684\u5065\u5eb7\u68c0\u67e5\u9700\u8981\u4e09\u5c42\u5fc3\u8df3&#xff1a;\u8fde\u63a5\u5c42\u68c0\u6d4b\u7f51\u7edc\u53ef\u8fbe\u3001\u8fdb\u7a0b\u5c42\u68c0\u6d4b Agent \u5b58\u6d3b\u4e0e\u8d44\u6e90\u72b6\u6001\u3001\u4e1a\u52a1\u5c42\u68c0\u6d4b\u5904\u7406\u8fdb\u5ea6\u662f\u5426\u63a8\u8fdb\u3002\u5355\u9760\u8fde\u63a5\u5c42\u5fc3\u8df3\u65e0\u6cd5\u533a\u5206&#034;\u5728\u601d\u8003&#034;\u548c&#034;\u5df2\u6302\u6389&#034;\u3002\u6838\u5fc3\u8bbe\u8ba1&#xff1a;5 \u79d2\u57fa\u7840\u5fc3\u8df3 &#043; \u72b6\u6001\u53d8\u5316\u5373\u65f6\u5fc3\u8df3\u3001\u505c\u6ede\u68c0\u6d4b&#xff08;step \u4e0d\u53d8\u7684\u6b21\u6570\u8d85\u9608\u503c\u5224\u5b9a\u5361\u4f4f&#xff09;\u3001\u7f3a\u5931\u68c0\u6d4b&#xff08;\u8fde\u7eed N \u6b21\u5fc3\u8df3\u7f3a\u5931\u5224\u5b9a\u6b7b\u4ea1&#xff09;\u3002\u68c0\u67e5\u70b9\u673a\u5236\u4fdd\u8bc1\u5d29\u6e83\u540e\u65ad\u70b9\u7eed\u4f20&#xff1a;\u6bcf\u5b8c\u6210\u4e00\u6b65\u4fdd\u5b58\u7ed3\u679c&#xff0c;\u6062\u590d\u65f6\u4ece\u6700\u65b0\u68c0\u67e5\u70b9\u7ee7\u7eed&#xff0c;\u4e0d\u4ece\u5934\u91cd\u8dd1\u3002\u5fc3\u8df3\u901a\u9053\u4e0e\u4e1a\u52a1\u901a\u9053\u9694\u79bb&#xff0c;\u907f\u514d\u4e1a\u52a1\u963b\u585e\u5f71\u54cd\u5fc3\u8df3\u5ef6\u8fdf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5&#xff1a;\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7Agent \u8fde\u7740\u8fde\u7740\u5c31\u6ca1\u4e86\u53cd\u5e94\u2014\u2014\u4f60\u4e0d\u77e5\u9053\u5b83\u662f\u771f\u7684\u5728\u601d\u8003&#xff0c;\u8fd8\u662f\u5df2\u7ecf\u6084\u6084\u6302\u4e86\u3002\u4e00\u3001\u573a\u666f\u75db\u70b9<br \/>\n\u4f60\u7684 Agent \u7cfb\u7edf\u7528 WebSocket \u7ef4\u6301\u957f\u8fde\u63a5&#xff0c;\u7528\u6237\u53d1\u4e00\u6761\u6d88\u606f\u540e Agent \u9700\u8981\u8c03\u7528\u591a\u4e2a\u5de5\u5177&#xff0c;\u8017\u65f6\u53ef\u80fd 10-60 \u79d2\u3002\u95ee\u9898\u6765\u4e86&#xff1a;\u8fd9 60 \u79d2\u91cc&#xff0c;\u7528\u6237\u4e0d\u77e5\u9053 Agent \u662f\u5728\u5904\u7406\u8fd8\u662f\u5df2\u7ecf\u6302\u4e86\u3002\u5982\u679c Agent \u8fdb\u7a0b\u5d29\u6e83&#xff0c;Web<\/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":[9680,120,763],"topic":[],"class_list":["post-86087","post","type-post","status-publish","format-standard","hentry","category-server","tag-k8","tag-kubernetes","tag-763"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7 - \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\/86087.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5&#xff1a;\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7Agent \u8fde\u7740\u8fde\u7740\u5c31\u6ca1\u4e86\u53cd\u5e94\u2014\u2014\u4f60\u4e0d\u77e5\u9053\u5b83\u662f\u771f\u7684\u5728\u601d\u8003&#xff0c;\u8fd8\u662f\u5df2\u7ecf\u6084\u6084\u6302\u4e86\u3002\u4e00\u3001\u573a\u666f\u75db\u70b9 \u4f60\u7684 Agent \u7cfb\u7edf\u7528 WebSocket \u7ef4\u6301\u957f\u8fde\u63a5&#xff0c;\u7528\u6237\u53d1\u4e00\u6761\u6d88\u606f\u540e Agent \u9700\u8981\u8c03\u7528\u591a\u4e2a\u5de5\u5177&#xff0c;\u8017\u65f6\u53ef\u80fd 10-60 \u79d2\u3002\u95ee\u9898\u6765\u4e86&#xff1a;\u8fd9 60 \u79d2\u91cc&#xff0c;\u7528\u6237\u4e0d\u77e5\u9053 Agent \u662f\u5728\u5904\u7406\u8fd8\u662f\u5df2\u7ecf\u6302\u4e86\u3002\u5982\u679c Agent \u8fdb\u7a0b\u5d29\u6e83&#xff0c;Web\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/86087.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-27T20:40:54+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=\"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\/86087.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/86087.html\",\"name\":\"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-27T20:40:54+00:00\",\"dateModified\":\"2026-07-27T20:40:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/86087.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/86087.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/86087.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7\"}]},{\"@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":"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7 - \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\/86087.html","og_locale":"zh_CN","og_type":"article","og_title":"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5&#xff1a;\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7Agent \u8fde\u7740\u8fde\u7740\u5c31\u6ca1\u4e86\u53cd\u5e94\u2014\u2014\u4f60\u4e0d\u77e5\u9053\u5b83\u662f\u771f\u7684\u5728\u601d\u8003&#xff0c;\u8fd8\u662f\u5df2\u7ecf\u6084\u6084\u6302\u4e86\u3002\u4e00\u3001\u573a\u666f\u75db\u70b9 \u4f60\u7684 Agent \u7cfb\u7edf\u7528 WebSocket \u7ef4\u6301\u957f\u8fde\u63a5&#xff0c;\u7528\u6237\u53d1\u4e00\u6761\u6d88\u606f\u540e Agent \u9700\u8981\u8c03\u7528\u591a\u4e2a\u5de5\u5177&#xff0c;\u8017\u65f6\u53ef\u80fd 10-60 \u79d2\u3002\u95ee\u9898\u6765\u4e86&#xff1a;\u8fd9 60 \u79d2\u91cc&#xff0c;\u7528\u6237\u4e0d\u77e5\u9053 Agent \u662f\u5728\u5904\u7406\u8fd8\u662f\u5df2\u7ecf\u6302\u4e86\u3002\u5982\u679c Agent \u8fdb\u7a0b\u5d29\u6e83&#xff0c;Web","og_url":"https:\/\/www.wsisp.com\/helps\/86087.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-27T20:40:54+00:00","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\/86087.html","url":"https:\/\/www.wsisp.com\/helps\/86087.html","name":"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-27T20:40:54+00:00","dateModified":"2026-07-27T20:40:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/86087.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/86087.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/86087.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Agent \u5fc3\u8df3\u4e0e\u5065\u5eb7\u68c0\u67e5\uff1a\u957f\u8fde\u63a5\u573a\u666f\u4e0b\u7684\u4f1a\u8bdd\u72b6\u6001\u76d1\u63a7"}]},{"@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\/86087","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=86087"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/86087\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=86087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=86087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=86087"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=86087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}