-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Per-turn agent input payload duplicates group history and restates sender/delivery facts up to 5x #99218
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.bugSomething isn't workingSomething isn't workingclawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PRMaintainer-authored PR
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.bugSomething isn't workingSomething isn't workingclawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PRMaintainer-authored PR
Type
Fields
Priority
None yet
Per-turn agent input payload carries duplicated history, repeated sender identity, and a 3-5x restated delivery contract
Current behavior
A payload audit of what the agent model receives on a single inbound turn (traced through
src/agents/system-prompt.ts,src/auto-reply/reply/inbound-meta.ts,src/auto-reply/reply/prompt-prelude.ts, and the Telegram body fold, verified againsttest/fixtures/agents/prompt-snapshots/) found the ordering and cache discipline are correct, but the payload carries roughly 700-800 tokens of per-turn overhead on a busy group turn, most of it redundant:Conversation context (untrusted, chronological...)— compact#id <ts> sender: bodylines from the message cache,src/auto-reply/reply/inbound-meta.ts:262-282), and the body separately carries the[Chat messages since your last reply - for context]fold built from the group-history window (extensions/telegram/src/bot-message-context.session.ts:452-474). Core dedupes only its own JSON history block against the chat window (chatWindowCoversHistory,inbound-meta.ts:592,:728); it cannot see or suppress the Telegram body fold. The two windows overlap but differ in selection, so the model sees mostly-the-same messages twice with different ids and formats.formatInboundEnvelope(bot-message-context.session.ts:176-191), repeating channel name, group label, chat id, and full weekday+timestamp+timezone — ~100-130 chars of constant boilerplate per line, up to 50 lines, all already stated once inConversation info.Conversation info.sender/sender_id, a wholeSenderJSON block whoselabelrecombines its own other fields (inbound-meta.ts:642-659), the envelope body line, the chat-window lines, and on Telegram quote-reply turns a seam that renders#59 Pash: [Telegram Ops id:...] Pash: text(inbound-meta.ts:407-441).## Messagingetiquette, group chat context, the per-turnDelivery:hint as the first block of every user message (inbound-meta.ts:554-559); room events addvisible_reply_contract:plus a closing directive while theRoom context:block contains another copy of the hint (prompt-prelude.ts:143-164). The statements agree, but repetition dilutes salience and burns tokens.## Group Chat Contexteven for direct chats (src/agents/system-prompt.ts:1316-1321), and the meta block nests its own## Inbound Contextheading at the same level (inbound-meta.ts:535).Expected behavior
One canonical group-history block per turn in one compact format; constant facts (channel, group label, chat id) stated once per block, not per line; one sender identity statement; one authoritative per-turn delivery-contract statement per layer; chat-type-appropriate headers.
Impact
Every group turn on every channel pays the token cost, and the duplicated near-identical history is the largest single source of model confusion on ambient/group turns — directly relevant to the over-reply behavior tracked in #99142.