Low-Cost LLMs, Six Iterations: Building a Personal Year-in-Review Tool
A local-first year-in-review tool that maps every conclusion back to source text, uses semantic analysis instead of word clouds, and keeps costs low with SQLite, OS keychain secrets, resumable queues, and tiered model calls. This article covers a four-layer architecture, chunk-to-summary-tree analysis, a six-round human–AI build loop, observability, and common pitfalls.
Why personal year-in-review is worth doing again
For years, platform “year in review” products have mostly done three things: count posts, generate a word cloud, and fill a fixed template with generic commentary. The core failure is that those outputs have no traceable mapping to what you actually wrote—each sentence, each reversal of opinion, each mistake. Conclusions cannot be verified or challenged, so they carry little information value.
A useful personal review tool should meet at least four conditions:
- Traceable: every claim points back to a specific passage and timestamp.
- Semantic, not lexical: detect topic shifts, stance changes, and interest drift—not word frequencies.
- Local-first: source content and the final report stay on the machine; credentials never sit in plaintext files.
- Cost-controlled: repeated long-context inference must be cheap enough to run casually.
Recent model economics make the fourth point a given rather than a constraint: per-token cost has dropped by an order of magnitude, and long-context understanding is strong enough for document-level synthesis. Personal tooling becomes viable: capabilities that once meant buying SaaS can be replaced with a few dozen lines of glue code and a local database.
Architecture: four local-first layers
Split the system into four layers with explicit data contracts so model-calling logic does not leak into business logic.
2.1 Data layer: single-file embedded database
Use an embedded relational store (e.g. SQLite) as the single source of truth: zero ops, one-file backups, transactions. Core schema:
CREATE TABLE posts (id TEXT PRIMARY KEY, -- platform content idtitle TEXT NOT NULL,body TEXT NOT NULL,published_at TEXT NOT NULL,raw_hash TEXT NOT NULL, -- incremental fetch dedupfetched_at TEXT NOT NULL);CREATE TABLE analyses (post_id TEXT NOT NULL,dimension TEXT NOT NULL, -- topic / stance / sentiment / stack, etc.payload TEXT NOT NULL, -- structured JSONmodel_tier TEXT NOT NULL, -- for cost attributiontokens_in INTEGER,tokens_out INTEGER,created_at TEXT NOT NULL,PRIMARY KEY (post_id, dimension));
raw_hash plus the composite key (post_id, dimension) are the basis for incremental reruns and “do not bill twice for the same call.”
2.2 Credential layer: OS keychain
Platform tokens and model API keys must not live in config or env files. Read them from the OS keychain / credential manager. Keep a thin abstraction for portability:
def get_secret(key: str) -> str:# macOS Keychain / Windows Credential Locker / Linux Secret Servicereturn keyring.get_password("annual-review", key)
2.3 Scheduler: a resumable local queue
Fetch and analysis are long-running and interruptible. Assume failure. A minimal queue is one table plus a loop:
def run_queue(worker, batch=20):while True:rows = db.query("""SELECT id FROM tasksWHERE status = 'pending' AND attempts < 5ORDER BY priority DESC LIMIT ?""", batch)if not rows:breakfor (tid,) in rows:db.execute("UPDATE tasks SET status='running' WHERE id=?", (tid,))try:worker(tid)db.execute("UPDATE tasks SET status='done' WHERE id=?", (tid,))except RateLimitError:db.execute("UPDATE tasks SET status='pending' WHERE id=?", (tid,))time.sleep(backoff())except Exception as e:db.execute("UPDATE tasks SET attempts=attempts+1, last_error=? WHERE id=?",(str(e), tid))
Keep a three-state machine: pending / running / done. Failures roll back to pending and increment attempts; over the threshold, human intervention. Treat rate limits separately from business errors: backoff vs. log-and-continue.
2.4 Model layer: tiers and a budget gate
Do not run every task on one model tier. Split by whether deep semantic reasoning is required:
| Tier | Tasks | Input scale |
|---|---|---|
| Light | tagging, clustering, extractive summary | per-post chunks |
| Deep | multi-year stance evolution, interest-shift attribution | concatenated posts / summary tree |
| Fallback | retry after structured-output validation fails | single item |
Gate every call so a bad loop cannot burn a month of quota:
def guarded_call(prompt, tier, budget):est = estimate_tokens(prompt)if spent_today() + est > budget.daily:raise BudgetExceeded()resp = llm.chat(prompt, tier=tier)budget.record(resp.usage)return resp
Long-text semantics: chunks to structured output
The hard part is not “reading it all” but producing conclusions you can check. Three steps.
Step 1 — Chunk and extract per post. Split on semantic boundaries (title + body). Ask one dimension per chunk; require JSON:
You are a content analyzer. Using only the given text, output JSON:{"topics": [string], "stance": "support|neutral|oppose","key_claims": [string], "evidence_span": [string]}Constraints: do not introduce information outside the text;evidence_span must be contiguous excerpts from the original.
evidence_span is the traceability backbone: every judgment in the report hangs on a quote the user can jump to.
Step 2 — Aggregate with a summary tree. When per-post results explode, merge by month, then by year (two or three layers). The deep-tier model only sees the aggregate layer, cutting input size by one or two orders of magnitude.
Step 3 — Trend and reversal detection. Sliding-window compare timestamped stance sequences. Mark intervals where stance or topic sets change sharply—“thought reversal” points. This is rule-based, uses no tokens, and often yields the highest-signal findings.
Human–AI development: six iterations
Building the tool is itself a human–AI loop. Do not dump the whole spec once; cut the goal into verifiable steps:
- Round 1 — API alignment: feed official platform API docs to a coding assistant; produce auth, pagination, rate-limit skeletons and retry policy.
- Round 2 — Scope: planning prompts lock architecture, UI, and product boundaries (local storage, keychain secrets, no heavy third-party deps).
- Round 3 — Parallel tracks: decompose and run UI, backend scheduling, unit tests, and prompt architecture in parallel.
- Round 4 — Integration: resume and dedup so a crash-and-reenter does not duplicate data.
- Round 5 — Output validation: JSON Schema plus retry so hallucinated structure never hits the DB.
- Round 6 — Regression and wrap-up: tests, logs, cost reports, end-to-end run.
Each round must ship a runnable artifact and a clear acceptance test, or iteration collapses into unbounded string concatenation.
Cost, observability, and safety
- Cost attribution:
analysesstores tier and tokens per call; roll up by dimension to see where money goes and which dimensions can drop a tier. - Cache first: cache key
raw_hash + dimension + prompt_version; invalidate only when the prompt version changes. - Logs and alerts: structured logs for duration, failure rate, daily spend; wire a general log/metrics stack and alert on failure rate or spend thresholds.
- Data minimization: fetch only fields needed for the review; generate reports locally. If you sync across devices, upload aggregated summaries only—raw body never leaves the machine.
- Trust: every conclusion must carry evidence spans and a confidence flag; drop untraceable claims instead of letting the model “fill in.”
Common pitfalls
- Putting credentials in config files—the most frequent and most dangerous mistake.
- No
raw_hashdedup; one rerun doubles the data. - Stuffing a full year of text into one context window; silent truncation after overflow distorts conclusions.
- Skipping structured-output validation; dirty rows in the DB are hard to unwind.
- No budget gate; debug loops cause surprise spend.
- Word-frequency only: treating “frequent” as “important.”
Closing
Cheap models change the economics of personal tools, not a single capability. When a semantic call is cheap enough to ignore, work that was “not worth automating” becomes automatable. The scarce skill shifts from writing code to defining the problem, slicing tasks, and designing verifiable acceptance criteria. Keep data local, hang conclusions on evidence, and cut iteration into six runnable pieces—that is what lets a personal AI tool keep running.
