Skip to content

fix(bridge): show full agent activity content in Feishu card#314

Merged
floodsung merged 1 commit into
mainfrom
fix/agent-activity-truncation
May 25, 2026
Merged

fix(bridge): show full agent activity content in Feishu card#314
floodsung merged 1 commit into
mainfrom
fix/agent-activity-truncation

Conversation

@floodsung

Copy link
Copy Markdown
Contributor

Why

The "agent activity" status card emitted between turns by MessageBridge.flushSpontaneous() was dropping most of what each spontaneous event carried.

Root cause

Two compounding bugs in the snippet pipeline (src/bridge/message-bridge.ts):

  1. Per-event 400-char hard slice in extractSpontaneousSnippet. Tool results, plan bodies, and any multi-line progress output got chopped well below the Feishu card's actual capacity.
  2. Only the latest snippet rendered in formatSpontaneousCardBody. The 30s coalesce window (SPONTANEOUS_COALESCE_MS) routinely batches 3-5 events, but the body only showed snippet[N-1] — every earlier event silently vanished.

Fix

  • Raised per-snippet cap to SPONTANEOUS_SNIPPET_MAX_CHARS = 4000 with an ellipsis marker on overflow.
  • Rewrote formatSpontaneousCardBody to render every snippet chronologically, joined by \n\n---\n\n, under a SPONTANEOUS_BODY_MAX_CHARS = 12000 body budget (well under the 28K card hard limit).
  • On overflow, the oldest snippets drop with a prepended _(N earlier events omitted; M shown)_ notice so the user can see the activity is being trimmed.

Tests

tests/message-bridge.test.ts — 34 tests pass. New cases:

  • truncates very long text at the snippet cap with an ellipsis marker
  • does not touch text shorter than the snippet cap
  • renders ALL snippets chronologically with a horizontal-rule separator
  • drops the oldest snippets and prepends an omitted notice when total exceeds the body budget

The "agent activity" status card was hiding most of what each spontaneous
event reported. Two compounding causes:

1. extractSpontaneousSnippet hard-capped each event at 400 chars via a
   raw slice() — long tool results, plan bodies, and progress lines were
   chopped well below the card's actual budget.

2. formatSpontaneousCardBody only rendered the *latest* snippet, dropping
   every earlier coalesced event from view (the 30s debounce window often
   gathers 3-5 events).

Now each snippet caps at 4000 chars with a trailing ellipsis marker, and
the body renders every snippet chronologically joined by horizontal-rule
separators under a 12000-char budget (safely under the 28K card limit).
On overflow, the oldest events drop with a prepended "(N omitted; M
shown)" notice so the user can see the activity is being trimmed.
@floodsung floodsung merged commit 0d083ac into main May 25, 2026
3 checks passed
@floodsung floodsung deleted the fix/agent-activity-truncation branch May 25, 2026 10:29
SimonYeyi pushed a commit to SimonYeyi/metabot that referenced this pull request May 26, 2026
…tics#314)

The "agent activity" status card was hiding most of what each spontaneous
event reported. Two compounding causes:

1. extractSpontaneousSnippet hard-capped each event at 400 chars via a
   raw slice() — long tool results, plan bodies, and progress lines were
   chopped well below the card's actual budget.

2. formatSpontaneousCardBody only rendered the *latest* snippet, dropping
   every earlier coalesced event from view (the 30s debounce window often
   gathers 3-5 events).

Now each snippet caps at 4000 chars with a trailing ellipsis marker, and
the body renders every snippet chronologically joined by horizontal-rule
separators under a 12000-char budget (safely under the 28K card limit).
On overflow, the oldest events drop with a prepended "(N omitted; M
shown)" notice so the user can see the activity is being trimmed.
floodsung pushed a commit that referenced this pull request Jun 15, 2026
GitHub-only commits #312 (ExitPlanMode auto-approve) and #314 (full agent
activity content) are already present in this branch via their internal
equivalents (exit-plan-mode.ts is byte-identical; #314 = internal 8316195).
GitLab is the source of truth, so this branch's tree is kept verbatim (-s ours);
this merge only makes GitHub main an ancestor so the cutover is a clean
fast-forward.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant