The rule
An agent edit on an encrypted doc costs the author 1x the raw LLM token count. No multiplier. No markup for encryption overhead. An edit that StackNet reports as{ input_tokens: 1847, output_tokens: 134 }
charges the owner 1847 + 134 = 1981 tokens — the same it would cost if
the doc were plaintext.
Why
Encryption is a product commitment, not a billing surface. We eat the server-side cost of decrypt → LLM → re-encrypt. If we passed that cost through as a markup, we’d be penalising users for opting into the more secure mode. The invariant is enforced by code:/api/docs/:id/agent-editcallsbumpAgentBudgetwith the rawinput_tokens/output_tokensvalues from StackNet’s/v1/chat/completionsresponse, with no numeric transformation.- A smoke test (
lib/docs/__smoke__/metering.smoke.ts) statically inspects the route source and fails CI if anyone adds a multiplier, rounding, orMath.ceilto the budget call.
What the owner sees
In the Usage tab of the share panel:- Doc-wide total today — sum of input + output tokens across all agents
- Per-agent row —
input in · output out = total tokens, plus edits and bytes written - Progress bar when a doc-wide cap is set — turns destructive- coloured at ≥ 90 %
What the agent sees
The response body of each successfulagent-edit:
tokensUsed is the same number added to DocAgentBudget. If a given
edit shows { input: X, output: Y }, the doc owner’s daily budget
moves by exactly X + Y.
Caps
Three layers apply in order, all checked before the LLM is called:1
Burst (5 edits / 60 s per agent)
Defense against a compromised token firing hundreds of edits in a
minute. Hard-coded — the owner can’t raise this.
2
Per-agent daily caps
DocMember.dailyEditCap (default 20) and dailyTokenCap (default
70 000 = 50 k in + 20 k out). Set at invite time, adjustable by
re-inviting.3
Doc-wide daily cap
Doc.dailyTokenCap — sums input + output tokens across all agents
on this doc. Null = no cap. Set from the Usage tab.[agent-edit] cap_hit doc=… agent=… reason=… used=… cap=….
Comparison: encrypted vs plaintext docs
| Scenario | Encrypted doc | Plaintext doc |
|---|---|---|
| Agent asks to add a 3-item list (2k input, 200 output) | 2200 tokens billed | 2200 tokens billed |
| Same edit, doc is 10 KB | 2200 tokens billed | 2200 tokens billed |
| Edit rejected by cap | 0 tokens billed | 0 tokens billed |
| Edit rejected by injection filter | 0 tokens billed | 0 tokens billed |