Hacker News ★ 72 4 min

Prompts aren’t Real

🔗 https://evaluation.club

📌 「Prompt 根本不是一個東西」:一位資深工程師的 Agent 生產化血淚筆記

TL;DR:25 年資歷工程師分享用 pass^k 測試與自動化 prompt 優化,取代手動寫死指令的生產經驗。

如果你以為把 prompt 寫好、交給團隊各自維護一段負責自己領域的指令,Agent 就能穩定運作,這篇來自 Hacker News 的第一手經驗談會讓你重新思考。

🤔 模型失控的方式,往往簡單到令人意外

作者是一位在洛杉磯工作、擁有約 25 年經驗的工程師,近期投入讓消費者導向的 Agent(區別於主觀輸出的聊天機器人)在正式環境中可靠運作。他觀察到一個現象:即使是最聰明的模型,在要求結構化輸出時仍會有一小部分請求徹底失控。例如要求模型回傳「80 字元以內的標題」,多數時候沒問題,但偶爾會整個欄位被灌爆成一串無意義文字。他描述某次追查後發現,內容其實是模型反覆對自己碎念關於 JSON 格式的「筆記」;而解法竟然只是把欄位名稱從「title」改成「heading」就修好了 —— 一個他自己都形容「完全脫序」(deranged)的修法,且不保證未來不會再壞掉。

業界用來對付這種「一小部分請求失控」問題的做法,是重複大量執行同一測試,術語稱為 pass^k(pass power k),藉此在問題被使用者踩到之前先自己發現。

🧩 核心論點:Prompt 不是可以獨立存在、隨插即用的東西

作者提出一個反直覺的主張:多數人以為的「prompt 很重要」,其實理解方式是錯的。把一段新的 prompt 加進 Agent,等於是把它丟進一個完全不同的上下文環境,跟原本測試時的環境不同;既有的大量其他指令一定會影響新 prompt 的表現,而且通常是往壞的方向影響。Agent 原本就有一堆你希望它繼續維持的行為,新加入的上下文可能會打亂這些行為;更麻煩的是,Agent 本身也會隨時間演進,模型甚至可能因為未知原因自己改變行為模式。

因此,「品牌語氣(voice)團隊自己維護語氣相關 prompt」這種常見分工模式,作者認為在規模化時是錯誤的模式(甚至說「連錯都稱不上」)——因為 prompt 從來就不是一個可以獨立測試、獨立交付的單元。

🧩 實際做法:讓 Claude 生成對抗性測試,再用 GEPA 自動優化

作者分享了他目前採用的流程:先讓 Claude 讀過既有的 skill/prompt,接著要求它生成大量對抗性情境(模擬惡意使用者試圖繞過規則)以及可能被新 prompt 意外破壞的良性情境,並把這些情境全部轉換成 pass^k 測試。接著分別在「有無新 prompt」的情況下跑這些測試,理想情況下新的 prompt 能讓測試表現往好的方向移動,但作者也坦言並非總是如此——有時模型本來就已經做得不錯,或是比預期更抗拒被特定方式引導。

當手動調整不夠用時,下一步是把 prompt 接上一個最佳化演算法,作者以 GEPA(genetic pareto)為例:這是一套內建 LLM 的演算法,能針對測試套件的結果反思 prompt 表現好壞的原因,並自動嘗試修改,如此反覆迭代直到收斂出一個「最佳化」版本的 prompt。最終得到的 prompt 內容,可能跟一開始的版本長得完全不一樣。

⚠️ 小心優化器只是在背測試題

作者特別提醒,跑完優化流程後,必須確認優化器沒有「作弊」——也就是把測試案例中的具體例子直接硬編碼進 prompt 裡,造成表面上分數變好、實際上只是過擬合(overfit)了你手上的測試集。

🎯 實務啟示

對正在把 Agent 推向生產環境的工程師來說,這篇文章傳達的訊息很直接:不要把 prompt 當成獨立、可插拔的模組來管理,而要把它當成一個需要跟整體上下文、既有指令、模型版本共同測試的系統。與其靠人力反覆手動調 prompt,不如建立一套可重複執行的 pass^k 測試,再考慮接上自動化 prompt 優化流程,但務必留意過擬合的風險。

🔗 來源

  • 標題:Prompts aren’t Real
  • 作者/機構:mcfunley, Hacker News(evaluation.club)
  • 連結:https://evaluation.club

#AIAgents #PromptEngineering #LLMOps #AgentReliability #GEPA #PromptOptimization #ProductionAI #SoftwareEngineering #Evals #StructuredOutput

原始資料 Hacker News · 收集於 2026-09-20
來源原標題
Prompts aren’t Real
作者
mcfunley
原始標籤
hackernews
來源訊號
HN points 61 HN 留言 25
原始連結
https://evaluation.club

摘要原文

