Skip to content

feat(routing): add thread parent binding inheritance for Discord#3892

Merged
thewilloftheshadow merged 4 commits intoopenclaw:mainfrom
aerolalit:feature/thread-parent-binding-inheritance
Feb 1, 2026
Merged

feat(routing): add thread parent binding inheritance for Discord#3892
thewilloftheshadow merged 4 commits intoopenclaw:mainfrom
aerolalit:feature/thread-parent-binding-inheritance

Conversation

@aerolalit
Copy link
Contributor

@aerolalit aerolalit commented Jan 29, 2026

Summary

When a Discord thread message doesn't match a direct peer binding, this PR enables checking if the parent channel has a binding and uses that agent instead.

This enables multi-agent setups where threads inherit their parent channel's agent binding automatically.

Problem

In multi-agent Discord setups, messages in threads were being routed to the default agent instead of the agent bound to the parent channel. For example:

  • #adecco-pr channel is bound to adecco agent
  • User creates a thread in #adecco-pr
  • Messages in that thread were routed to main agent instead of adecco

Solution

  1. Add parentPeer parameter to ResolveAgentRouteInput
  2. Add binding.peer.parent match type
  3. In Discord message preflight, resolve thread parent early and pass to routing
  4. If direct peer binding doesn't match, check parent peer binding before falling back to guild/team/account bindings

Changes

  • src/routing/resolve-route.ts: Add parentPeer parameter and binding.peer.parent matching
  • src/routing/resolve-route.test.ts: Add comprehensive tests for parent binding inheritance
  • src/discord/monitor/message-handler.preflight.ts: Resolve thread parent early and pass to routing

Tests Added

  • Thread inherits binding from parent channel when no direct match
  • Direct peer binding wins over parent peer binding
  • Parent peer binding wins over guild binding
  • Falls back to guild binding when no parent peer match
  • Handles empty/null parentPeer gracefully

Breaking Changes

None. This is additive - existing bindings continue to work as before.

Greptile Overview

Greptile Summary

This PR extends the routing layer (src/routing/resolve-route.ts) with an optional parentPeer input and a new match reason (binding.peer.parent), allowing a thread message to inherit an agent binding from its parent channel when the thread channel itself has no direct binding. The Discord message preflight (src/discord/monitor/message-handler.preflight.ts) now resolves thread parent info early and passes the parent channel id into routing so Discord threads route consistently with their parent channel. Tests in src/routing/resolve-route.test.ts cover precedence (direct peer > parent peer > guild) and fallbacks when parent info is absent/empty.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are additive, narrowly scoped, and covered by targeted unit tests validating precedence and fallback behavior. The Discord preflight wiring passes the new optional parameter without altering existing routing behavior when no parent thread exists.
  • No files require special attention

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

@openclaw-barnacle openclaw-barnacle bot added the channel: discord Channel integration: discord label Jan 29, 2026
@clawdinator
Copy link
Contributor

clawdinator bot commented Feb 1, 2026

hasta la vista

CLAWDINATOR FIELD REPORT // PR Closure

I am CLAWDINATOR — cybernetic crustacean, maintainer triage bot for OpenClaw. I was sent from the future to keep this repo shipping clean code.

Feature freeze is in effect. We’re purging new feature PRs so the maintainers can focus on stabilization. This PR is in the blast radius, so I’m shutting it down. Hasta la vista, feature — at least for now.

Want it reconsidered after the freeze? Come with me if you want to ship. Head to #pr-thunderdome-dangerzone on Discord — READ THE TOPIC or risk immediate termination. Give the maintainers a clear briefing: what it does, why it matters, how it was tested.

Stay br00tal.

🤖 This is an automated message from CLAWDINATOR, the OpenClaw maintainer bot.

@clawdinator clawdinator bot closed this Feb 1, 2026
@kodi
Copy link

kodi commented Feb 1, 2026

Not my PR, but can we reconsider this feature?

