fix(auto-reply): restore per-turn message-tool delivery contract#99389
Merged
Conversation
Addressed source-reply turns now carry the message-tool-only delivery hint in runtime prompt context, matching the room-event per-turn contract without persisting the hint into transcript rows. Surface: auto-reply prompt envelopes and agent messaging guidance. Fixes #99371. Release-note: fixes Telegram group replies under message_tool_only delivery being composed privately instead of being prompted to use message(action=send).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes #99371. Under
message_tool_onlydelivery, directly addressed turns carried no per-turn delivery contract after 63cbb35 removed the inbound delivery hint as duplication: the only remaining statement was one line buried in the appended system prompt (for CLI backends, ~line 595 of a ~54KB appended section behind the harness's own system prompt). In production this swallowed visible replies: the model composed answers as plain final text,source-reply/private-finalkept them private, and ~25 consecutive addressed turns delivered nothing. Success was only intermittent — resumed CLI sessions with a prior in-contextmessagetool call kept working; fresh sessions coin-flipped. The generalized group etiquette line ("message-tool-only delivery does not require visible output … prefer no channel message", e081028) compounded it by reading as license to answer privately.Room-event turns were unaffected because they already carry a per-turn delivery directive. The asymmetry was the bug.
Why This Change Was Made
resolvePerTurnDeliveryDirective(inboundEventKind, sourceReplyDeliveryMode)insrc/auto-reply/reply/prompt-prelude.ts. Room-event wording is moved verbatim (test-pinned, byte-identical);user_request+message_tool_onlyappends the existingMESSAGE_TOOL_ONLY_DELIVERY_HINTconstant to the runtime-only inbound context, adjacent to the current message. Other delivery modes get no directive.buildInboundUserContextPrefix, and the pre-63cbb350566 3-5x duplication does not come back. The hint constant is already a recognizedstrip-inbound-metasentinel, so replayed shipped transcripts keep stripping with zero stripper changes, and the persisted transcript row for the turn stays bare (proven by regression test:currentInboundContextcarries the hint, the transcript row does not).message(action=send)is the path because final text stays private.User Impact
message_tool_onlydeployments (Telegram/Discord group bots) reliably deliver replies to direct mentions again, on both fresh and resumed CLI sessions. Ambient room-event behavior (default-silent, #99144) is unchanged.Evidence
user_request+message_tool_onlyand zero for other modes (reverted fix:expected +0 to be 1); get-reply-run asserts the hint incurrentInboundContextwith a bare transcript row (reverted fix: hint missing); existingstrip-inbound-metatest covers replayed-row stripping.node scripts/run-vitest.mjs(system-prompt, prompt-prelude, get-reply-run.media-only, strip-inbound-meta),pnpm tsgo,pnpm check:test-types, scoped oxlint,pnpm prompt:snapshots:check: exit 0.check:changedon the rebased branch: exit 0 (runtbx_01kwk9dvqegybpsvbfdhw5fd5q).prompt-prelude.ts +27/-5,system-prompt.ts +1/-1; the rest is tests.