Your Agent Is Leaking Tokens. Build a Decision Ledger on a Free Server
说明与用途
使用免费MonkeyCode服务器构建一个记录每个决策到SQLite账本并在达到令牌预算时停止的代理。
问题
An LLM‑powered agent can repeatedly call the same tool, rephrase, and retry, causing silent token budget leaks without errors.
结果
A lightweight, self‑auditing agent that logs every decision and enforces a token budget, preventing silent leaks on a free server.
工作流
- Provision a free Linux server via MonkeyCode dashboard and install Python 3.10+ and requests
- Export MC_API_KEY, MC_BASE_URL, MC_MODEL, and MC_BUDGET_TOKENS as environment variables
- Create agent.py: initialize SQLite ledger, define call_llm(), a placeholder search_tool(), and main() loop
- In main(), loop while used tokens < BUDGET: call LLM, parse JSON action, execute tool, record decision and token usage in ledger
- Verify token counts from LLM response and update used counter
- Stop loop when budget exceeded or LLM returns stop action
证据
MonkeyCode’s free tier includes a 10M token allowance and a free server option.
The final artifact is a SQLite ledger with a hard token budget.
- 记录日期: 2026-09-06T15:37:08.175Z