Repository navigation
fix(telegram): preserve question choices across button rows - #118049
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 2:38 PM ET / 18:38 UTC. ClawSweeper reviewWhat this changesThe PR preserves canonical Gateway question option ordering in private reply metadata so Telegram buttons resolve the answer selected by the user even when presentation controls are reordered, repeated, split across rows, or partially rendered. Merge readinessThe repair appears to fix a source-proven Telegram callback bug: current main derives a question option index from rendered control position, while this branch uses the Gateway-owned option value and visibly falls back when the mapping is unavailable. Keep this PR open for explicit maintainer handling because it carries the protected Likely related people: Priority: P1 Review scores
Verification
How this fits togetherAgent harnesses create interactive questions and attach private question metadata to their reply payloads. Telegram renders those controls as callbacks, and the Gateway resolves the callback index to the stored question option before recording the answer. flowchart LR
A[Agent question] --> B[Harness reply payload]
B --> C[Telegram renderer]
C --> D[Telegram callback]
D --> E[Gateway question resolver]
E --> F[Recorded answer]
Decision needed
Why: The repository's dependency policy makes personal inspection of sibling Codex source a hard prerequisite for a Codex-related contract verdict, and that source was unavailable in this read-only review environment. Before merge
Agent review detailsSecurityNone. PR surfaceSource +93, Tests +525. Total +618 across 10 files. View PR surface stats
Review metricsNone. Mantis proof suggestionNative Telegram Desktop proof would materially complement the supplied harness by showing reordered and repeated buttons resolving the option the user tapped. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep canonical option ordering at the question producer, map Telegram callbacks through the declared question action value, and retain the text fallback for invalid or ambiguous metadata; complete the direct Codex contract check before merge. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible with high confidence: current main derives question callback indices from local rendered positions, and the branch's integration test demonstrates a reordered/repeated control selecting the wrong canonical option under the old rule. This read-only review did not execute the test. Is this the best way to solve the issue? Yes for the OpenClaw owner boundary: canonical option order belongs at the question producer, and resolving by AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9236fb854c97. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
e22e232 to
66eeaf1
Compare
66eeaf1 to
df92174
Compare
df92174 to
8ef568e
Compare
8ef568e to
deac08c
Compare
deac08c to
26fd60a
Compare
|
Merged via squash.
|
…#118049) Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where Telegram users answering an interactive question could submit the wrong Gateway answer when question buttons were repeated, split across rows, reordered, or displayed as a subset of the available choices.
Why This Change Was Made
The Gateway-owned question producer now carries the bounded canonical option labels through existing private delivery metadata. Telegram resolves each button against that authoritative ordering instead of inferring its answer index from rendering order. Invalid, missing, ambiguous, or unmatched metadata falls back visibly instead of submitting an incorrect answer. No public action shape, Plugin SDK surface, Gateway protocol, or configuration is expanded.
User Impact
Telegram question buttons select the answer users actually tapped, including repeated controls, reordered/subset presentations, row boundaries, mixed controls, and Unicode labels. Unsupported or unsafe question controls retain a visible text fallback.
Evidence
26fd60ad870ea9d34e99c1f653f46d8ba97567f2.gpt-5.6-solhigh-reasoning autoreview with explicit P0–P3 coverage: zero findings, confidence 0.96. Genuine TruffleHog credential scan: clean.QuestionManager, Gateway question handlers, and the default Gateway option resolver; reordered controls persist the canonical selected answer.codex-rs/protocol/src/request_user_input.rs:8,codex-rs/app-server-protocol/src/protocol/v2/item.rs:1603, andcodex-rs/app-server/src/bespoke_event_handling.rs:715preserve canonical ordered option labels.Real behavior proof
The exact reviewed commit
26fd60ad870ea9d34e99c1f653f46d8ba97567f2was synchronized to an isolated Blacksmith Testbox, with five changed production source blobs independently authenticated. A real grammY bot and HTTP client rendered repeated/reordered Telegram controls, the actual Telegram callback handler opened authenticated Gateway WebSocket sessions and resolved the answer through realquestion.get/question.resolveRPC calls, and missing or ambiguous metadata produced visible text without an unsafe clickable button.test/telegram-question-gateway.test.ts(1),src/agents/embedded-agent-subscribe.handlers.tools.test.ts(146),extensions/telegram/src/button-types.test.ts(29), andextensions/telegram/src/interactive-fallback.test.ts(18): 194/194 passed.{ "proof": "real-grammy-real-gateway-client-mocked-bot-api-and-gateway", "head": "26fd60ad870ea9d34e99c1f653f46d8ba97567f2", "canonicalOptions": ["A", "B", "C"], "renderedOptions": ["C", "A", "A", "B"], "rows": [2, 2], "callbackOptionIndex": 2, "selectedAnswer": "C", "fallbackVerdicts": [ { "metadata": "missing", "visibleOption": "C", "unsafeControls": false }, { "metadata": "ambiguous", "visibleOption": "C", "unsafeControls": false } ], "botMethods": ["sendMessage", "answerCallbackQuery"], "gatewayMethods": ["question.get", "question.resolve"], "connectedGatewayClients": 2, "status": "PASS" }The Telegram Bot API endpoint and Gateway server were controlled loopback mocks; grammY, HTTP delivery, callback middleware, the production Telegram callback handler, Gateway authentication/client, canonical answer resolution, and callback acknowledgment were real. No live Telegram account or external Telegram network was used. The remote lease was explicitly stopped and independently verified
completed.Rank-up moves addressed
C, while missing and ambiguous metadata visibly fall back without unsafe controls.codex-rs/protocol/src/request_user_input.rs:8defines orderedVecoptions;codex-rs/app-server/src/bespoke_event_handling.rs:719maps those ordered labels without reordering;codex-rs/app-server-protocol/src/protocol/v2/item.rs:1603defines the stable option-label contract. These sibling Codex sources were personally inspected directly, not inferred from OpenClaw wrappers or review comments.Maintainer review
The repository owner explicitly delegated autonomous landing of low-risk, independently reviewed QA fixes. The acting maintainer personally inspected the sibling Codex source at
codex-rs/protocol/src/request_user_input.rs:8,codex-rs/app-server/src/bespoke_event_handling.rs:719, andcodex-rs/app-server-protocol/src/protocol/v2/item.rs:1603; the ClawSweeper worker could not access that sibling checkout itself. Four fresh independent nonauthor source reviews, the exact-head genuine Sol review, clean TruffleHog scan, exact-head hosted CI, and the authenticated 194-test runtime proof were reviewed before repo-native maintainer preparation.