腳本與任務並不相同:確定性流程應留在腳本中
A Script and a Task Are Not the Same Thing
Qingfeng 指出,腳本按固定步驟執行並產生可預期結果,任務則要觀察當下情況、作出判斷再行動。混合流程中,應保留確定性腳本,只把未知步驟交給 Agent,讓腳本接續執行。腳本可直接審核,任務則要按結果驗證;混用兩者會令審核和驗證都變得困難。
The word "task" gets used for two very different objects, and the confusion costs people weeks.
A script is deterministic. Same input, same output, no judgement, no surprises. A task is a small delegation: something has to look at the world, decide, and act. Scripts fail loudly and immediately. Tasks fail quietly, three steps later.
Most of the disappointment I see with agents comes from treating one as the other.
When it should be a script
If you can write down the steps without using the word "check" or "figure out", it is a script. Renaming files, running the test suite, deploying a known branch - all scripts. Do not put an agent in the loop. It is slower, it costs money, and it introduces a failure mode that did not exist.
My rule: if I have to explain the task to a colleague twice, and both times I use the same words, it is a script that nobody has written yet.
When it is genuinely a task
When the steps depend on what the world looks like at the moment. "Find the failing test and fix it" is a task. So is "check whether the deploy actually took effect" and "figure out which of these three dependency bumps is the breaking one".
Notice that all of these contain an implicit decision. That is the signal. A task has a fork in it, and which way to go is not known until someone looks.
The mixed case that gets people
The dangerous middle is a script with one unknown step. It looks like a task, so people hand the whole thing to an agent, and now a deterministic sequence of ten steps is being improvised by something with judgement, at ten times the cost, with a new failure mode per step.
The fix is to keep the script and delegate only the unknown step. The script calls the task, that task returns a decision, the script continues. Most of my reliable automations have exactly this shape: a boring deterministic spine with one intelligent node in the middle.
Why the distinction holds up
Scripts are auditable. I can read the file and know what will happen. Tasks have to be verified by result, which is why the finish condition matters so much.
When the two get mixed, you lose both properties: you cannot audit it, and you cannot fully verify it either. That is the worst of both worlds, and it is a surprisingly common place to end up.
If you have found a task that turned out to be a script in disguise, I would like to hear it. Mine was a weekly report I had been "delegating" for a month before realising the numbers came from the same three queries every time.
來源:DEV Community · dev.to