Expand description
Per-response character budget (ADR-033) — a port of src/asdecided/mcp/budget.py
(ORACLE-NEXT revision, which adds the items rule). Shared by the CLI
retrieve surface (commands::cmd_retrieve) and the decided-mcp server.
The budget unit is CHARACTERS (Python len of the serialized string —
Unicode code points, not bytes) of the payload serialized as
json.dumps(payload, ensure_ascii=False) with DEFAULT separators — i.e.
", " / ": " WITH spaces (pyjson::dumps_compact). The docstring in the
oracle says “no spaces”; the code does not pass separators, so the wire
truth is with spaces (PORT-CONTRACT.d/10 §2) — port the code, not the
comment.
Truncation is deterministic and whole-item wherever a repeated collection is involved. Every successful payload is either reduced to the configured character budget or replaced with a small explicit budget error; an over-budget success is never returned.
Constants§
- BUDGET_
ERROR - BUDGET_
ERROR_ HINT - DEFAULT_
BUDGET - HINT_
CONTENT - HINT_
RELATED - HINT_
RETRIEVE - HINT_
SEARCH - HINT_
SUMMARY - MARKER_
HINT - MARKER_
OMITTED - MARKER_
TRUNCATED - MIN_
BUDGET - Smallest supported configured budget. This leaves room for a structured budget error when fixed response fields alone cannot fit.
Functions§
- char_
len len(text)in Python — code points, not bytes.- py_
slice_ to text[:stop]with Python slice semantics (negative stop trims the tail; the truncators only pass non-negative stops, but the retrieve excerpt share can go negative).- serialize
budget.serialize(payload, budget).- valid_
configured_ budget - validate_
call_ budget