Repository navigation
Conversation
Greptile SummaryThis PR adds a two-layer bypass for grammY's sequential update processing so that interrupt and steer mode messages can be delivered immediately instead of queuing behind an active handler. The first layer assigns a per-message sequential key (bypassing per-chat serialization), and the second layer skips the inbound debouncer when an active run is detected. A lightweight Confidence Score: 5/5Safe to merge — no correctness or reliability issues found; all edge cases are documented. No P0 or P1 issues found. The two-layer bypass design (sequential key + debouncer skip) is sound, cache key symmetry between population and lookup is correct for both DMs and groups, and the force-detach path for interrupt timeouts is well-tested. All remaining findings are P2 style notes. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/telegram/src/sequential-key.ts
Line: 101
Comment:
**Redundant nullish coalescing**
`threadId` is already typed as `number | undefined`, so `threadId ?? undefined` is equivalent to just `threadId`.
```suggestion
if (options.isRunActiveForChat(chatId, threadId, senderId)) {
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(telegram): bypass grammY sequential ..." | Re-trigger Greptile |
8e07c01 to
820f10c
Compare
57cfb94 to
4f1b1d8
Compare
167877c to
d40b634
Compare
d40b634 to
2f1bbdc
Compare
31e0c71 to
58f756c
Compare
|
Maintainer triage: this is mergeable, but it is a perceived-latency fix rather than the polling-stall fix. The two-layer design looks sound: per-message sequential keys for active steer/interrupt cases, plus debouncer bypass when a run is active. The cache is bounded, the cache key covers chat/thread/sender, and CI is green. Recommendation: merge after a normal rebase/check, but do not treat it as closing #69147/#64288/#66885. It fixes "Telegram feels slow to interrupt/steer while a handler is busy"; the active |
(cherry picked from commit fcc86f0)
(cherry picked from commit f350bb4)
…dit (openclaw#69581) * fix(codex): exclude codex-app-server synthetic apiKey from secrets audit The Codex extension uses the literal string "codex-app-server" as a hardcoded placeholder apiKey in provider.ts, since the real authentication is managed by the app-server transport itself. The secrets audit currently reports this as a real plaintext leak (PLAINTEXT_FOUND), producing a false positive for any user who has configured the Codex harness. Declare it as a plugin-owned non-secret marker in the Codex plugin manifest, so it flows through the standard `listKnownNonSecretApiKeyMarkers()` path alongside `ollama-local`, `lmstudio-local`, `gcp-vertex-credentials`, and `minimax-oauth`. Also extends the existing `model auth markers` unit tests to lock in the behavior. Fixes openclaw#69511 * ci: retrigger checks (no-op) (cherry picked from commit 081da17)
openclaw#69338) When ingestDelta returns null (first empty/commentary delta or unchanged content), the handler returned early, skipping setActivityStatus and armStreamingWatchdog. If all subsequent deltas were also null (e.g. due to phase filtering), the watchdog was never armed and the status bar stayed stale as "idle" while a run was live. Move setActivityStatus("streaming") and armStreamingWatchdog before the null-displayText guard so they fire on every received delta event. Fixes openclaw#34513, openclaw#40824 Co-authored-by: Claude Sonnet 4.6 <[email protected]> (cherry picked from commit 89b6d02)
58f756c to
4070807
Compare
…injection Replace the overly restrictive isStreaming() guard in queueEmbeddedPiMessage and queueReplyRunMessage with a precise agent-loop lifecycle check. The old guard blocked steer messages during tool execution (when isStreaming is false but the agent loop is still running), preventing legitimate steer/interrupt delivery. - Add isStopped() method to EmbeddedPiQueueHandle that returns true when the agent loop is not actively running (before first prompt or after prompt end). During these windows the steering queue is not drained, so messages would be silently dropped. - In attempt.ts, track agentLoopStarted (set immediately before activeSession.prompt()) and agentLoopStopped (set in the prompt finally block). isStopped = !started || stopped. - queueEmbeddedPiMessage and queueReplyRunMessage now check isStopped() instead of isStreaming(), correctly allowing steer during tool execution while rejecting during startup and teardown windows. - In agent-runner.ts, the steer guard uses isActive (run handle exists) instead of isStreaming, matching the broader acceptance window. - Add isStopped?() to ReplyBackendHandle interface. - Remove the now-dead isStreaming param from runReplyAgent and its destructuring in runPreparedReply. - 6 new/updated tests covering: not-streaming+running (tool exec), stopped (teardown), not-yet-started (startup), compacting, and streaming cases. Fixes openclaw#48003 Co-Authored-By: Cha <[email protected]> via OpenClaw
…Operation registries
- Rename forceDetached → waitInterrupted for clarity: the flag indicates
whether the waitForActiveRunEnd was forcefully interrupted, not whether
a detach operation succeeded.
- Two-phase abort: interrupt → waitForEmbeddedPiRunEnd → refreshPreparedState
→ check isActive; if still active, attempt forceDetachActiveRun.
- forceDetachActiveRun return value is advisory — scheduling layer commits
to superseding regardless; createReplyOperation handles residual
ReplyOperation state.
- Stale waiter cleanup: forceDetachActiveRun resolves waiters with false
immediately to prevent leakage.
- Identity-gated force-supersede: createReplyOperation's force now accepts
`{ ifStale: ReplyOperation }`. At the interrupt-retry site in
agent-runner, the stale ReplyOperation is captured synchronously in the
ReplyRunAlreadyActiveError catch, then the retry passes the ref so the
force only fires when the registered op is object-identical to the
original stale one. If a newer request registered during the 500ms wait
window, the retry throws and we return "try again" instead of
preempting the legitimate newer run.
- Creation sequence counter: reply-run-registry tracks a monotonic per-
sessionKey createSeq incremented on every successful createReplyOperation.
The interrupt-retry path captures staleSeq alongside staleReplyOperation
and rejects the retry when seq advanced during its wait. Closes the
window where a newer request supersedes the stale run AND completes
before the older retry wakes — identity-gate alone can't detect that
case because the registry is empty again by retry time.
…ge delivery - Per-message sequential keys for steer/interrupt so they bypass the debouncer and are delivered immediately without waiting for the previous message's response. - Extract resolveEffectiveQueueMode helper (shared with queue/settings.ts) to avoid duplicating the session → channel → global cascade in the Telegram hot path. - Fix stale steer+backlog comparison (normalized to steer-backlog).
4070807 to
4f699be
Compare
|
Codex review: needs changes before merge. Summary Reproducibility: yes. Static current-main proof is high-confidence: ordinary Telegram messages in the same chat/topic share one grammY key, and the same debounce key can keep the second handler behind the first active run before it reaches steer or interrupt scheduling. Next step before merge Security Review findings
Review detailsBest possible solution: Land a narrow replacement or clean rebase that contains only the Telegram delivery bypass, its required active-run seam, focused tests, and a changelog entry, with unrelated branch churn dropped. Do we have a high-confidence way to reproduce the issue? Yes. Static current-main proof is high-confidence: ordinary Telegram messages in the same chat/topic share one grammY key, and the same debounce key can keep the second handler behind the first active run before it reaches steer or interrupt scheduling. Is this the best way to solve the issue? Yes for the two-layer design, no for this branch as the merge vehicle. The maintainable path is the active-run-aware sequential key plus debouncer bypass, delivered as a focused PR coordinated with the core active-run prerequisite. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 76861364197f. |
|
Thanks for the PR. This branch carries release/config churn around the Telegram delivery change, so it is not reviewable as a focused Telegram PR. Please reopen as a narrow PR with only the intended fix. |
Problem
In Telegram, grammY's
sequentializemiddleware serializes all updates for the same chat. When a run is active (e.g., executing a tool call), new messages queue behind it. This prevents:Changes
1. Chat-session cache (
chatSessionCache)Maps Telegram chat IDs → OpenClaw session keys. Capped at 500 entries with LRU eviction. Populated when session state is resolved during message processing.
2. Per-message sequential key
When a run is active for the cached session key AND the queue mode is
interruptorsteer/steer-backlog/steer+backlog, generate a unique per-message key instead of the per-chat key. This lets grammY process the new message concurrently with the running update.3. Lightweight run-active-check module
New re-export path (
pi-embedded-runner/run-active-check.ts) avoids pulling the full embedded-agent module graph intoreply-runtime.ts→ channel plugins. Addresses module boundary concern wherereply-runtimeis a lightweight SDK entry.4. Live config for queue mode decisions
The sequential key bypass reads live config via
loadConfig()instead of the outer config snapshot, so queue mode changes take effect without restart.Dependencies
Clean 3-commit stack on top of the latest prerequisite commits; will rebase away once both merge:
isStreaming→isActive/isStopped)Tests
sequential-key.test.ts,bot.create-telegram-bot.test.ts, etc.): passruns.test.ts,get-reply-run-queue.test.ts,reply-run-registry.test.ts,agent-runner.steer-guard.test.ts): 52/52 passisStreaming/isInterruptMode)Known Limitations
chatSessionCachemaps chat ID → session key; group chats with multiple senders sharing one chat ID work correctly (cache is per-chat, not per-sender)isRunActiveForSessionKeyreturns true; if the cache misses (first message in a chat), the fallback is normal per-chat serializationRelated
Part of a 3-PR fix set for interrupt/steer message delivery:
isStreaming→isActive/isStopped)AI Disclosure