Skip to content

v1.36.0 — Practical Memory + Self-Restart + Paraphrase Intents

Latest

Choose a tag to compare

@B2JK-Industry B2JK-Industry released this 09 Apr 22:48
· 36 commits to main since this release
e115a0f

Telegram practical memory, end-to-end self-update + restart, and a comprehensive paraphrase-aware intent layer.

Closes the operator complaints from a real production session: "agent doesn't remember the previous message after a fast-path reply", "stiahni si novu verziu a nasad to fell through to a 180s timeout", "raw Chyba: {\"type\":\"result\",\"subtype\":\"errormaxturns\",...} JSON leaked into chat", and "I want to update + restart from Telegram without SSH-ing into the server".

Highlights

End-to-end Telegram self-update + restart

A single owner-only Telegram message — stiahni si novu verziu a nasad to, update yourself, git pull a reštart, or any of ~30 free-form variants — now performs git fetchgit pull --ff-only → graceful drain → os._exit(0). Systemd / supervisord / docker brings up a fresh process with the new code.

Opt-in via AGENT_SELF_RESTART_AFTER_UPDATE=1 and gated against a detected supervisor (INVOCATION_ID from systemd, AGENT_PROCESS_SUPERVISOR operator override, SUPERVISOR_ENABLED for supervisord, container env / /.dockerenv for docker / kubernetes). The agent refuses to self-kill in an unsupervised environment.

Setup: copy deploy/agent-life-space.service to /etc/systemd/system/, edit user/group/paths (4 lines), systemctl daemon-reload && systemctl enable --now agent-life-space. Full operator handbook in docs/SELF_UPDATE.md.

Practical conversation memory

Every reply path (16 deterministic intents, dispatcher, semantic cache, RAG direct hit, work-queue acknowledgement, deny-guard, main LLM) now writes through one AgentBrain._finalize_reply() so the in-RAM tail and the persistent SQLite store stay in sync. The first message after a process restart hydrates the in-RAM tail from SQLite. The fixes the production complaint that a "hi" → intent reply → "what did I just say?" sequence had zero history when the second message reached the LLM.

In-RAM tail bumped 10 → 20 turns. SQL ordering bug fixed (ORDER BY id DESC instead of timestamp DESC).

Per-chat reply ordering

TelegramBot._chat_locks keeps the reply ordering deterministic inside any single chat while leaving different chats concurrent. Two messages from the same chat can no longer overtake each other.

Paraphrase-aware intent detection

Two precision-first heuristic fallbacks (_looks_like_self_update_question, _looks_like_self_update_imperative) catch free-form variants like "vraj máš novú verziu kde si schopný si aj nasadiť nové veci k sebe je to tak ?" or "stiahni si nový kód z githubu a nahoď ho" without false positives. The negative test set includes the most likely false positives ("stiahni mi obrázok", "pull the milk from the fridge", "aktualizuj toto pdf") to make sure they stay rejected.

Comprehensive timeout normalization

errormaxturns, tooluse, raw result JSON, CLI timeout after Xs, deadline exceeded, asyncio.TimeoutError, request_timeout=N, read timed out — all map to a friendly user-facing sentence. Wired into both the brain path AND the legacy _handle_text path so the production Chyba: {"type":"result","subtype":"errormaxturns",...} leak cannot recur.

New deterministic intents

  • memory_list ("ake su tvoje spomienky?") — reads the live memory store and produces a grounded listing with real counts.
  • context_recall ("prečo si začal s touto temou?", "o čom sme sa bavili?") — reads the in-RAM chat tail and lists the prior turns literally, no LLM.

Both run before the LLM and are zero-cost.

Stats

  • 1967 tests passing (was 1833 before this release; +134 new)
  • 76 new tests in tests/test_telegram_intents.py — parametrized intent detection, brain integration with provider strict-mock, error normalization, paraphrase positives + negatives
  • 16 new tests in tests/test_brain_persistence.py — hydration, idempotent finalize, tail bound, intent persistence
  • 7 new tests in tests/test_telegram_bot_ordering.py — per-chat lock, same-chat serialization, cross-chat concurrency
  • 11 new tests in tests/test_self_update.py — self-restart opt-in, supervisor detection, dirty / up-to-date / diverged refusal
  • ruff check — All checks passed!
  • mypy — 0 issues across 115 source files

Migration notes

  • No breaking changes. Self-restart is opt-in via AGENT_SELF_RESTART_AFTER_UPDATE=1, default OFF. Existing deployments behave identically until the operator opts in.
  • To enable end-to-end Telegram update + restart: see the systemd / supervisord / docker recipes in docs/SELF_UPDATE.md.
  • Default response language is now English. Set AGENT_DEFAULT_LANGUAGE=Slovak (or any other language) to override. The model still matches the user's language on signal regardless.

Bootstrap from a v1.35.0 deployment

Self-update is code; the code has to exist on the server before the agent can use it. v1.35.0 cannot pull v1.36.0 by itself. One last manual bootstrap:

ssh your-server
cd ~/Agent_Life_Space
git pull origin main
sudo cp deploy/agent-life-space.service /etc/systemd/system/
# edit User/Group/WorkingDirectory/EnvironmentFile (4 lines)
sudo systemctl daemon-reload
sudo systemctl enable --now agent-life-space

After this, every future update is just one Telegram message: stiahni si novu verziu a nasad to.

Full per-fix breakdown in CHANGELOG.md.