Daily Tech Briefing
AI 科技速览
每天 5 分钟内学习 AI。获取最新的人工智能新闻,理解其重要性,并学习如何将其应用于您的工作。
Dev.to AI · 2026/7/22 01:11:01
Build a FinOps AI Agent: Autonomous Kubernetes Cost Optimization with Guardrails
AI 中文解读
FinOps AI Agent来了!这次不是让AI直接改你的云服务器配置,而是让它当个“只动嘴不动手”的财务分析师——它只查账、算浪费、写优化报告,最终要不要改还得你拍板。简单说就是:AI读数据排浪费,人类做决定走流程,安全又高效。
通俗解读:以前用AI优化云成本,最怕它突然抽风直接修改系统配置,一旦出错就是大事故。现在这个新方案给AI上了“紧箍咒”:只给它两个只读工具(查成本、看资源效率),不给任何能直接改系统的权限。AI算出哪个服务资源要多了、哪个内存跑不满,直接生成一份优化建议的代码修改请求(Pull Request),然后通过GitOps流程让人工审核后再生效。既发挥了AI的快速分析能力,又把危险锁在外面。
实际影响:对企业来说,云成本优化不再依赖人工翻报表,AI自动揪出浪费点并给出具体修改方案,运维人员只要点头或摇头就行。普通人可能感受不到这个变化,但企业省下的成本可能变成更便宜的产品或更稳定的服务——比如你刷视频时服务器不再因为配置不合理而卡顿,公司也少交冤枉钱给云厂商。
<blockquote>
<p>💡 <strong>Originally published on <a href="https://devtocash.com/blog/2026-07-22-finops-ai-agent-kubernetes-cost-optimization" rel="noopener noreferrer">devtocash.com</a></strong> — where this guide stays updated. I write hands-on DevOps/SRE deep-dives there weekly.</p>
</blockquote>
<h2>
What a FinOps agent should actually do
</h2>
<p>A useful FinOps agent does not "manage your cloud bill." It does one narrow, verifiable job: read cost and utilization data, find the handful of workloads that are wasting money, and produce a concrete, reviewable rightsizing change — a pull request, not a live <code>kubectl apply</code>. The intelligence is in ranking the waste and justifying the fix; the <em>action</em> stays behind a human gate and your existing GitOps flow.</p>
<p>That framing is the whole design. Cost data is read-only and cheap to query, which makes it nearly ideal agent input — an over-provisioned <code>resources.requests</code> is an objective fact, not a judgment call. The danger is never in the reading; it is in letting a model that occasionally hallucinates a number write directly to production. So we build an agent that is powerful at analysis and deliberately powerless at mutation. This pairs the <a href="https://devtocash.com/blog/ai-agents-sre-autonomous-incident-response-2026" rel="noopener noreferrer">autonomous-agent playbook</a> with hard <a href="https://devtocash.com/blog/finops-kubernetes-cost-optimization" rel="noopener noreferrer">FinOps cost discipline</a>.</p>
<h2>
The two tools it gets — and the one it doesn't
</h2>
<p>An agent is defined by its tools. Give this one exactly two read tools and zero write tools.<br>
</p>
<div class="highlight js-code-highlight">
<pre class="highlight python"><code><span class="n">TOOLS</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">{</span>
<span class="sh">"</span><span class="s">name</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">get_cost_allocation</span><span class="sh">"</span><span class="p">,</span>
<span class="sh">"</span><span class="s">description</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">Per-workload cost + CPU/memory efficiency over a window. </span><span class="sh">"</span>
<span class="sh">"</span><span class="s">Efficiency = usage / requests. Below ~0.4 is waste.</span><span class="sh">"</span><span class="p">,</span>
<span class="sh">"</span><span class="s">input_schema</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span>
<span class="sh">"</span><span class="s">type</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">object</span><span class="sh">"</span><span class="p">,</span>
<span class="sh">"</span><span class="s">properties</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span>
<span class="sh">"</span><span class="s">namespace</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span><span class="sh">"</span><span class="s">type</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">string</span><span class="sh">"</span><span class="p">},</span>
<span class="sh">"</span><span class="s">window</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span><span class="sh">"</span><span class="s">type</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">string</span><span class="sh">"</span><span class="p">,</span> <span class="sh">"</span><span class="s">enum</span><span class="sh">"</span><span class="p">:</span> <span class="p">[</span><span class="sh">"</span><span class="s">7d</span><span class="sh">"</span><span class="p">,</span> <span class="sh">"</
分享
阅读原文 ↗