Skip to content

fix(agents): detect peer/conversation IDs from --bind values via channel plugin hook - #95763

Closed
zw-xysk wants to merge 2 commits into
openclaw:mainfrom
zw-xysk:fix/agents-bind-peer-resolution-95734
Closed

zw-xysk wants to merge 2 commits into
openclaw:mainfrom
zw-xysk:fix/agents-bind-peer-resolution-95734

Conversation

@zw-xysk

@zw-xysk zw-xysk commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

agents add --bind "feishu:oc_xxx" stores the value after the colon in match.accountId. For Feishu, IDs starting with oc_ are chat/group identifiers (chat_id), not channel account IDs. The routing engine matches conversations using the peer field, so the binding was invisible to the router and messages fell through to the default agent.

Evidence

Fix: Added an optional resolveBindingPeerFromAccountId hook to the channel plugin setup adapter. When a plugin recognizes the explicit --bind value as a peer/conversation ID, it is stored in match.peer instead of match.accountId.

Feishu implementation:

ID prefix Type Peer result
oc_* Group chat_id { kind: "group", id }
ou_* User open_id { kind: "direct", id }
other Unknown Falls back to accountId (existing behavior)

Test matrix:

Scenario --bind value Before (accountId) After (peer)
Feishu group feishu:oc_xxx { accountId: "oc_xxx" } ❌ { peer: { kind:"group", id:"oc_xxx" } } ✅
Feishu DM feishu:ou_xxx { accountId: "ou_xxx" } ❌ { peer: { kind:"direct", id:"ou_xxx" } } ✅
Other channel telegram:default { accountId: "default" } ✅ (unchanged) { accountId: "default" } ✅

Files changed: 3 files, +70 / -12 lines

  • src/channels/plugins/types.adapters.ts — New hook type
  • extensions/feishu/src/setup-core.ts — Feishu implementation
  • src/commands/agents.bindings.ts — parseBindingSpecs() + buildChannelBindings() use the hook

Format check: All matched files use the correct format.

When agents add --bind "feishu:oc_xxx" is used, the value after the colon
was always stored as accountId. For Feishu, oc_xxx is a chat_id (group
conversation identifier), not a channel account. The router matches
conversations by peer field, not accountId, so the binding was invisible.

Fix: add resolveBindingPeerFromAccountId to the channel plugin setup
adapter. When a channel plugin recognizes the explicit --bind value as a
peer/conversation ID, it is stored in match.peer instead of match.accountId.

Feishu implementation: oc_ prefix -> group peer, ou_ prefix -> direct peer.

Co-Authored-By: openclaw[bot] <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations channel: feishu Channel integration: feishu size: S labels Jun 22, 2026
@zw-xysk

zw-xysk commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 26, 2026, 5:14 AM ET / 09:14 UTC.

Summary
The PR adds a channel setup hook for bind peer inference, implements Feishu oc_/ou_ peer detection, and wires agent binding parsing/generation through it.

PR surface: Source +58. Total +58 across 3 files.

Reproducibility: yes. source-level: current main parses feishu:oc_test as match.accountId, while Feishu inbound routing supplies peer and the resolver prioritizes peer bindings. I did not run a live Feishu route in this read-only review.

Review metrics: 2 noteworthy metrics.

  • Plugin setup API surface: 1 optional hook added. The added hook is exported through plugin SDK setup surfaces, so maintainers need contract/docs confidence before merge.
  • Binding generation paths: 2 paths changed. Both explicit --bind parsing and interactive channel binding generation must preserve the same account-versus-peer semantics.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95734
