Skip to content

fix(outbound): auto-select single enabled message account - #85671

Closed
HemantSudarshan wants to merge 3 commits into
openclaw:mainfrom
HemantSudarshan:hemant/fix-message-account-selection
Closed

HemantSudarshan wants to merge 3 commits into
openclaw:mainfrom
HemantSudarshan:hemant/fix-message-account-selection

Conversation

@HemantSudarshan

@HemantSudarshan HemantSudarshan commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #20756.

  • Add a shared outbound message account resolver after channel selection.
  • Preserve explicit accountId, CLI/default account overrides, and agent binding account IDs before inference.
  • When the message tool omits an account, prefer an enabled configured default account; otherwise auto-select exactly one enabled configured account and fail clearly for zero or multiple choices.
  • Leave accountless plugin/test-channel dispatch untouched so plugin-owned behavior and context guards still run.
  • Enforce cross-context send policy before inferred account validation so security denials are not masked by account setup errors.
  • Document the omitted-account behavior in the channel routing and message CLI docs.

No changelog entry is included because contributor-authored PRs should leave changelog credit/addition to maintainers during landing.

Verification

  • git fetch --all --prune
  • git rebase upstream/main
  • node scripts/run-vitest.mjs src/infra/outbound/channel-selection.test.ts src/infra/outbound/message-action-runner.plugin-dispatch.test.ts src/infra/outbound/message-action-runner.core-send.test.ts src/infra/outbound/message-action-runner.context.test.ts
  • node scripts/run-vitest.mjs src/infra/outbound/message.channels.test.ts src/infra/outbound/message-action-runner.media.test.ts src/infra/outbound/message-action-runner.poll.test.ts extensions/whatsapp/src/send.test.ts extensions/whatsapp/src/active-listener.test.ts
  • pnpm exec oxfmt --check --threads=1 src/infra/outbound/channel-selection.ts src/infra/outbound/message-action-runner.ts src/infra/outbound/channel-selection.test.ts src/infra/outbound/message-action-runner.plugin-dispatch.test.ts src/infra/outbound/message-action-runner.core-send.test.ts src/infra/outbound/message-action-runner.context.test.ts docs/channels/channel-routing.md docs/cli/message.md
  • pnpm docs:check-mdx docs/channels/channel-routing.md docs/cli/message.md
  • git diff --check
  • pnpm check:changed

Real behavior proof

Behavior addressed: omitted message-tool accountId no longer falls through to a disabled default account when the selected channel has exactly one enabled configured account.

Real environment tested: local OpenClaw checkout on Windows 11, branch hemant/fix-message-account-selection, rebased onto current upstream/main (99a1107b61) and pushed as head 90a5c78a3b.

Exact steps or command run after this patch: the verification commands listed above were run after formatting the patch, after the CI-regression adjustments for accountless plugin dispatch and cross-context policy ordering, and again after rebasing onto latest upstream.

Evidence after fix: focused resolver and plugin-dispatch tests pass, including the regression where default is disabled and xiaomi is the only enabled configured account; the CI-failing core send/context test files also pass after preserving accountless plugin dispatch and enforcing context policy before account inference. Docs MDX, formatting, diff whitespace, and check:changed all exit successfully.

Observed result after fix: account-aware plugins get inferred account selection before dispatch; accountless plugins continue without injected accountId, and cross-context denials are raised before account setup validation can mask them.

What was not tested: live WhatsApp delivery was not run. The remote Crabbox/Testbox wrapper could not start in this environment because its binary failed its own sanity check; direct pnpm tsgo:core was also blocked locally by an existing Windows path-with-space invocation issue, while pnpm check:changed completed successfully.

Copilot AI review requested due to automatic review settings May 23, 2026 08:11
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 8:46 PM ET / 00:46 UTC.

Summary
The PR adds shared outbound message-account inference after channel selection, updates message-action dispatch, adds resolver/dispatch tests, and documents omitted-account behavior.

PR surface: Source +142, Tests +260, Docs +7. Total +409 across 6 files.

Reproducibility: yes. at source level: current main leaves accountId unset unless it is explicit/default/bound, and WhatsApp omitted-account sends then ask the default helper. I did not run a live WhatsApp or CLI send in this read-only review.

Review metrics: 1 noteworthy metric.

  • Omitted-account fallback policy: 1 fallback/default path changed. The PR changes how omitted account IDs behave in multi-account outbound sends, which maintainers should review for upgrade compatibility before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #20756
