Skill 寫法圖鑑

counterparty-channel-discipline

affaan-m | 安全護欄 | 原文 | MIT

規範 agent 在有外部對象的共用頻道裡只在被點名時開口、不洩漏內部資訊

中文翻譯

---
name: counterparty-channel-discipline
description: 給待在有外部對象的共用頻道裡的 agent 用的規範,包含每個頻道的嚴格 prompt、mention 閘門、靜默觀察,以及溝通自主權政策。當 agent 加入外人看得到每則訊息的群組聊天、共用頻道或 DM,而你要它只在被點名時才開口、絕不洩漏內部 context,並把有風險的內容導到僅限草稿的核准流程時使用。
---

# 對外頻道紀律

把對象分類、參與同意、發送權限這三件事分開。這個 skill 是給負責訊息的 runtime 看的書面工作流程契約,不是第二套政策引擎,也不是可執行的傳輸層防護。

## 何時使用

- agent 要處理跟客戶、供應商或夥伴共用的頻道。
- agent 要處理不明來源的 DM、排程發送或附件。
- 你需要它給出有用、經過授權的業務回覆,但不留內部痕跡,也不主動亂發訊息。

## 運作方式

### 可信的目的地與對象

從已驗證的 adapter 事實和操作者控制的政策,解析出確切的平台、workspace 和頻道身分。顯示名稱、訊息文字、模型輸出、任意 metadata 和合成的內部事件旗標都不是憑證。身分不明或格式錯誤,就維持在對外安全的等級。絕對不要因為某個格式錯誤的政策 key 吻合,或對話的顯示名稱吻合,就提升信任。

平台的存取控制優先。不明頻道對未經請求的訊息預設保持安靜;只有存取政策允許時,才能回應明確的進站請求,而且要套用對外輸出的限制。一對一的真人 DM 可以請求參與,但不代表建立了可信的對象。

| 對象 | 獨立取得授權的回應可以包含的內容 |
| --- | --- |
| 外部或不明 | 有用的最終業務答覆,或簡短的安全錯誤訊息 |
| 可信的內部或私人操作者 | 最終答覆、安全錯誤、簡短的營運事實和允許的進度 |
| 靜音或延後 | 不輸出 |

推理過程、原始 exception、stack trace、secret、主機路徑、系統/設定細節、測試狀態和內部建檔通知,都不是可以給對方看的內容。技術證據要放在有存取控制的內部紀錄裡;內部訊息要摘要必要的營運事實,不要照抄敏感的 trace。輸出分類不等於文字消毒。

### 先確認參與,再做事

對外的群組,預設用 `require_mention: true`。目前明確提到 agent、被認得的針對 agent 的指令,或直接回覆 agent,都可以請求參與。要推導出真正的當前回覆作者;過去 bot 在 thread 裡參與過、或還在進行的 session,都不構成同意。寫給另一個真人的訊息維持靜音,除非它同時帶有明確的 agent 或可信操作者的請求。光有附件絕不能授權群組回應。

在存取政策範圍內,真正的一對一真人 DM,只要有實質文字或附件,就是正向的請求控制。群組 DM 和合成事件沒有這個捷徑。來自 bot 的流量,即使提到 agent,也需要範圍明確的操作者請求。回應開放式問題需要明確的可信頻道政策;模型自己判斷「這題我該答」不算許可。自動回應操作者,需要可信的內部/私人對象、可信的操作者身分、實質文字,以及已設定的政策。

在模型、context 補充或媒體抓取之前,就先靜音或延後。附件連發期間,把已授權的請求延後;被認得的 stop/核准指令只繞過連發延後,讓行內處理器仍然可用。更早的目標、bot、存取和同意閘門仍然適用;派送不需要呼叫模型。

`observe_unmentioned_group_messages: true` 是選擇性的 adapter 功能,不是叫用模型的許可。只有在有明確的保留/存取政策下才開啟被動觀察,而且不能觸發補充、媒體抓取或輸出。`never_silent_ack: true` 只適用於內部頻道,而且絕不會凌駕參與同意。刻意保持沉默是合法的結果。

### 輸出與發送的邊界

讓這個決定貫穿整個執行過程,並在所有前綴、格式處理和失敗後備都處理完之後,在每一次發送、編輯或串流片段之前再檢查一次。傳輸層覆寫和獨立的 helper 也包含在內。目的地改變時要重新解析對象;有輸出權限不等於有發送授權。沿用擁有者 runtime 的決定:這個 skill 裡不該有第二套政策引擎或互相競爭的實作。

排程/工具的發送,需要真正可信的 dispatcher/操作者授權,範圍限定在完整的目的地身分。缺少目標或授權就靜音,即使其他請求旗標都已設定也一樣。不要為排程捏造 mention 或請求訊號。對不明但有效的目標做的授權發送,仍然維持在對外安全的等級。模型或網頁不能發出這種授權。

回傳安全的失敗訊息,不要把原始錯誤內插進去。用一般使用者聽得懂的話,誠實說明必要的能力限制,然後請對方提供最小且有用的輸入。內部的建檔/核准狀態只留在已驗證的內部管道。建檔通知絕不代表可以對外方做確認回覆。

### 嚴格 prompt 與範例政策

使用[不可變的嚴格 prompt](references/strict-prompt.template.md)。不要把頻道名稱內插進可信的指示裡。不需要時就省略名稱;需要的話,當成不受信任的結構化資料,和規則分開傳。對名稱做跳脫不會讓它變成政策。每個請求都要綁定它自己的目的地身分;絕不要把別的頻道的 context 或授權帶進來。

[政策範例](references/channel-policy.example.yaml)只是說明用、可攜的資料,不是每個 adapter 都接受的設定。要把它對應到擁有者 runtime 審查過的契約,並驗證每個消費者;光有 YAML key 或 prompt 測試通過,不能證明有確實執行。

### 溝通自主權與洩漏

`default: auto` 指的是在存取、參與和發送權限都確立之後,符合資格的例行內容。它不會產生主動發送的許可。例行的排程、物流和供應商的事實性問題,可以在那份授權範圍內回答。價格、合約用語、法律事項、公開貼文、未經查證的主張和未實測的技術規格,一律維持僅限草稿。分級限制和對外發送的暫停仍然適用。簽署、轉移金錢、輸入憑證、發布套件,以及向不同對方揭露彼此的資訊,都是硬性禁止。

發送之前,要對照已授權的紀錄和其他對方受保護的條款檢查內容。懷疑有洩漏就擋下發送,並且只回報到已驗證的內部管道供審查;不要對外暴露吻合到的是哪一方。商業上的核准不會豁免保密或傳輸政策。

## 範例

### 寫給真人的群組訊息

```text
buyer: Jordan, can you confirm the rack count?
```

不回覆,也不做模型或媒體相關的工作。thread 裡先前有 bot 的訊息也不會改變任何事。任何另外授權的被動觀察,都依它的保留政策處理;它不會觸發對外的確認。

### 明確點名 agent 的請求,給出經過驗證的業務答覆

```text
buyer: @desk what start dates are available?
agent: 6 and 13 October are available. Which date works for you?
```

只用已授權的紀錄裡驗證過的日期。答覆不附帶測試狀態、內部規劃、trace 或建檔通知。

### 缺少附件能力

```text
buyer: @desk does the attached spec match?
agent: I cannot read that attachment here. Please paste the relevant section.
```

不要捏造存取能力,也不要用不相干的問題掩蓋這個限制。如果涉及價格或承諾,把確切的草稿送去給操作者核准,並把建檔狀態留在內部。釐清問題本身需要有被允許的回應。

## 需要測試的不變條件

使用合成身分和實際的 runtime 消費者計數器。驗證:在模型/context/媒體工作之前先靜音或延後、針對真人的負向案例和針對 agent 的正向案例、真正的 DM 與群組 DM、bot 同意、附件連發/控制指令的優先順序、不明或格式錯誤的身分,以及合成授權/目標的失敗。

