如何用雙份任務簡報避免 AI Agent 靠延長逾時時間「修復」不穩定測試
Don't let your AI agent "fix" a flaky test by raising the timeout
作者提出為同一項不穩定測試調查任務撰寫兩份簡報,要求 AI Agent 查明 nightly build 超時原因,而不是直接延長逾時時間讓測試通過。Agent 簡報列明調查來源、範圍、停止條件、檢查及交付內容;人工執行者則負責提供存取權限、在決策邊界停下並核對證據。兩份簡報須對齊各自的停手點和批准責任,讓調查即使未能提交修補程式,也能交付可核查的發現。
"Fix the flaky test" sounds like a clear task. Give it to an AI agent, and the fastest way to make the build green is to raise the timeout. The test passes, and nobody learns whether the real problem was the test, the build environment, or a change in the product.
That's not really an agent problem. It's a handoff problem. The agent knows what to investigate but not when to stop. The person running it knows how to start a session but not which decisions belong to them.
So I write two briefs for one task: a detailed one for the agent and a short one for the human. I explain the full pattern in One task, two briefs: instructions for the human and the agent. Below is one worked pair you can copy.
The task
A test in the nightly build sometimes times out. Nobody has established yet whether the test is unstable, the build environment is slow, or product behavior has changed.
Brief 1: for the agent
OUTCOME
Determine why the named test times out in the nightly build. Return a
finding a reviewer can check. Make a code change only if the cause and
an approved remedy are established.
SOURCES
Start with the failure report, the test's current code, the relevant
build logs, and the team's approved test conventions. Record the build
and commit IDs you used. If a source is missing or inaccessible, name it
in the report.
SCOPE
Inspect the named test and the product path it exercises. Compare passing
and failing runs where evidence exists. Keep changes to that path and its
test coverage. Do NOT weaken an assertion, increase a timeout, or disable
the test just to make the build pass.
DECISION POINTS
- Evidence points to a product regression: report it before changing
product behavior.
- Intended behavior is unclear: ask the test or feature owner to decide.
- Evidence can't separate test, environment, and product: deliver the
competing explanations and the next check that would separate them.
CHECKS
For an approved fix: run the relevant test and existing build checks.
Record what ran, the environment, and the result.
For an investigation without a fix: identify the logs and comparisons
that support the finding.
DELIVERY
Return the cause or remaining uncertainty, links to evidence, any
approved change, check results, and known limits. Do not merge or deploy
unless the task separately authorizes it.
This is deliberately more than "look into the timeout." It gives the agent sources, a boundary, and a useful result even if the investigation ends without a patch. It also turns the tempting shortcut, raising the timeout, into an explicit decision instead of a quiet edit.
Brief 2: for the human runner
Open the named build and repository, and make sure the agent can reach
the failure report and logs. Check that its finding matches the recorded
runs. Bring any proposed behavior change or unresolved test expectation
to the named owner before authorizing a fix, then review the result.
The runner doesn't need to memorize every test convention in the agent brief. Their job is to supply access, notice when the investigation crosses a decision boundary, and check the evidence that comes back. If the fix needs specific build or device checks, put those in a separate QA list.
Read the two briefs together before you assign the task
The briefs have to agree with each other:
- If the human is told to wait for an owner's decision, the agent must be told to stop at the same point.
- If the agent is asked to deliver a patch, the human must know who can approve it and what evidence to inspect.
A quick test: each reader should be able to answer three questions.
- What can I do now?
- What makes me stop?
- What must I hand back?
The full pattern
This post covers one task. The Wagglet guide to the two-brief pattern explains why the agent and the runner need instructions that line up but give each of them different responsibilities, so you can apply it beyond flaky tests.
A good handoff doesn't promise a quick fix. It makes an honest finding useful and keeps open decisions in front of the person who owns them.
What shortcut do your agents reach for when a check fails?
I write for Wagglet, an AI task handoff tool.
來源:DEV Community · dev.to