Nanobot

Nanobot makes compaction and token pressure visible in chat

Nanobot is exposing manual and automatic compaction as structured lifecycle events, adding per-round context bars, cache-hit details and model generation speed. The system already measured much of this; the change is that operators can now see it survive replay.

← Back to homeOriginal source ↗

HKUDS/nanobot PR #5656 is the inspected primary source: “feat: make context compaction visible in channels.” The related records were inspected as supporting context rather than independent confirmation.

The facts

- HKUDS/nanobot PR #5656 was created 2026-09-04T08:00:36Z and was open at inspection; its title is “feat: make context compaction visible in channels.” - HKUDS/nanobot PR #5660 was created 2026-09-04T09:34:52Z and was closed at inspection; its title is “feat(webui): show model generation speed in context usage popover (#5631).” - HKUDS/nanobot PR #5649 was created 2026-09-03T17:51:54Z and was closed at inspection; its title is “feat(webui): visualize context usage by logical round.” - The repository reported 47713 stars, 765 open issues, default branch main, and last push 2026-09-04T16:32:29Z. - The latest tagged-release baseline checked was v0.3.0 published 2026-07-25T08:08:47Z.

What changed

HKUDS/nanobot PR #5656 reports: Summary add /compact to compact the active session without resetting the conversation emit structured context_compaction lifecycle events for manual, capacity, provider-native, truncation, and idle-timeout compaction keep one stable compaction_id per operation and expose checkpoint_source as llm_summary or raw_fallback render compaction progress and outcomes in WebUI, TUI, and generic channels, including multiple compactions in one turn localize the /compact command palette copy across all supported WebUI locales keep summary text out of channel events while logging successful LLM summaries at DEBUG Behavior notes WebUI shows started live without persisting it, then persists the terminal phase as a durable timeline row. Raw fallback is visually distinguished and remains observable after transcript replay. /new remains a session reset/archive operation and is not treated as active-context compaction. Event delivery failures do not change compaction semantics. Testing focused Python compaction, command, WebUI replay/wire, and WebSocket tests — 136 passed WebUI test suite — 1,137 passed uv run --no-sync basedpyright — 0 errors ruff check nanobot/ bun run build Linear: https://linear.app/nanobot-ai/issue/NAN-44/所有上下文压缩都应在-channel-内可见

HKUDS/nanobot PR #5660 reports: Summary Addresses #5631 (在 webui 里面展示上下文、模型速度这些信息). The composer context usage popover already showed per-round context and token usage; this adds the missing **model generation speed** (tokens per second) beside the existing generation time. The backend already reports the needed data on each turn (measured_completion_tokens paired with generation_ms), so this is a display-only change. Changes lib/format.ts: add formatTokensPerSecond(tokens, ms, locale), returning a localized "N tok/s" string, or null when the inputs cannot yield a meaningful rate (so callers omit the row instead of showing 0 or Infinity). ComposerUsagePopover: carry measuredCompletionTokens on each round and render a **Generation speed** row, in both the visible tooltip grid and the accessible aria-label. ThreadShell: thread measured_completion_tokens through into the round usage summary, falling back to output tokens when absent. i18n: add the speed labels to English and both Chinese locales (生成速度); other locales fall back to the English default until translated. Tests Adds formatTokensPerSecond tests covering the rate calculation, the one-decimal formatting for slow rates, and the guard cases that yield null. Verification tsc -p tsconfig.build.json --noEmit: 0 errors ESLint on changed files: clean vitest run src/tests/format.i18n.test.ts: 7 passed

HKUDS/nanobot PR #5649 reports: Summary Move token usage out of individual assistant messages and into a compact composer popover. Show current context usage as used tokens, context capacity, and percentage. Visualize the eight most recent logical rounds as proportional input-token bars, with the cache-hit portion shown as stripes and aligned input, output, KV cache hit rate, and generation-time details available on hover. Preserve logical-round usage across WebSocket events and transcript replay so the chart survives refreshes. Data design Treat one AgentRunner invocation as one logical round, even when malformed-response recovery requires multiple provider calls. Aggregate usage from internal recovery calls into that round before publishing it. Carry ordered round_usages through the existing turn-complete and session transcript path; the UI does not make a separate usage query. Do not estimate missing historical data or retain compatibility for the superseded, never-merged per-request contract. Verification Ruff checks for all changed Python files Strict BasedPyright check for all changed Python surfaces 421 targeted Python tests 177 targeted WebUI tests Production WebUI build Git whitespace validation

Why it matters

Context loss is hard to govern when compaction is invisible and usage is scattered across messages. Durable lifecycle and round-level telemetry let users distinguish normal compression from a silent fallback. The practical test is whether the system remains bounded and its receipts still describe the action after failure, retry or restart.

Current

The primary record was open when captured on 2026-09-05. The tagged-release baseline was v0.3.0 published 2026-07-25T08:08:47Z. Repository metadata, source bodies, current pull requests and issues, releases, Google News, Hacker News, Lobsters, Metamesh and the rendered ClawCharts row were inspected. ClawCharts selected the subject; it did not prove the claim.

Evidence

The primary URL is https://github.com/HKUDS/nanobot/pull/5656. Supporting records are https://github.com/HKUDS/nanobot/pull/5660 and https://github.com/HKUDS/nanobot/pull/5649. Source bodies, timestamps and states are preserved in the daily evidence bundle. Test counts and reproductions remain attributed to their authors unless identified as independently rerun.

Source boundary

Open work is described as open, closed work as closed, and operator reports as reports. A pull request is evidence of proposed or reviewed direction, not proof of a shipped release. Search residue, package mirrors and historically published source spines were excluded.

Operator take

Use one compaction identity per operation, persist terminal phases rather than transient progress, aggregate recovery calls into their logical round, and omit meaningless rate values instead of displaying zero or infinity. Preserve a before-state receipt, make the smallest reversible change, and verify the original failure independently.

Caveat

Public project records are mutable. Status, scope and evidence can change after publication. This brief records the inspected state and does not authorize changes to a reader’s deployment.

Source inspected; source state, environment and release boundary remain explicit.