feat: dialogue confirmation loop for Telegram agents - #5
Draft
Secret297-CODER-SOURCE with Copilot wants to merge 2 commits into
Draft
feat: dialogue confirmation loop for Telegram agents#5Secret297-CODER-SOURCE with Copilot wants to merge 2 commits into
Secret297-CODER-SOURCE with Copilot wants to merge 2 commits into
Conversation
- Add `pendingConfirmation` and `confirmationRequired` fields to `SessionEntry` - New `dialogue-confirmation.ts`: confirmation/rejection detection (English + Russian), agent confirmation-request detection, prompt injection helpers, session state updaters - New `commands-dialogue.ts`: /confirm, /reject, /agree, /yes, /no, /cancel and /dialogue status|confirm-required on|off command handlers - Register `handleDialogueCommand` in `commands-core.ts` - Integrate confirmation loop into `get-reply-run.ts`: inject pending-confirmation notes into system prompt, detect natural-language yes/no in user messages, and auto-set `pendingConfirmation` when agent response requests confirmation - 25 new tests in `dialogue-confirmation.test.ts` Co-authored-by: Secret297-CODER-SOURCE <73541046+Secret297-CODER-SOURCE@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add conversational loop for Telegram agents
feat: dialogue confirmation loop for Telegram agents
Mar 6, 2026
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.
Telegram agents had no mechanism to maintain a confirmation-pending state across turns — each response was stateless with respect to whether the agent was awaiting user agreement. This adds a session-persisted confirmation loop so agents can block progression until the user explicitly confirms or rejects.
Summary
pendingConfirmation/confirmationRequiredsession fields, a newdialogue-confirmationmodule with English+Russian detection, prompt injection helpers, auto-detection of agent confirmation requests, and/confirm//reject//dialoguecommands.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
pendingConfirmation: { task, sentAt }persisted to the session store when an agent response contains a confirmation request (e.g. "Please confirm", "Shall I proceed?", "Подтвердите").pendingConfirmationis set, the next inbound message is inspected for natural-language yes/no (English + Russian). Confirmed → agent body prepended with[User confirmed the pending action]. Rejected →[User rejected/cancelled the pending action].[Dialogue state: awaiting user confirmation]note; whenconfirmationRequiredis enabled, it receives[Dialogue mode: confirmation required]./confirm(aliases:/agree,/yes) — explicitly confirm; clearspendingConfirmation/reject(aliases:/cancel,/no) — explicitly reject; clearspendingConfirmation/dialogue status— show pending state + mode/dialogue confirm-required on|off— toggle session-level confirmation-required modeSecurity Impact (required)
NoNoNoNo— new commands are info/state-only, no exec surfaceNo— writes only to the existing per-session store entryRepro + Verification
Environment
channels.telegramconfigSteps
pendingConfirmationset in session store; agent next turn includes the pending note in system prompt./confirm//rejectcommands explicitly.Expected
Actual
Evidence
25 new unit tests in
dialogue-confirmation.test.tscoveringisConfirmationResponse,isRejectionResponse,agentResponseRequestsConfirmation, and prompt builders. All 462 existingauto-reply/reply/tests and 73 session/Telegram tests continue to pass.Human Verification (required)
\bboundary issue (fixed — JS regex\bdoesn't work with Cyrillic; replaced with(?:^|\s)…(?:\s|$)anchors). Mixed-case confirmation strings. Empty strings. Sessions withoutpendingConfirmationset.Compatibility / Migration
Yes— new fields are optional onSessionEntry; no existing behavior changesNoNoFailure Recovery (if this breaks)
handleDialogueCommandfrom theHANDLERSarray incommands-core.ts; revert theextraSystemPromptandapplyConfirmationContextadditions inget-reply-run.ts.src/auto-reply/reply/get-reply-run.ts,src/auto-reply/reply/commands-core.ts[User confirmed]prefixes on unrelated "yes" messages in contexts wherependingConfirmationwas never set — not possible by design (guard isif (!pending) return body).Risks and Mitigations
/\b(yes|confirm|proceed|agree)\b/icould match "I don't agree with that" and incorrectly treat it as a confirmation.pendingConfirmationis actively set (not on every message). Short-pattern matches like\b(yes)\brequire a pending state to fire. False positives clear the state but don't block the user; the agent sees the full message and can handle ambiguity.setConfirmationPendingIfRequestedfires on every agent response, adding a store write on any response containing common phrases.updateSessionStoreused throughout the codebase.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.