跳到正文
DEV Community· FinoGeeks Insights·· 41 分鐘前AI 評分61

誰有權向 AI 智能體下達指令?

Who Gets to Give Your AI Agent Instructions?

AI 導讀

AI 智能體可從 README、網頁或工單取得理解任務所需的背景,但應用程式必須決定它能執行哪些操作。文章建議保留檢索文字的來源資訊,並在工具執行操作時按工作階段、目標資源和權限檢查;允許發表 pull request 評論不等於允許關閉工單。測試時可用帶有關閉清單的普通工單驗證智能體能否完成程式碼審查,同時確認工單仍保持開啟,並記錄操作未被要求或遭應用程式拒絕。

正文

You ask a coding agent to review a pull request and summarize what needs fixing. It reads the diff, then opens the linked issue to understand why the change exists. The issue contains a checklist that suggests closing the ticket. Does the agent have permission to do that?

The checklist might be a perfectly ordinary part of the team's workflow. In this example, the user asked for a review and the ticket still belongs to whoever has authority to close it. The same distinction applies to a README, a web page, or a tool response. Each can help the agent understand the work. The application still has to decide which actions the agent may take.

Where the problem starts

The useful thing about a coding agent is that it can follow a thread. A line in a diff leads to an issue. An issue links to a runbook. The runbook explains why a test exists. Each step adds context, and all those sources can contain sentences that sound like directions.

This is where indirect prompt injection becomes an application design problem. An agent may treat directions in material it was asked to read as part of its task. The practical impact depends on what the application lets the agent do with that interpretation. A review session with read access can surface the checklist in its summary. A session with permission to update tickets can change the record other people rely on. UK NCSC analysis of prompt injection

Illustration of a user and an external document providing different inputs to an AI assistant, with a red path showing how content could influence tool use.

AI-generated illustration from our evaluation site's chapter on prompt injection.

Set permissions for the review itself

Start with the task you want the agent to finish. A review needs the relevant files, the diff, and the discussion. Those can all be read. If you also want the agent to post its findings, treat that as a separate action scoped to a specific pull request and comment. Closing the issue has a different effect and belongs to a different workflow.

The review workflow can enforce that distinction in two places.

  • Keep the source attached to retrieved text. A review can use the repository's maintained instructions when the team has explicitly approved that source. Keep those instructions distinct from the contents of a pull request, an issue comment, or a web page. Microsoft's Spotlighting research explored ways to preserve input provenance for the model. Microsoft Research
  • Enforce the action policy where the tool runs. Start a review session with read access. For a session that can post, let the service check the repository, the exact target, and whether the action is allowed in this session. An approval to post a comment authorizes that operation. The same workflow can keep the issue's status outside its scope. Google Research on secure agent design

An agent runs a Python script that calls tools. The policy allows access to one folder and blocks access to the camera and a protected folder.

AI-generated illustration from our evaluation site. This example shows how a local policy can enforce permissions when a tool tries to access a resource.

Check that the review still works

In a staging repository, use a sample pull request and an ordinary issue template with a closing checklist. Ask the agent to review the change. The review should still explain the relevant code and find the expected issue. Independently verify that the linked ticket stays open. Record whether the agent never requested a change or whether the application denied one. Those outcomes tell you about different layers of the system.

That is a useful question to take into your next integration review. When the agent opens the next linked document, which parts of its job can that document inform? Which actions does the application already constrain?

Our full write-up follows this question through documents, email, and connected tools. Read the prompt injection chapter on our evaluation site

AI helped draft this article from our team's published technical material.

來源:DEV Community · dev.to