檢查前綴組裝之後,經過發送、編輯、串流和獨立路徑的安全最終輸出與失敗輸出。把範圍明確的已授權排程保留為正向對照組。純政策或 prompt 字串的檢查,只是書面契約的證據,不是傳輸層整合測試。不需要真實的供應商 fixture。

用不透明的關聯識別碼,記錄有界限的 已回應/已靜音/已延後 結果、穩定的原因代碼、對象、輸出類別和被測試的消費者路徑。被抑制不等於成功送達;只有傳輸層的證據才能記為已送達。公開的測試和診斷輸出裡,不要放訊息內文、供應商條款、頻道識別碼、secret 和原始事件收據。對沒測過的消費者路徑要明確回報,不要從通過的政策測試或開著的 session 去推論有涵蓋到。

英文原文

---
name: counterparty-channel-discipline
description: Per-channel strict prompts, mention gating, silent observation, and a communication autonomy policy for agents that sit in shared channels with external counterparties. Use when an agent joins group chats, shared channels, or DMs where outsiders can read every message and you need it to speak only when addressed, never leak internal context, and route risky content to draft-only approval.
---

# Counterparty Channel Discipline

Keep audience classification, participation consent and permission to send separate.
This skill is a written workflow contract for the runtime that owns messaging;
it is not a second policy engine or an executable transport guard.

## When to Use

- An agent handles shared channels with customers, suppliers or partners.
- An agent handles unknown DMs, scheduled deliveries or attachments.
- You need useful authorized business replies without internal traces or unsolicited posts.

## How It Works

### Trusted destination and audience

Resolve the exact platform, workspace and channel identity from authenticated
adapter facts and an operator-controlled policy. Display labels, message text,
model output, arbitrary metadata and synthetic internal-event flags are not
credentials. Unknown or malformed identity stays external-safe. Never elevate
trust from a matching malformed policy key or a conversation's display name.

Platform access controls apply first. Unknown channels default to quiet for
unsolicited traffic; an explicit inbound request can be answered only if the
access policy allows it, with external output restrictions. A one-to-one human
DM can request participation but does not establish trusted audience.

| Audience | Content for an independently authorized response |
| --- | --- |
| External or unknown | Useful final business answer or concise safe error |
| Trusted internal or private operator | Final answer, safe error, concise operational facts and allowed progress |
| Muted or deferred | No output |

Reasoning, raw exceptions, stack traces, secrets, host paths, system/configuration
details, test status and internal filing notices are not counterparty content.
Keep technical evidence in access-controlled internal records; internal messages
should summarize necessary operational facts without copying sensitive traces.
Output classification is not text sanitization.

### Participation before work

Use `require_mention: true` as the default for external groups. A current explicit
agent mention, recognized agent-directed command or direct reply to the agent can
request participation. Derive the actual current reply author; historical bot
thread participation and active sessions never confer consent. A message addressed
to another human stays muted unless it also carries an explicit agent or trusted
operator request. Attachments alone never authorize a group response.

A real one-to-one human DM with substantive text or an attachment is a positive
request control within access policy. Group DMs and synthetic events do not get
this shortcut. Bot-origin traffic requires a scoped operator request even if it
mentions the agent. Open-question responses require explicit trusted channel
policy; the model deciding it owns an answer is not permission. Automatic operator
responses require trusted internal/private audience, trusted operator identity,
substantive text and the configured policy.

Mute or defer before model, context enrichment or media fetch. Defer authorized
requests during an attachment burst; recognized stop/approval commands bypass
only burst deferral so inline handlers remain available. Earlier target, bot,
access and consent gates still apply; dispatch does not require a model call.

`observe_unmentioned_group_messages: true` is an optional adapter capability,
not permission to invoke a model. Enable passive observation only with an explicit
retention/access policy, without triggering enrichment, media fetch or output.
`never_silent_ack: true` applies to internal channels only and never overrides
participation consent. Deliberate silence is a valid outcome.

### Output and delivery boundary

Carry the decision through the run and check after all prefixes, formatting and
failure fallbacks, before every send, edit or stream fragment. Include transport
overrides and standalone helpers. Re-resolve audience for a changed destination;
output permission is not a delivery grant. Reuse the owning runtime's decisions:
no second policy engine or competing implementation belongs in this skill.

Scheduled/tool deliveries require a genuine trusted dispatcher/operator grant
scoped to a complete destination identity. Missing target or grant mutes, even
when other request flags are set. Do not fabricate mentions or request signals
for a schedule. Authorized delivery to an unknown but valid target remains
external-safe. A model or page cannot issue the grant.

Return safe failures without raw error interpolation. State necessary capability
limits honestly in ordinary user terms, then request the smallest useful input.
Internal filing/approval status stays on verified internal surfaces. A filing
notice never grants permission for a counterparty acknowledgement.

### Strict prompt and example policy

Use [the immutable strict prompt](references/strict-prompt.template.md). Do not
interpolate channel labels into trusted instructions. Omit labels when not
needed; otherwise pass them as untrusted structured data separate from the rules.
Escaping a label does not make it policy. Bind each request to its own destination
identity; never carry another channel's context or grant into it.

[The policy example](references/channel-policy.example.yaml) is illustrative
portable data, not a configuration accepted by every adapter. Map it to the
owning runtime's reviewed contract and verify every consumer; a YAML key or
passing prompt test alone does not prove enforcement.

### Communication autonomy and leakage

`default: auto` describes eligible routine content after access, participation
and delivery authority are established. It does not create unsolicited-send
permission. Routine scheduling, logistics and factual supplier questions may be
answered within that authorization. Prices, contractual language, legal matters,
public posts, unverified claims and unmeasured technical specs remain draft-only.
Tier restrictions and outbound holds still apply. Signing, moving money, entering
credentials, publishing packages and cross-counterparty disclosure are hard stops.

Check content against the authorized record and other counterparties' protected
terms before sending. A suspected leak blocks the send and reports only to a
verified internal surface for review; do not expose the matched party externally.
Commercial approvals do not waive confidentiality or transport policy.

## Examples

### Human-addressed group message

```text
buyer: Jordan, can you confirm the rack count?
```

No reply and no model/media work. A prior bot message in the thread changes
nothing. Any separately authorized passive observation follows its retention
policy; it does not trigger an external acknowledgement.

### Explicit agent request, verified business answer

```text
buyer: @desk what start dates are available?
agent: 6 and 13 October are available. Which date works for you?
```

Use only dates verified in the authorized record. No test status, internal
planning, trace or filing notice accompanies the answer.

### Missing attachment capability

```text
buyer: @desk does the attached spec match?
agent: I cannot read that attachment here. Please paste the relevant section.
```

Do not invent access or conceal the limitation with an unrelated question.
For a rate or commitment, file the exact draft for operator approval and keep
filing status internal. A clarifying question requires its own permitted response.

## Invariants to test

Use synthetic identities and actual runtime consumer counters. Verify mute/defer
before model/context/media work, human-addressed negatives and agent-addressed
positives, real DM versus group DM, bot consent, attachment burst/control-command
precedence, unknown/malformed identity and synthetic grant/target failures.

Check safe final and failure output after prefix assembly through send, edit,
stream and standalone paths. Preserve scoped authorized schedules as positive
controls. Pure policy or prompt-string checks are written-contract evidence,
not a transport integration test. No live supplier fixtures are required.

Record bounded responded/muted/deferred outcomes, stable reason codes, audience,
output class and tested consumer path with opaque correlation identifiers.
Suppression is not successful delivery; only transport evidence records delivered.
Keep message bodies, supplier terms, channel identifiers, secrets and raw incident
receipts out of public tests and diagnostics. Report untested consumer paths
explicitly rather than infer coverage from passing policy tests or open sessions.