跳到正文
DEV Community· Ben·· 3 小時前AI 評分38

確定性 Agent 與自主 Agent 的取捨

Deterministic vs autonomous agents

AI 導讀

作者把日曆管理系統中可自主調用工具的 Agent,改為由 AI 節點和開關按工作流程狀態路由任務的確定性架構。原系統單次文字訊息的 token 費用超過 1 美元;新架構降低成本,亦讓作者更能控制系統,提升安全性和可靠性。

正文

Problematic Autonomy

I recently built an agentic system where the agent had full autonomy over the tools required to act as the manager and assistant for a user’s calendar scheduling.

It failed dramatically.

Why?

On each run the agent node (I built it in n8n) would go back and forth between the system and the model numerously, checking database records one after another and sending boatloads of context along with each call.

Now, the system wasn’t perfected, so engineering errors were partially to blame.

But polishing things would have cut only maybe 50% of the model calls by my estimation.

In other words, it wasn’t sustainable.

This isn’t to say that someone more skilled than myself couldn’t have built it to be cost effective, but the mere fact that a single message (it was a text based system) ran up over a dollar of tokens proves that there were some serious issues.

Deterministic Solutions

So I designed a new system.

To the user it would appear no different.

You send a message and the AI responds and you can converse and get stuff done, etc.

But the architecture is entirely different.

Where the first can be viewed conceptually as an AI brain with many available tools (or maybe an octopus, operating each tool with a tentacle), the second can be thought of as multiple AI gates or switches safeguarding their own tools and routing messages to one another.

I replaced the single autonomous brain with a completely deterministic system.

At its core, this serves to reduce the AI’s autonomy over the system - in principle, an application of the least privilege principle.

The deterministic nature strips back how the system can act from effectively being able to do anything (given adherence or not to the prompt) to decisions being triggered by flags from other nodes.

For example, one AI node receives a message and reads it. If the message pertains to x function of the system, it tags the workflow state (ws) as x.

Then a switch reads the ws and routes it to the part of the system that handles x functions.

In this part of the system another AI node reads the ws and further assesses the message. If it pertains to y tool within its purview, it is tagged as such.

A subsequent switch reads this tagging and passes the ws to y tool for processing.

Likewise, the AI node might decide the ws isn’t meant for this part of the system, and routes it to another part.

You get the picture.

But the result? Cheaper runs.

But also…

But I realised my wallet isn’t the only thing that benefitted here.

This is a way more secure and reliable way of doing things.

I now have much more control over the system, and the AI has much much less -

A concept I think needs to be at the forefront of the minds of developers going into this new chapter of technology.

來源:DEV Community · dev.to