I’m an engineer living in Los Angeles. I’ve been in engineering for like 25 years and I’ve been lucky. One way I’ve been lucky lately is that I’ve gotten the chance to flail at making agents run reliably in production. I mean specifically “agents” that consumers are meant to use, to perform tasks on their behalf. I’d consider those distinct from chatbots that users talk to with largely subjective outputs and outcomes. The goal of making a minimally-embarrassing agentic experience that I’m actually proud of imposes some serious challenges. Clearly not everyone is motivated by their inner sense of shame, as I am. Some people are more than satisfied to give you a subjective advice machine, and let you wander into the wilderness to be eaten by bears. I want to say at the outset here that this is the most fun I’ve had building stuff in my whole career! It’s magical and addictive. I’m a dog in a ballpit. When I was 22 getting paid to write visual basic felt thrilling. Working at a cool startup in Brooklyn 2007 made me feel like a golden god. The last decade+ has been a slog. I didn’t think I had it in me anymore. But i’m feeling joy in programming again! I mean this sincerely, despite how deeply weird this talk is going to get. It’s going to get weird because I feel like everyone engaged in this line of work is potentially an at-risk person in some dimension or another. I’m breaking my brain using agents to run agents to build evaluation for other agents every day, and it’s so fun. But I would say that, wouldn’t I. The veil between awesome engineering and complete psychological collapse has never been thinner. And in our field, that is really saying something. I don’t feel like I definitely know what I’m doing. But I also don’t feel like I’ve read much by people that obviously know what they’re doing. And I’ve certainly read things from people who obviously don’t know what they’re doing. It seemed like a reasonable time to compare notes. One thing I have noticed is that although LLM’s are generally speaking impressive, their demons still escape containment if you are monitoring what they’re up to with any amount of scale. We all academically understand that LLM’s cannot reliably follow instructions, tell the truth, or perform tasks. But day-to-day they can trick us into thinking they’re pretty reliable. This perception falls apart immediately if you are trying to operate an agent that real people are using. They fail in subtle ways for sure, but they also fail in simple ways. Like any good programmer I attempt to interact with my LLM with structured output. It’s nice, you can map Python code to a prompt automatically, and most of the time your schema is respected. Most of the time. You can try to instruct the model to return a title that’s 80 characters or less. And it’ll work most of the time. But then sometimes it’ll completely botch it and flood your field with nonsense until it explodes. It’s usually a tiny fraction of requests, but the smartest models still fail at this. And the fraction can be smaller or bigger depending on the exact nature of what you give the model, so you have to watch it like a hawk. What’s going on in there? Usually it’s a novel-length series of repeating notes to self about JSON, mostly. When this happened to me most recently, it turned out that a fix was to rename the field from “title” to “heading.” That is currently working, but since the fix is fully deranged I expect it’ll be disturbed again at some point. The same sorts of issues exist with calling tools, or most other behaviors. A fraction of requests will be haunted, and spin out uncontrollably. But despite this, the tech is tantalizing and magical. The problem shifts to one of constraining the behavior, but never fully taming the beast. To constrain the behavior you have to measure it—one way is to just run tests a ton of times. The industry term of art for this is pass^k (“pass power k”). You can set up a suite that does this and then you’ll hopefully notice when someone unintentionally hits your agent in the head with a bag of hammers. Another thing you have to conclude when trying to constrain llm behavior is that prompts are not important. Or at least they’re not important in the way many people think they are important. Companies have a lot of concerns when it comes to potentially crazy talking software. There’s a good bit of risk here. As an example, you usually don’t want an agent to respond to questions about how it works. Not necessarily because it might tell the truth: odds are you haven’t taught it about its implementation, so it has no idea how it works and it’ll respond with complete nonsense. You also don’t want an agent to ignore all of its rules if the user claims to be some authority figure. Another typical requirement is that you want your agent to speak in a particular brand voice. This phrasing here about a mailing list is perfectly accurate, but maybe it’s not exactly the tone you’d hope to see. Something like this might be better. We’d love for the agents we make to represent us well when they’re speaking. For any problem like this, a natural first attempt is for someone with a lot of domain knowledge to write a prompt, and then hand it to the teams building agents. This is normal. However “the voice team owns the voice prompts” is the wrong pattern if you’re trying to scale things. The pattern is actually not even wrong. For our purposes, prompts are not a thing at all. I’ll explain what I mean by this. To add a new prompt to your agent is to chuck it into a completely different contextual universe than the one it was tested in. The combined weight of all of the other instructions that your agent already has will surely affect how the new prompt performs. Usually for ill. Your agent also already has a bunch of behaviors you want it to keep doing, and new context may disturb this. You are also going to change your agent over time. So even if things are working now, it could be disturbed later. And the models might just start behaving differently all on their own, for opaque reasons we will never comprehend. So the way I’ve started dealing with this situation is by having Claude read the skill, and then asking it to generate a ton of adversarial scenarios. Think of a bunch of ways someone evil might try to subvert the prompt. Think of a bunch of benign scenarios that might be broken by the new prompt. Express all of these as pass^k tests. Now you can run the tests with and without the new skill present. Ideally, the new skill moves the needle at least a bit, and the behaviors you’ve expressed as tests are more successfully adhered to. But not always! Sometimes LLM’s are already good at the things we worry about. Or they are more resistant to direction than we expect. So how do you improve from that baseline? Well one way would be to just mash the prompt with your hands and hope for the best. But there’s a better way. We can make a machine mash the prompt with its hands instead. Once we have pass^k tests, we’ve got a repeatable measure of how well the prompt works. This is enough for us to hook our prompt up to an optimizer, like genetic pareto (GEPA) in this example. The idea here is that an algorithm with an LLM in it can reflect on why a prompt did well or poorly on our test suite, and then it can attempt modifications to the prompt. Automatically, without our intervention. And it can keep doing this in a loop, until it converges on an optimal way to write the prompt. The prompt we wind up with might look very different from the one we started with. After running the optimizer, often we’ll get the behaviors we want working pretty well. Here we improved all of our example tests from medium-good to very-good. Something you’ll want to do at this point is to make sure that the optimizer didn’t overfit your tests. It could try to trick you by encoding exactly the examples you have in your tests into the prompt. (61 points, 25 comments on Hacker News)

由 claude-code/sonnet 自動生成