Summary: The linked issue is the canonical omitted-account auto-selection report, and this PR is the active implementation candidate; related accountId items overlap but do not supersede it.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal output, logs, screenshot, recording, copied live output, or a linked artifact from a real omitted-account CLI or plugin run.
  • Rebase on current main or provide a maintainer-editable replacement branch.
  • Regenerate and review the drifted prompt snapshots.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists local tests and narrative observed results, but it does not include redacted terminal output, logs, copied live output, screenshot, recording, or a linked artifact showing the after-fix omitted-account behavior; after adding proof, updating the PR body should trigger a fresh review, or a maintainer can comment @clawsweeper re-review. 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.

Risk before merge

  • [P2] The PR intentionally changes omitted-account fallback behavior, so existing zero-enabled or multiple-enabled account setups may fail before dispatch until users pass an explicit account.
  • [P1] The current fork head is conflicting and maintainerCanModify is false, so maintainers need contributor action or a credited replacement branch before landing.
  • [P1] The PR body still provides local test/check narrative only, not redacted terminal output, logs, copied live output, screenshot, recording, or a linked artifact proving the changed real behavior.
  • [P1] CI reports prompt snapshot drift after the message-tool account-selection contract changed.

Maintainer options:

  1. Rebase, refresh snapshots, and prove the runtime path (recommended)
    Ask the contributor to rebase on current main, regenerate the prompt snapshots, and add redacted real output or logs from an omitted-account send before merge.
  2. Preserve legacy fallback unless strict behavior is sponsored
    If maintainers do not want a breaking fail-closed policy for ambiguous omitted accounts, revise the resolver so existing fallback remains default and stricter selection is explicit or separately approved.
  3. Open a credited replacement branch
    If the fork cannot be refreshed with maintainer edits enabled, replace it with a narrow maintainer-editable branch that preserves the useful resolver work and credits the contributor.

Next step before merge

  • [P1] The remaining action is maintainer judgment plus contributor rebase/proof on an uneditable conflicting fork, not a narrow automated repair of this branch.

Security
Cleared: The diff touches outbound TypeScript logic, tests, and docs only; no dependency, workflow, lockfile, secret, permission, or package execution surface is changed.

Review findings

  • [P2] Refresh message prompt snapshots — src/infra/outbound/message-action-runner.ts:1294-1300
Review details

Best possible solution:

Land or replace a narrow shared outbound resolver only after the branch is rebased, prompt snapshots are refreshed, real behavior proof is supplied, and maintainers accept the fail-closed policy for ambiguous account selection.

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

Yes at source level: current main leaves accountId unset unless it is explicit/default/bound, and WhatsApp omitted-account sends then ask the default helper. I did not run a live WhatsApp or CLI send in this read-only review.

Is this the best way to solve the issue?

Yes for the owner boundary, but not yet merge-ready: a shared resolver after channel selection uses the existing plugin config adapter seam and is better than a WhatsApp-only fallback. The PR still needs conflict resolution, snapshot refresh, real proof, and maintainer acceptance of the compatibility policy.

Full review comments:

  • [P2] Refresh message prompt snapshots — src/infra/outbound/message-action-runner.ts:1294-1300
    This PR changes the model-facing omitted-account message-tool contract, and CI reports prompt:snapshots:check drift in the Discord group message-tool fixtures. Regenerate and review the prompt snapshots so the fixtures match the new runtime behavior.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR targets a bounded outbound message-delivery problem with limited blast radius, but it affects real multi-account sends.
  • merge-risk: 🚨 compatibility: Changing omitted-account fallback can require explicit account selection in existing multi-account setups that previously reached plugin fallback behavior.
  • merge-risk: 🚨 message-delivery: The resolver can change whether outbound messages dispatch, auto-select an account, or fail before delivery.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 PR body lists local tests and narrative observed results, but it does not include redacted terminal output, logs, copied live output, screenshot, recording, or a linked artifact showing the after-fix omitted-account behavior; after adding proof, updating the PR body should trigger a fresh review, or a maintainer can comment @clawsweeper re-review. 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

PR surface:

Source +142, Tests +260, Docs +7. Total +409 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 151 9 +142
Tests 2 262 2 +260
Docs 2 8 1 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 421 12 +409

What I checked:

  • Root and scoped policy read: Root AGENTS.md and the scoped outbound/docs guides were read fully; their compatibility, message-delivery, proof, and docs guidance applies to this fallback change. (AGENTS.md:1, f59310a555d7)
  • Current main lacks account inference: Current main derives accountId only from explicit params, input.defaultAccountId, or target-bound agent binding, then writes params.accountId only when one of those sources exists. (src/infra/outbound/message-action-runner.ts:1487, f59310a555d7)
  • Current WhatsApp omitted-account fallback: WhatsApp send still returns the explicit account if present and otherwise falls back to resolveDefaultWhatsAppAccountId, matching the disabled-default failure path from the linked issue. (extensions/whatsapp/src/send.ts:80, f59310a555d7)
  • Generic plugin account seam exists: ChannelConfigAdapter already exposes listAccountIds, resolveAccount, optional defaultAccountId, isEnabled, and isConfigured hooks, so the shared resolver is in the right owner boundary. (src/channels/plugins/types.adapters.ts:121, f59310a555d7)
  • PR diff implements the shared resolver: The PR adds resolveMessageAccountSelection, uses plugin account hooks, preserves accountless plugins, and calls the resolver from runMessageAction when no explicit/default/bound account is present. (src/infra/outbound/channel-selection.ts:347, 90a5c78a3bcf)
  • CI prompt snapshot drift: The failing check-additional-boundaries-a lane reports prompt:snapshots:check drift for discord-group-codex-message-tool.md and codex-dynamic-tools.discord-group.json. (90a5c78a3bcf)

Likely related people:

  • vincentkoc: Recent commits touched the message action runner, channel selection, account enabled predicate, and shared outbound/account helper surfaces implicated by this resolver. (role: recent outbound/channel contributor; confidence: high; commits: a22a1edc8faa, 5df513c8956e, 0ea08076c3b5; files: src/infra/outbound/message-action-runner.ts, src/infra/outbound/channel-selection.ts, src/channels/plugins/account-helpers.ts)
  • steipete: Prior issue comments give the shared resolver direction, and recent history touches channel-selection docs and account helper behavior near the requested policy. (role: prior reviewer and recent account-helper/docs contributor; confidence: high; commits: fc1848a28b6b, 7d3f1963d30c, 16ef041b5d86; files: src/infra/outbound/channel-selection.ts, src/channels/plugins/account-helpers.ts, docs/channels/channel-routing.md)
  • mcaxtr: Recent WhatsApp outbound delivery work is adjacent to the active-listener and omitted-account send behavior affected by this PR. (role: adjacent WhatsApp outbound contributor; confidence: medium; commits: 5040eb5d8424, 94ed68bc7688; files: extensions/whatsapp/src/send.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-03T23:20:06.326Z sha 90a5c78 :: needs real behavior proof before merge. :: [P2] Refresh message prompt snapshots

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.

Pull request overview

This PR fixes outbound message account inference when accountId/--account is omitted by introducing a shared resolver that prefers an enabled default account and otherwise auto-selects the only enabled+configured account (or fails clearly when the choice is ambiguous or impossible). This aligns the message tool behavior with the principle of least surprise and addresses the reported failure mode where an omitted account would fall through to a disabled default account.

Changes:

  • Add resolveMessageAccountSelection() to centralize account inference logic after channel selection.
  • Update runMessageAction() to apply the inferred accountId into normalized params before dispatch.
  • Add regression/behavior tests and document the omitted-account selection rules in CLI + routing docs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/infra/outbound/message-action-runner.ts Calls the new resolver when accountId is omitted, and writes the inferred account back into params before dispatch.
src/infra/outbound/channel-selection.ts Adds shared account selection resolver (prefer enabled default; else select single enabled+configured; else error).
src/infra/outbound/message-action-runner.plugin-dispatch.test.ts Adds plugin-dispatch coverage for auto-selecting the single enabled configured account and rejecting ambiguous configs.
src/infra/outbound/channel-selection.test.ts Adds unit tests for account selection sources and error cases.
docs/cli/message.md Documents --account omitted behavior and when an explicit account is required.
docs/channels/channel-routing.md Documents outbound account fallback behavior when no enabled default exists.

@clawsweeper clawsweeper Bot added 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 May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 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.

@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 23, 2026
@BingqingLyu

This comment was marked as spam.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@HemantSudarshan 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.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(outbound): auto-select single enabled message account This is item 1/1 in the current shard. Shard 8/22.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

message tool should auto-select the only enabled account

3 participants