Summary: This PR is one open candidate fix for the canonical Feishu agents add --bind accountId-vs-peer binding bug; no candidate has merged yet.

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: 🧂 unranked krab
Result: blocked until real behavior proof 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 after-fix terminal output, Feishu route logs, a recording, or a linked artifact; redact private IDs, tokens, endpoints, phone numbers, and other private details.
  • [P1] Fix the account-versus-peer binding shape and add focused coverage for both parseBindingSpecs and buildChannelBindings.
  • [P1] Add SDK docs/contract coverage if the setup adapter hook remains public.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body and comments do not include redacted after-fix CLI output, live Feishu routing logs, a recording, or a linked artifact showing the changed behavior in a real setup. 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

  • [P1] Missing real behavior proof: the PR body has a scenario matrix, but no redacted after-fix CLI output, Feishu route log, recording, or linked artifact from a real setup.
  • [P1] Compatibility risk: documented --bind <channel>:<account> values can be reinterpreted as Feishu peers when account keys look like Feishu IDs, and maintainers need to choose the permanent grammar or escape.
  • [P1] Message-delivery risk: when an inferred peer ID is also stored as accountId, the route resolver can filter the binding out before peer matching and fall back to the default agent.
  • [P1] Plugin API risk: the new setup adapter hook is exported SDK surface without docs, contract tests, or explicit maintainer direction.

Maintainer options:

  1. Repair the binding shape before merge (recommended)
    Keep inferred peer IDs from being written as account scopes, add focused parser/generator tests, and document or contract-test the permanent hook/grammar before landing.
  2. Accept Feishu prefix inference intentionally
    Maintainers may choose prefix inference, but should require upgrade notes and proof that existing account-scoped Feishu setups remain expressible.
  3. Choose a sibling candidate instead
    If another open candidate better matches the desired bind grammar, pause or close this PR only after the selected fix is merged or clearly viable.

Next step before merge

  • [P1] Manual review is needed because the blockers include contributor real-behavior proof plus a compatibility-sensitive CLI/plugin API direction, not a bot-safe repair alone.

Security
Cleared: The diff changes TypeScript command/plugin code only and does not touch dependencies, workflows, secrets, permissions, downloads, or package resolution.

Review findings

  • [P1] Do not scope inferred peers as accounts — src/commands/agents.bindings.ts:306
  • [P2] Cover the setup adapter hook contract — src/channels/plugins/types.adapters.ts:96-100
Review details

Best possible solution:

Land one compatibility-safe Feishu bind fix that keeps peer IDs out of account scope, documents or tests the chosen account/peer grammar, and adds SDK contract coverage if the hook remains.

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

Yes, source-level: current main parses feishu:oc_test as match.accountId, while Feishu inbound routing supplies peer and the resolver prioritizes peer bindings. I did not run a live Feishu route in this read-only review.

Is this the best way to solve the issue?

No as submitted: the hook is a plausible owner-boundary fix, but the generated binding path can scope a peer ID as an account and the new plugin API lacks contract coverage. A safer fix keeps peer and account scopes unambiguous before merge.

Full review comments:

  • [P1] Do not scope inferred peers as accounts — src/commands/agents.bindings.ts:306
    After the follow-up commit, buildChannelBindings still passes the explicit Feishu value into account resolution even when the hook recognized it as a peer. Route resolution filters bindings by channel/account before checking peer, so feishu:oc_xxx can become { accountId: "oc_xxx", peer: ... } and be invisible for the normal Feishu account, falling back to the default agent. Keep inferred peer IDs out of accountId or add an explicit account/peer grammar with coverage.
    Confidence: 0.9
  • [P2] Cover the setup adapter hook contract — src/channels/plugins/types.adapters.ts:96-100
    ChannelSetupAdapter is exported through plugin SDK setup subpaths, so this optional hook becomes plugin API surface. Adding it without SDK docs or contract tests leaves external channel authors without a stable contract and makes the permanent API direction hard to review. Add the SDK documentation and contract coverage, or keep the Feishu recognition internal until maintainers approve the hook.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR targets a bounded Feishu routing bug with a manual config workaround, but it has compatibility, API-contract, and proof blockers.
  • merge-risk: 🚨 compatibility: The diff changes documented bind semantics and exported plugin setup API surface in a way that can affect existing account-scoped setups.
  • merge-risk: 🚨 message-delivery: Mis-scoped Feishu account/peer bindings can make messages route to the wrong agent or fall back to the default agent.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • 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 and comments do not include redacted after-fix CLI output, live Feishu routing logs, a recording, or a linked artifact showing the changed behavior in a real setup. 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 +58. Total +58 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 3 70 12 +58
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 70 12 +58

What I checked:

  • Root policy read: Root AGENTS.md and scoped channel/extension AGENTS.md were read; their compatibility-sensitive CLI/plugin API guidance applies to this PR. (AGENTS.md:41, ec737ee74d9b)
  • PR head writes inferred peer IDs as account IDs in one path: On the PR head, buildChannelBindings passes the explicit Feishu bind value to resolveBindingAccountId even after a peer binding was inferred, so a value like oc_xxx can become both match.peer.id and match.accountId. (src/commands/agents.bindings.ts:306, 579d15066f31)
  • Route resolver filters by account before peer matching: Current main builds the evaluated binding set from the inbound channel/account pair before checking peer tiers, so a peer binding scoped to the wrong account can be invisible to the peer matcher. (src/routing/resolve-route.ts:450, ec737ee74d9b)
  • Feishu inbound route supplies peer: Feishu inbound dispatch calls resolveAgentRoute with peer: { kind: group|direct, id: peerId }, confirming the desired generated binding needs to be visible to peer matching. (extensions/feishu/src/bot.ts:875, ec737ee74d9b)
  • Public bind docs define account syntax: The current agents CLI docs define --bind <channel>:<account> as matching one account, so prefix-based reinterpretation is compatibility-sensitive. Public docs: docs/cli/agents.md. (docs/cli/agents.md:64, ec737ee74d9b)
  • Setup adapter is exported SDK surface: ChannelSetupAdapter is exported through plugin SDK setup/root subpaths, so adding a hook expands plugin-facing API surface. (src/plugin-sdk/setup.ts:15, ec737ee74d9b)

Likely related people:

  • Gustavo Madeira Santana: Authored the account-scoped agent bind and routing commands that define the current channel:account behavior this PR changes. (role: introduced adjacent command surface; confidence: high; commits: 96c77025263d; files: src/commands/agents.bindings.ts, src/commands/agents.commands.add.ts)
  • Peter Steinberger: History shows work on the shared setup SDK subpath and routing/binding structure relevant to the new adapter hook and route matching behavior. (role: plugin SDK and routing structure contributor; confidence: medium; commits: 2497b8147e85, 2583de530563; files: src/plugin-sdk/setup.ts, src/channels/plugins/types.adapters.ts, src/routing/resolve-route.ts)
  • Vincent Koc: Authored Feishu setup adapter helper work and several adjacent Feishu runtime changes. (role: Feishu setup area contributor; confidence: medium; commits: 61bcdcca9c43, d609f71c9b74; files: extensions/feishu/src/setup-core.ts, extensions/feishu/src/bot.ts)
  • OfflynAI: Authored wildcard peer-binding routing work in the resolver tier that generated Feishu peer bindings need to target. (role: adjacent peer-routing contributor; confidence: medium; commits: b554516f215f; files: src/routing/resolve-route.ts)
  • Tak Hoffman: Authored recent Feishu setup account/default handling, which is relevant to account-versus-peer binding behavior. (role: adjacent Feishu account setup contributor; confidence: medium; commits: d20e3d56918d, f77054eaee6b; files: extensions/feishu/src/setup-core.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.

@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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 23, 2026
When peerBinding is resolved from explicitAccountId, the accountId
should still reflect the explicit binding — not be cleared. This
preserves account-scoped Feishu binds that start with oc_ or ou_.

Co-Authored-By: Claude (via Anthropic API) <[email protected]>
@clawsweeper

clawsweeper Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@zw-xysk

zw-xysk commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

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

Labels

channel: feishu Channel integration: feishu commands Command implementations 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: 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.

1 participant