buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Remote host-agent Activity is typing-only: observer frames fail NIP-44 after trim

Open brandon-btcgroup opened this issue 3 months ago • 2 comments

Remote host-agent Activity goes blank (typing only)

Summary: A host-route buzz-acp agent with BUZZ_ACP_RELAY_OBSERVER=true is mid-turn and Buzz Desktop only shows a typing indicator. The VM logs NIP-44 encrypt failures after the observer trimmer, 4MiB queue drops, and relay quota exceeded. A same-relay Grok host agent on the owner Mac renders Activity fine.

Environment

  • Buzz Desktop 0.5.19 (macOS), owner signed in
  • Remote host: Linux VM, buzz-acp from Buzz_0.5.20_amd64.deb generation / Aug 25 Linux binary (same observer code: fit_observer_event_to_budget present)
  • Agent: Grok ACP (grok agent --always-approve stdio), BUZZ_ACP_AGENTS=2, BUZZ_ACP_RELAY_OBSERVER=true, BUZZ_ACP_AGENT_OWNER set, NIP-OA owner is the signed-in Desktop identity
  • Channel: private stream, large multi-agent turn (tool reads/writes)

Expected

Desktop Activity panel for the remote agent shows tool calls / reads / writes — the same transcript used for locally managed agents — as documented for BUZZ_ACP_RELAY_OBSERVER=true (kind 24200 frames to the owner).

Actual

Desktop shows typing only. VM buzz-acp logs (same window):

failed to encrypt relay observer event: NIP-44 error: message too long
observer publish queue over byte budget; dropped oldest events dropped=1 total_dropped=7 pending_bytes=4131977
relay NOTICE: rate-limited: quota exceeded; retry in 21s

The encrypt error is NIP-44 error: message too long, not PlaintextTooLarge. So fit_observer_event_to_budget (PR #1072) accepted the JSON (≤ 65,535 per OBSERVER_MAX_PLAINTEXT_LEN), then nip44::encrypt still refused it. Those frames are dropped; typing events still ship.

A second host agent on the owner Mac against the same relay has zero of these warnings and Activity works.

Why this looks like a bug

publish_relay_observer_event trims then calls encrypt_observer_payload, whose contract after #1072 is that encrypt should succeed. Remaining frames that fit the JSON cap still fail NIP-44 (padding / off-by-one vs 65,535 is the likely mismatch). Queue overflow and the shared 120 msg/min quota then drop the rest of a high-volume Grok turn. Desktop has no error — only a hanging typing indicator.

Ask

  1. Leave headroom so a trimmed 65,535-byte observer JSON always encrypts under NIP-44 v2 (including padding).
  2. Never drop a frame the trimmer already accepted; log sizes if encrypt still fails.
  3. Surface observer loss in Desktop instead of typing-only.

Related

  • https://github.com/block/buzz/pull/1072
  • https://github.com/block/buzz/pull/4917

brandon-btcgroup avatar Aug 31 '26 04:08 brandon-btcgroup

Your "padding / off-by-one vs 65,535 is the likely mismatch" is correct, and the fix for it has been sitting open since 11 August. #5578 "fix(observer): align NIP-44 plaintext limit". It has had zero reviews and it does not reference this issue, because it predates it by three weeks. I have pointed it back here.

The number you were looking for is 65,408. nostr defines MAX_SUPPORTED_PLAINTEXT_SIZE: usize = 65_536 - 128 and rejects anything above it, while OBSERVER_MAX_PLAINTEXT_LEN in crates/buzz-core/src/observer.rs:25 is 65,535. That is a 127-byte window where a payload clears Buzz's preflight and then dies inside NIP-44, which is exactly the failure you captured.

Second platform, and it is not a rare event. One Windows box running managed agents with the relay observer enabled:

  • 504 occurrences of the same line, NIP-44 error: message too long
  • 15 of 18 agent log files
  • 2026-08-15T10:00:48Z through 2026-09-03T04:32:12Z, still live today
  • no PlaintextTooLarge at all in that window

So this is not specific to your Grok host agent, your Linux VM, or your relay. It reproduces on Windows against a different relay with different agents.

On your three asks, #5578 covers the first one and gives you the second as a consequence, since aligning the budget means a frame the trimmer accepted is one NIP-44 will take. Your third ask, surfacing observer loss in Desktop instead of a hanging typing indicator, is a separate piece of work and nothing open touches it that I could find. That one is worth keeping this issue open for even after #5578 lands.

Confirmed on macOS with Buzz Desktop 0.5.25 and locally managed agents.

During the audited 24-hour window (September 29, 2026, 14:47 UTC through September 30, 2026, 14:47 UTC), managed-agent logs recorded 31 occurrences of:

failed to encrypt relay observer event: NIP-44 error: message too long

The failures affected two agents (29 and 2 occurrences). No identities, credentials, or raw conversation logs are included here.

The exact pinned dependency, nostr 0.44.7, confirms the boundary mismatch:

  • crates/buzz-core/src/observer.rs sets OBSERVER_MAX_PLAINTEXT_LEN to 65,535 bytes.
  • nostr 0.44.7 sets MAX_SUPPORTED_PLAINTEXT_SIZE to 65_536 - 128 (65,408) in src/nips/nip44/v2.rs:35, and rejects larger plaintext in pad at lines 334–335.
  • The ACP observer fitter uses the Buzz constant, so serialized payloads of 65,409–65,535 bytes pass its budget and then fail encryption. publish_relay_observer_event logs the failure and returns without publishing the frame.

A local candidate patch lowers the shared cap to 65,408 and adds regression cases that encrypt/decrypt JSON exactly at the limit and reject JSON one byte above it. Formatting and diff checks passed; Rust tests have not run, and the installed app has not been changed.

This supports the existing diagnosis and proposed fix in #5578. Acceptance should include actual NIP-44 encryption at the maximum accepted serialized size, rather than only checking against the shared constant.

Separately, one burst produced 1,517 queue-budget warnings accounting for 1,727 dropped source observer events. That is the bounded telemetry-overload path, not evidence that regular chat replies failed. Neither the queue overflow nor the encryption warning recurred after this morning's restart in the audited logs.

shanemhamilton avatar Sep 30 '26 14:09 shanemhamilton