User hit 'API error 402: ... You requested up to 131072 tokens, but can only afford 4511' on the assist alias: no provider ever sent max_tokens, so OpenRouter's credit pre-check billed the routed model's full worst-case output; user also asked to bound session history to the last 5 requests/responses. Architect decisions: - AI_MAX_TOKENS (num, default 2048): sent as max_tokens on OpenRouter and generationConfig.maxOutputTokens on Gemini — a real per-request cost ceiling. llamacpp unchanged (local/free, no pre-check). - AI_SESSION_TURNS (num, default 40 kept back-compat; messages, 2 per exchange — 10 = last 5 conversations): resolved lazily in session_push because config loads after the hardcoded line-25 default. - Both registered in the bin/pos-ai POS_CONFIG @General section, so they appear in 'pos config ai' with num: validation. Reviewer hardening (CHANGES_REQUIRED -> fixed): unguarded env input could reach jq tonumber (0/-5/010/abc all savable via config-ui's ^-?[0-9]+$) and abort the CLI; both providers and session_push now guard with ^[1-9][0-9]*$ and fall back to the default. Verified: fake-curl shim smoke (16 provider-body + 12 session-window checks incl. the 010-regression proof), make gen idempotent, make check OK, make lint 0 FAIL/0 WARN, make test 17 files / 299 checks / 0 fail (~49s), bash -n clean, git diff --check clean. Reviewer ACCEPT (twice). Tester regression round (permanent provider-body + session-pruning coverage) intentionally not run this cycle — user's call; remains a documented follow-up.
3.8 KiB
Maintainer Report — AGENT_TODO.md Done entry for AI cost/session-window work
Date: 2026-09-06 Mode: single-file convention edit (AGENT_TODO.md only); no commit; no gates.
TL;DR
Drift: the AI cost & session-window work (OpenRouter 402 + AI_SESSION_TURNS) was finished but had no Done entry — a one-edit-per-commit convention violation. Fix: added ONE dated Done bullet at the TOP of the Done section (2026-09-06, above the existing same-day entries), ~5-8 lines, style-matched to existing entries. Corrected, validated against diff (2 insertions), report written. All constraints honored: touched ONLY AGENT_TODO.md, ran no gates, made no commit.
Step 1: Verify facts before writing
Read AgentsReport/architect/2026-09-06_ai-cost-window-design.md (decisions, defaults, lazy resolution, scope) and AgentsReport/builder/2026-09-06_ai-cost-window.md (implementation + F1 hardening + verification numbers). Cross-checked reviewer 2026-09-06_f1-hardening-recheck.md → Status ACCEPT (after 2026-09-06_ai-cost-window-review.md → CHANGES_REQUIRED, 1 REQUIRED + 1 NOTE) → supports "Reviewer ACCEPT (twice)" with the CHANGES_REQUIRED→fixed flow.
Confirmed the Done-section convention from existing entries (line 6 "newest last", bullet - **YYYY-MM-DD** — <title> … wrapping one paragraph).
[DONE]
Step 2: Insert the Done entry
Added one bullet at the top of the ## Done section (AGENT_TODO.md:45), placing it above the existing pos ai alias same-day entry (per brief: "at the TOP of the Done section … above the existing same-day entries"). Covers:
- 402 root cause (no
max_tokenssent; OpenRouter pre-bills worst-case 131072 vs 4511 balance) + user request to bound session to last-5. - Architect decisions:
AI_MAX_TOKENS(num, default 2048, cost cap) on OpenRoutermax_tokens+ GeminigenerationConfig.maxOutputTokens(llamacpp skipped);AI_SESSION_TURNS(2 msgs/exchange; default 40 back-compat; 10 = last 5) resolved lazily insession_push(config loads after line-25 default); both registered inbin/pos-ai# POS_CONFIG:@General→pos config ai. - Reviewer hardening (CHANGES_REQUIRED→fixed): unguarded env → jq
tonumber(0/-5/010/abc) — both providers +session_pushnow guard^[1-9][0-9]*$fallback-to-default. - Verified: fake-curl shim (16 provider-body + 12 session-window checks incl. 010-regression proof), gen idempotent, check OK, lint 0/0, test 17 files/299 green, Reviewer ACCEPT (twice). Tester round not run (user's call); permanent coverage = follow-up.
Line count: the bullet is ~6 wrapped display lines (single logical line / 2 added physical lines).
[DONE]
Step 3: Validate the correction
git diff --stat AGENT_TODO.md → 1 file changed, 2 insertions(+); git diff AGENT_TODO.md shows only the one added logical line at the top of Done, no other files touched. Verified the entry is above the existing same-day pos ai alias entry and style-matches (bullet, - **2026-09-06** —, inline prose).
Per constraints: no gates run, no commit made.
[DONE]
Handoff
Status: MAINTENANCE_COMPLETE (single-item task, fully satisfied)
Standard enforced: AGENT_TODO.md Done convention — move completed work into Done (dated) in the same-language form used by existing entries.
Files changed: AGENT_TODO.md (1 logical line added at top of Done).
Verification: git diff --stat / git diff — 2 insertions only; correct placement + style confirmed by read.
Scope compliance: in-scope (AGENT_TODO.md only) — no other files, no gates, no commit.
Recommended next agent: Orchestrator (this edit rides the imminent commit; no further Maintainer action).
Reason: nothing else remains in scope; the entry is ready to be committed with the AI cost/session-window work.
Changes made by Maintainer: one Done entry added at the top of the Done section.