fix(auto-reply): single canonical group history and deduped turn metadata#99256
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 6:59 PM ET / 22:59 UTC. Summary PR surface: Source +60, Tests +240. Total +300 across 22 files. Reproducibility: yes. at source level: current main body-folds Telegram group history while core prompt assembly also renders structured chat-window/history and repeated sender/delivery metadata. I did not run a live Telegram transport capture in this read-only review. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land the prompt cleanup only after preserving the public legacy hint export semantics or explicitly accepting that SDK compatibility change, while keeping the Telegram rolling-history and old-transcript stripping behavior intact. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main body-folds Telegram group history while core prompt assembly also renders structured chat-window/history and repeated sender/delivery metadata. I did not run a live Telegram transport capture in this read-only review. Is this the best way to solve the issue? No, not quite: the central prompt cleanup is the right layer, but broadening the public Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3a2baef0bfc6. Label changesLabel justifications:
Evidence reviewedPR surface: Source +60, Tests +240. Total +300 across 22 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Move Telegram group history out of the message body fold and into the structured chat-window context used by the inbound metadata renderer. Preserve outbound self entries, post-self watermarks, recovered forum-topic routing, and richer cached reply/media fields while dropping stale recovered-topic windows.\n\nFixes #99218
Merge sender identity into conversation info, remove duplicate per-turn delivery hints, demote inbound metadata heading, keep room-event default-silent guidance singular, strip rendered chat-window context on replay, and refresh prompt snapshots.
74caaaf to
5b43f21
Compare
|
Maintainer decision on the two P1s:
Proof — accepted as sufficient. Beyond the snapshot/Testbox lanes in the PR body, the change was validated by rendering a real production group turn (real message + 11 cached context messages) through both |
What Problem This Solves
Fixes #99218. A payload audit found the per-turn input the agent model receives carries ~700-800 tokens of redundant overhead on a busy group turn:
Conversation context (untrusted, chronological...)) plus the Telegram body fold ([Chat messages since your last reply - for context]with a full bracket envelope per line). Core'schatWindowCoversHistorydedupe could not see the channel-side fold.Senderblock recombining its own fields, envelope lines, chat-window lines, and a quote-turn seam that rendered#59 Pash: [Telegram Ops id:...] Pash: text).visible_reply_contract:plus two copies of the delivery hint plus the closing directive.## Group Chat Contexteven for direct chats, with a nested same-level## Inbound Contextheading.Why This Change Was Made
One canonical statement per fact makes the payload cheaper and easier for the model to parse — duplicated near-identical history was the largest single source of model confusion on ambient/group turns (directly relevant to the over-reply behavior tracked in #99142).
mergeTelegramGroupHistoryPromptContext, deduped by message id with cache-derived rich rows winning, chronological, watermark semantics preserved (room events keep the full window, addressed turns post-self). Both legacy fold paths (formatTelegramGroupHistoryEntry,buildRecoveredTelegramBody) are deleted.sender: { id, name, username, e164, is_bot }inside Conversation info; standaloneSenderblock deleted; quote-turn header no longer repeats the sender the envelope already names.Delivery:hint is removed (the identical contract is in the system prompt — see snapshot evidence); room events keep exactly one authoritative default-silent directive, preserving fix(auto-reply): default room events to silence #99144 behavior. The retired hint strings moved toLEGACY_MESSAGE_TOOL_DELIVERY_HINTS(recognition-only: strip-inbound-meta, heartbeat-filter, codex attempt-context); exported SDK names unchanged.## Conversation Context(core and the copilot sibling inextensions/copilot/src/attempt.ts), Inbound Context demoted to###.strip-inbound-meta.tskeeps every previously-shipped sentinel (including the removedSenderblock and both old/new chat-window headers) so shipped session history still strips cleanly;extractInboundSenderLabelreads both the old flat and new nested sender shapes.User Impact
Every group turn on every channel gets a smaller, single-format context. Snapshot floor case (Telegram DM, zero history):
userInputText1129 → 1033 chars; group turns save far more since the duplicated history block dominated. No behavior change to reply gating: room-event default-silent (#99144) and group history coverage (#99143, including bot self-replies on ambient turns) are preserved and test-pinned.Evidence
node scripts/run-vitest.mjsacross all touched test files plus an affected-format sweep (22 shards) — green.pnpm tsgo,pnpm check:test-types,pnpm prompt:snapshots:check— green.node scripts/run-vitest.mjs test/extension-test-boundary.test.ts src/scripts/test-projects.test.ts— green.check:changed(tbx_01kwjepxmm4byr12p6qd0xz1tk): all lanes green including Linux prompt-snapshot drift; the singletypecheck core testsfailure was a stale test call-site fixed in-branch, re-proven withpnpm check:test-types.extensions/mattermost/src/channel.test.tsfails identically on cleanmain(1/49); untouched by this branch.