Skip to content

fix(telegram): route /new, /reset to control lane to bypass queue - #71563

Closed
kiranvk-2011 wants to merge 1 commit into
openclaw:mainfrom
kiranvk-2011:fix/telegram-control-commands-bypass-v2
Closed

kiranvk-2011 wants to merge 1 commit into
openclaw:mainfrom
kiranvk-2011:fix/telegram-control-commands-bypass-v2

Conversation

@kiranvk-2011

@kiranvk-2011 kiranvk-2011 commented Apr 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Session lifecycle commands (/new, /reset) were getting queued behind active agent runs in the Telegram sequential key system. When a user sent one of these commands while an agent was running, the command would be queued and never execute until the agent finished — defeating the purpose of these interrupt commands.

Solution

Added resolveSessionControlCommand() function to extensions/telegram/src/sequential-key.ts that detects session lifecycle commands and routes them to the :control lane, bypassing the per-topic sequential queue.

Changes

  • extensions/telegram/src/sequential-key.ts: Extracted shared command resolution into resolveControlCommand() predicate-based helper, added resolveSessionControlCommand() for /new and /reset
  • extensions/telegram/src/sequential-key.test.ts: Added test coverage for session control command routing

Technical Details

The fix follows the same pattern as the existing resolveStatusCommandControlLane():

  1. Normalizes the command body using normalizeCommandBody()
  2. Resolves text aliases using maybeResolveTextAlias()
  3. Looks up the command in listChatCommands()
  4. Returns true if the command key is new or reset

When detected, these commands route to telegram:${chatId}:control instead of the normal per-topic lane, bypassing the queue and executing immediately.

Testing

  • Added test cases for /new and /reset routing to control lane
  • Includes test for bot-username suffixed command (/new@bot)

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S labels Apr 25, 2026
@greptile-apps

greptile-apps Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds resolveSessionControlCommand() to route /new, /reset, and /clear commands to the telegram:${chatId}:control lane, bypassing the per-topic sequential queue so these session lifecycle commands execute immediately even when an agent run is active. The implementation faithfully mirrors the existing resolveStatusCommandControlLane pattern and is integrated in the correct position in the routing chain.

Confidence Score: 4/5

Safe to merge; only a minor style concern about code duplication.

No P0 or P1 issues found. The single P2 (duplicated resolution logic between the two helper functions) does not affect correctness or safety.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/telegram/src/sequential-key.ts
Line: 51-71

Comment:
**Significant code duplication with `resolveStatusCommandControlLane`**

`resolveSessionControlCommand` is an almost verbatim copy of `resolveStatusCommandControlLane` — identical `normalizeCommandBody` call, `maybeResolveTextAlias` lookup, and `listChatCommands().find()` — differing only in the final predicate. Consider extracting the shared resolution logic into a single private helper so both call-sites share it, reducing future maintenance surface.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(telegram): route /new, /reset, /clea..." | Re-trigger Greptile

Comment on lines +51 to +71
function resolveSessionControlCommand(params: {
rawText?: string;
botUsername?: string;
}): boolean {
// Session lifecycle commands (/new, /reset, /clear) must bypass the per-topic
// sequential queue so they execute immediately even when an agent run is active.
// Without this, these commands get queued behind the running turn and never
// actually reset the session.
const normalizedBody = normalizeCommandBody(
params.rawText?.trim() ?? "",
params.botUsername ? { botUsername: params.botUsername } : undefined,
);
const alias = maybeResolveTextAlias(normalizedBody);
if (!alias) {
return false;
}
const command = listChatCommands().find((entry) =>
entry.textAliases.some((candidate) => candidate.trim().toLowerCase() === alias),
);
return command?.key === "new" || command?.key === "reset" || command?.key === "clear";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Significant code duplication with resolveStatusCommandControlLane

resolveSessionControlCommand is an almost verbatim copy of resolveStatusCommandControlLane — identical normalizeCommandBody call, maybeResolveTextAlias lookup, and listChatCommands().find() — differing only in the final predicate. Consider extracting the shared resolution logic into a single private helper so both call-sites share it, reducing future maintenance surface.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/telegram/src/sequential-key.ts
Line: 51-71

Comment:
**Significant code duplication with `resolveStatusCommandControlLane`**

`resolveSessionControlCommand` is an almost verbatim copy of `resolveStatusCommandControlLane` — identical `normalizeCommandBody` call, `maybeResolveTextAlias` lookup, and `listChatCommands().find()` — differing only in the final predicate. Consider extracting the shared resolution logic into a single private helper so both call-sites share it, reducing future maintenance surface.

How can I resolve this? If you propose a fix, please make it concise.

@kiranvk-2011

Copy link
Copy Markdown
Contributor Author

Greptile P2: Resolved ✅

Comment: Significant code duplication between resolveStatusCommandControlLane and resolveSessionControlCommand.

Fix: Extracted shared resolution logic into resolveControlCommand() — a generic helper that accepts a predicate function. Both call-sites now use it:

function resolveControlCommand(\n  params: { rawText?: string; botUsername?: string },\n  predicate: (command: { key: string; category: string }) => boolean,\n): boolean {\n  const normalizedBody = normalizeCommandBody(...);\n  const alias = maybeResolveTextAlias(normalizedBody);\n  if (!alias) return false;\n  const command = listChatCommands().find(...);\n  return command ? predicate(command) : false;\n}\n\nfunction resolveStatusCommandControlLane(params) {\n  return resolveControlCommand(params, (cmd) =>\n    cmd.category === "status" && cmd.key !== "export-session");\n}\n\nfunction resolveSessionControlCommand(params) {\n  return resolveControlCommand(params, (cmd) =>\n    cmd.key === "new" || cmd.key === "reset" || cmd.key === "clear");\n}\n```

Net change: **0 lines added** (19 removed, 19 added — pure refactor).

Thanks for catching this!

@kiranvk-2011 kiranvk-2011 changed the title fix(telegram): route /new, /reset, /clear to control lane to bypass queue fix(telegram): route /new, /reset to control lane to bypass queue Apr 25, 2026
@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep this PR open: current main and the latest release still route /new and /reset through the normal Telegram chat/topic lane, but the branch is not merge-ready because targeted command forms can still miss the control lane, tests are missing, and real Telegram proof is absent.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main and v2026.6.9 route /stop and read-only status commands to Telegram control lanes while /new and /reset fall through to normal chat/topic routing. I did not run a live Telegram repro in this read-only review.

Is this the best way to solve the issue?

No, not yet. The owner surface is right, but the best fix should handle targeted suffixes without bot metadata, add focused tests, and include real Telegram proof before merge.

Security review:

Security review cleared: The diff only changes Telegram sequential-key classification in TypeScript and does not touch secrets, dependencies, CI, package metadata, permissions, or code-download paths.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-25T11:51:54Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is missing and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • vincentkoc: Recent current-main history and blame for sequential-key.ts and its tests point to commits c645ec4 and 720e295 carrying the present control-lane shape. (role: recent area contributor; confidence: medium; commits: c645ec4555c0, 720e295cff18; files: extensions/telegram/src/sequential-key.ts, extensions/telegram/src/sequential-key.test.ts)
  • ngutman: Authored the /btw side-question lane work in the same Telegram sequential-key helper and tests. (role: adjacent feature owner; confidence: medium; commits: 9aac55d30614; files: extensions/telegram/src/sequential-key.ts, extensions/telegram/src/sequential-key.test.ts)
  • nk3750: Credited in the merged Telegram approval-callback separate-lane precedent in the same helper and tests. (role: adjacent sequentialization contributor; confidence: medium; commits: 22b53a4973d5; files: extensions/telegram/src/sequential-key.ts, extensions/telegram/src/sequential-key.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 9405b8f075ab.

@kiranvk-2011
kiranvk-2011 force-pushed the fix/telegram-control-commands-bypass-v2 branch from 7599444 to 5e06249 Compare April 27, 2026 01:06
@kiranvk-2011
kiranvk-2011 requested a review from a team as a code owner April 27, 2026 01:06
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L and removed size: S labels Apr 27, 2026
@kiranvk-2011
kiranvk-2011 force-pushed the fix/telegram-control-commands-bypass-v2 branch from 5e06249 to eb4e371 Compare April 27, 2026 01:07
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed docs Improvements or additions to documentation size: L labels Apr 27, 2026
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 12, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@clawsweeper

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@kiranvk-2011 thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@clawsweeper

clawsweeper Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@kiranvk-2011 thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 19, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 24, 2026

This branch had an error being deployed

1 failed deployment
qa-live-shared — cdd04d77 Deployed Jun 19, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #199514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant