Close 关闭Agent
()
| 1207 | |
| 1208 | // Close 关闭Agent |
| 1209 | func (a *Agent) Close() error { |
| 1210 | close(a.stopCh) |
| 1211 | |
| 1212 | // 通知 Middleware Agent 停止 (Phase 6C) |
| 1213 | if a.middlewareStack != nil { |
| 1214 | ctx := context.Background() |
| 1215 | if err := a.middlewareStack.OnAgentStop(ctx, a.id); err != nil { |
| 1216 | agentLog.Warn(ctx, "middleware OnAgentStop error", map[string]any{"error": err}) |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | if err := a.sandbox.Dispose(); err != nil { |
| 1221 | return err |
| 1222 | } |
| 1223 | |
| 1224 | return a.provider.Close() |
| 1225 | } |
| 1226 | |
| 1227 | // buildToolContext 构造工具执行上下文, 注入必要的服务。 |
| 1228 | // 当前会注入: |
nothing calls this directly
no test coverage detected