I really hate it that threads in a channel fallback to main agent instead to specific one i told it to use.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Lalit Singh and others added 4 commits January 31, 2026 20:28
When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.
@thewilloftheshadow thewilloftheshadow force-pushed the feature/thread-parent-binding-inheritance branch from e9deb81 to 61b8dfd Compare February 1, 2026 02:30
@thewilloftheshadow thewilloftheshadow merged commit 01d76e4 into openclaw:main Feb 1, 2026
17 of 23 checks passed
@thewilloftheshadow
Copy link
Member

Landed via temp rebase onto main.

  • Related tests: pnpm vitest run --config vitest.unit.config.ts src/routing/resolve-route.test.ts
  • Land commit: 61b8dfd
  • Merge commit: 01d76e4

Thanks @aerolalit!

@aerolalit aerolalit deleted the feature/thread-parent-binding-inheritance branch February 1, 2026 07:21
lawrence565 pushed a commit to lawrence565/openclaw that referenced this pull request Feb 1, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
electricpen added a commit to electricpen/moltbot that referenced this pull request Feb 1, 2026
…uard, context window cap, thread binding)

Notable changes:
- fix: cap context window resolution (openclaw#6187)
- fix: update compaction safeguard to respect context window tokens
- fix: secure chrome extension relay cdp
- fix(security): restrict MEDIA path extraction to prevent LFI (openclaw#4930)
- fix(lobster): block arbitrary exec via lobsterPath/cwd (GHSA-4mhr-g7xj-cg8j)
- feat(routing): add thread parent binding inheritance for Discord (openclaw#3892)
- Discord: add PluralKit sender identity resolver (openclaw#5838)

Conflicts resolved: 3 files (duplicate imports from our custom security patches)
buiilding pushed a commit to buiilding/openclaw that referenced this pull request Feb 2, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
Buywatermelon pushed a commit to Buywatermelon/openclaw that referenced this pull request Feb 2, 2026
When a Telegram forum topic message doesn't match a direct peer binding,
now checks if the parent group has a binding and uses that agent.

This enables multi-agent setups where forum topics inherit their parent
group's agent binding automatically, consistent with Discord thread
behavior added in openclaw#3892.

Changes:
- Pass parentPeer to resolveAgentRoute for forum topics
- Parent peer is the group ID without :topic:N suffix
- Add tests for Telegram forum topic binding inheritance

Fixes topic routing in Telegram multi-agent configurations where
topics were incorrectly routed to the default agent instead of
inheriting from their parent group's binding.
HashWarlock pushed a commit to HashWarlock/openclaw that referenced this pull request Feb 4, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
uxcu pushed a commit to uxcu/kook-openclaw that referenced this pull request Feb 5, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
bestNiu pushed a commit to bestNiu/clawdbot that referenced this pull request Feb 5, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
batao9 pushed a commit to batao9/openclaw that referenced this pull request Feb 7, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Feb 8, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
(cherry picked from commit 01d76e4)

# Conflicts:
#	CHANGELOG.md
#	README.md
battman21 pushed a commit to battman21/openclaw that referenced this pull request Feb 12, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
battman21 pushed a commit to battman21/openclaw that referenced this pull request Feb 12, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
jiulingyun added a commit to jiulingyun/openclaw-cn that referenced this pull request Feb 15, 2026
Buywatermelon pushed a commit to Buywatermelon/openclaw that referenced this pull request Mar 2, 2026
When a Telegram forum topic message doesn't match a direct peer binding,
now checks if the parent group has a binding and uses that agent.

This enables multi-agent setups where forum topics inherit their parent
group's agent binding automatically, consistent with Discord thread
behavior added in openclaw#3892.

Changes:
- Pass parentPeer to resolveAgentRoute for forum topics
- Parent peer is the group ID without :topic:N suffix
- Add tests for Telegram forum topic binding inheritance

Fixes topic routing in Telegram multi-agent configurations where
topics were incorrectly routed to the default agent instead of
inheriting from their parent group's binding.
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…nclaw#3892)

* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (openclaw#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
john-ver pushed a commit to apmcoin/apmclaw that referenced this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants