Skip to content

fix: approval chats get no prompt when native handler is not running - #148188

Closed
gokay-ai wants to merge 1 commit into
openclaw:mainfrom
gokay-ai:cursor/approval-forward-runtime-gate-5d5c
Closed

gokay-ai wants to merge 1 commit into
openclaw:mainfrom
gokay-ai:cursor/approval-forward-runtime-gate-5d5c

Conversation

@gokay-ai

Copy link
Copy Markdown
Contributor

Fixes #148031

What Problem This Solves

Fixes: an approval raised from a chat that native delivery is configured for gets neither a native prompt nor the forwarded text prompt when that channel's native approval handler is not running.

User Impact

User impact: while a native approval handler is still starting, disabled, or otherwise not running, that chat still receives the forwarded text prompt so the request can be decided before it expires. When the native handler is running, forwarding stays suppressed as before.

Why This Change Was Made

The local prompt path already keeps the prompt unless a native route runtime is actually active. Forwarding now uses the same live-runtime check. The forwarder is not a channel-account task, so it reads the owning Gateway coordinator instead of configuration/route match alone.

Evidence

Focused Vitest on the real forwarder, same Telegram exec-approval config as the issue probe:

  • no active native runtime → forwarded prompt delivered
  • active native runtime → forwarding stays suppressed

node scripts/run-vitest.mjs src/infra/exec-approval-forwarder.test.ts — 29 passed.

pnpm build && pnpm check && pnpm test are in progress against this head and will be recorded here.

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check could not safely complete for this revision.

ClawSweeper will not retry this unchanged revision.

Next step: No contributor action is requested. Maintainers should inspect the linked workflow run.

View the workflow run.

@gokay-ai
gokay-ai marked this pull request as ready for review September 14, 2026 10:42
Copilot AI lite review requested due to automatic review settings September 14, 2026 10:42

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 14, 2026, 7:00 AM ET / 11:00 UTC.

ClawSweeper review

What this changes

The PR checks the owning Gateway’s active native approval handlers before suppressing forwarded approval prompts, with regression tests for Telegram and Discord.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR addresses a defect still present on current main and v2026.9.4. The approach is useful, but the new account lookup can restore duplicate prompts for cross-channel forwarding, and the supplied validation does not establish real delivery.

Priority: P2
Reviewed head: dc0a9e4d18d1bbd5b2d1be0ed2526586a9c9b82b

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair has useful regression coverage, but destination-account handling and real delivery proof remain unresolved.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The forwarder tests exercise active/inactive coordinator state with mocked delivery, but do not show the new Gateway wiring producing an approval prompt in a real chat after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The forwarder tests exercise active/inactive coordinator state with mocked delivery, but do not show the new Gateway wiring producing an approval prompt in a real chat after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Introduced account lookup: The new runtime query uses the request's source account whenever the forwarding target omits accountId, including when source and destination are different channels.
Destination account contract: Native approval account selection resolves explicit forwarding targets without accountId to the destination channel's default account. The runtime coordinator rejects a query naming a different account. Discord's suppression adapter also resolves its own default account rather than inheriting another channel's source account.
Current main still needs the repair: Fetched main still suppresses forwarding solely through the channel adapter, without checking whether a native runtime is active.
Findings 1 actionable finding [P2] Resolve runtime activity against the forwarding destination account
Security None None.

How this fits together

The Gateway forwards pending command and plugin approvals to configured chat destinations. Channel-native handlers can replace those forwarded prompts; the route coordinator records which handlers are running.

flowchart TD
  A[Pending approval] --> B[Resolve forwarding destinations]
  B --> C[Check destination native handler]
  D[Gateway route coordinator] --> C
  C --> E[Channel suppression policy]
  E --> F[Native approval prompt]
  C --> G[Forwarded approval prompt]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The forwarder tests exercise active/inactive coordinator state with mocked delivery, but do not show the new Gateway wiring producing an approval prompt in a real chat after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve runtime activity against the forwarding destination account (P2) - When a request originates on Telegram account work and approvals.exec.targets contains a Discord approver destination without accountId, this queries the Discord runtime for work. Native account selection instead resolves that target to Discord's default account (approval-request-account-binding.ts:60). If that default handler is running, the query still returns false and bypasses Discord's suppressor, so both the native handler and forwarder send a prompt. Resolve the destination account using the existing channel/default-account contract and cover this cross-channel case.
  • Resolve merge risk (P1) - Cross-channel targets that omit accountId can receive both native and forwarded prompts because the new lookup checks an unrelated source account.
  • Complete next step (P2) - Repair destination-account matching and add real approval-delivery proof before merge. Prefer before/after screenshots or recordings where useful; terminal output and runtime logs also count. Redact credentials, IP addresses, phone numbers, private endpoints, and unrelated data. Update the PR body to trigger re-review; if it does not, ask a maintainer to comment @clawsweeper re-review.

Findings

  • [P2] Resolve runtime activity against the forwarding destination account — src/infra/exec-approval-forwarder.ts:167-170
Agent review details

Security

None.

PR surface

Source +31, Tests +77. Total +108 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 34 3 +31
Tests 1 117 40 +77
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 151 43 +108

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #148031
Summary: This PR is an implementation candidate for the reported forwarding gap; the LINE feature carries a related temporary workaround.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Match the destination account (recommended)
    Resolve runtime coverage against the account used by native and outbound delivery, with a regression for cross-channel targets that omit accountId.

Technical review

Best possible solution:

Use the existing destination-account resolution contract for runtime coverage, preserving fallback for inactive handlers and suppression for the actual active destination.

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

Yes, from source: current main suppresses configured native destinations even without a running handler. The introduced duplicate-delivery case follows from a named source account and an explicit Discord target without accountId; neither scenario was executed in this read-only review.

Is this the best way to solve the issue?

The runtime-aware approach is appropriate, but account selection must follow the destination's existing routing contract rather than unconditionally inheriting the source account.

Full review comments:

  • [P2] Resolve runtime activity against the forwarding destination account — src/infra/exec-approval-forwarder.ts:167-170
    When a request originates on Telegram account work and approvals.exec.targets contains a Discord approver destination without accountId, this queries the Discord runtime for work. Native account selection instead resolves that target to Discord's default account (approval-request-account-binding.ts:60). If that default handler is running, the query still returns false and bypasses Discord's suppressor, so both the native handler and forwarder send a prompt. Resolve the destination account using the existing channel/default-account contract and cover this cross-channel case.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against df663a946582.

Labels

Label changes:

  • add P2: This repairs conditional approval-prompt loss while native handlers are unavailable.
  • add merge-risk: 🚨 message-delivery: The introduced account fallback can produce duplicate approval prompts for existing cross-channel forwarding configurations.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The forwarder tests exercise active/inactive coordinator state with mocked delivery, but do not show the new Gateway wiring producing an approval prompt in a real chat after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • add proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The PR changes whether a Telegram approval prompt appears when its configured native handler is inactive.

Label justifications:

  • P2: This repairs conditional approval-prompt loss while native handlers are unavailable.
  • merge-risk: 🚨 message-delivery: The introduced account fallback can produce duplicate approval prompts for existing cross-channel forwarding configurations.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The forwarder tests exercise active/inactive coordinator state with mocked delivery, but do not show the new Gateway wiring producing an approval prompt in a real chat after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The PR changes whether a Telegram approval prompt appears when its configured native handler is inactive.

Evidence

What I checked:

  • Introduced account lookup: The new runtime query uses the request's source account whenever the forwarding target omits accountId, including when source and destination are different channels. (src/infra/exec-approval-forwarder.ts:170, dc0a9e4d18d1)
  • Destination account contract: Native approval account selection resolves explicit forwarding targets without accountId to the destination channel's default account. The runtime coordinator rejects a query naming a different account. Discord's suppression adapter also resolves its own default account rather than inheriting another channel's source account. (src/infra/approval-request-account-binding.ts:60, dc0a9e4d18d1)
  • Current main still needs the repair: Fetched main still suppresses forwarding solely through the channel adapter, without checking whether a native runtime is active. (src/infra/exec-approval-forwarder.ts:147, df663a946582)
  • Latest release retains the defect: The supplied latest release, v2026.9.4, contains the same configuration-only forwarding suppression. (src/infra/exec-approval-forwarder.ts:147, 3a9d69db306c)
  • Existing fallback contract: Documentation preserves local approval prompts when no native runtime is active and distinguishes forwarding configuration from channel-native delivery. The existing local suppression owner already checks runtime activity. Public docs: docs/tools/exec-approvals-advanced.md. (docs/tools/exec-approvals-advanced.md:326, dc0a9e4d18d1)
  • Proof inspected: The captured body and subsequently inspected live body both report 29 Vitest passes. Tests inject a mocked delivery function and synthetic channel adapters; they do not exercise Gateway startup wiring or real chat delivery. The live head remains the pinned review head, and no additional contributor comments supply runtime evidence. (src/infra/exec-approval-forwarder.test.ts:288, dc0a9e4d18d1)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Fix destination-account resolution and add a cross-channel default-account regression.
  • Add redacted after-fix real delivery evidence showing fallback with the native handler inactive and no duplicate prompt when active; include Telegram Test Server proof for the Telegram claim.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Forwarding used to drop the chat prompt whenever native delivery was
configured for that target, even if the handler was deferred, disabled,
or not yet started. Gate fallback suppression on a live native route
runtime, matching the local prompt path, and wire the owning Gateway
coordinator into the forwarder.

Fixes openclaw#148031

Signed-off-by: GokayAI <[email protected]>
@gokay-ai

Copy link
Copy Markdown
Contributor Author

Closing as superseded — #148228 already merged the same fix on main (fba931fc9084, Closes #148031). Rebasing this branch would just replay an older source-account lookup over the landed destination-account owner. Thanks for the review path.

@gokay-ai

Copy link
Copy Markdown
Contributor Author

Superseded by merged #148228.

@gokay-ai gokay-ai closed this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Approval forwarding drops the text prompt while the channel's native approval handler is not running

2 participants