E0020: cost_exceeded
E0020 cost_exceeded — a declared cost bound is lower than what the handler can spend.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0020).
The rule
A cost { tokens: N } bound in a cell is checked against the sum of the max_tokens caps of every think() a handler can make. Here two calls capped at 400 and 200 can spend 600 reply tokens, more than the declared 500, so soma check fails. Raise the bound to at least the computed peak, or lower the max_tokens caps; prompt tokens are not counted in this bound.
A program that triggers it
wrong.cell
cell agent Summarizer {
face {
signal summarize(ticket: String) -> String
}
cost { tokens: 500 }
on summarize(ticket: String) {
let gist = think("Summarize this support ticket: {ticket}", map("max_tokens", 400))
let tone = think("Classify the tone of: {ticket}", map("max_tokens", 200))
return "{gist} [{tone}]"
}
}What soma check prints:
$ soma check wrong.cell
warning: agent cell 'Summarizer' has no state machine — add a state section for verified behavior
error: cost: 'tokens' budget exceeded — computed 600 tokens > declared 500 tokens (peak in Summarizer.summarize)
= code: E0020
✗ 1 error(s), 1 warning(s).The fix field of soma check --json: cost: 'tokens' budget exceeded — computed 600 tokens > declared 500 tokens (peak in Summarizer.summarize)
The fix
On line 5, cost { tokens: 500 } becomes cost { tokens: 600 }.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -3,5 +3,5 @@
signal summarize(ticket: String) -> String
}
- cost { tokens: 500 }
+ cost { tokens: 600 }
on summarize(ticket: String) {
let gist = think("Summarize this support ticket: {ticket}", map("max_tokens", 400))With the fix, soma check accepts the program:
$ soma check right.cell
✓ cost: 'tokens' bound proven — peak 600 reply tokens (the max_tokens caps) ≤ declared 600 (prompts are not counted: cap them with set_budget)
warning: agent cell 'Summarizer' has no state machine — add a state section for verified behavior
✓ 1 warning(s), no errors.