Skip to content

fix(matrix): preserve ACP thread binding targets#64343

Merged
gumadeiras merged 5 commits into
mainfrom
codex/fix-matrix-acp-thread-bindings
Apr 10, 2026
Merged

fix(matrix): preserve ACP thread binding targets#64343
gumadeiras merged 5 commits into
mainfrom
codex/fix-matrix-acp-thread-bindings

Conversation

@gumadeiras

Copy link
Copy Markdown
Member

Summary

  • Problem: ACP thread-bound session spawn reused a lossy groupId as the transport target, which lowercased mixed-case Matrix room ids and dropped parent conversation context for thread binds.
  • Why it matters: Matrix ACP binds could fail from top-level rooms or existing threads, while other channels rely on the same core seam.
  • What changed: src/agents/acp-spawn.ts now resolves full conversation refs through the plugin seam, keeps canonical to authoritative, preserves parentConversationId for thread binds, and keeps channel-specific fallback behavior intact.
  • What did NOT change (scope boundary): session/group metadata normalization and broader groupId semantics across policy/config code were not redesigned here.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: ACP thread spawn collapsed canonical to and fallback groupId into the same value before calling resolveInboundConversation(), so case-sensitive Matrix room ids were lowercased and parent conversation refs for thread binds were lost.
  • Missing detection / guardrail: ACP spawn lacked a seam test that exercised mixed-case Matrix room ids and existing-thread binds through the generic plugin contract.
  • Contributing context (if known): groupId is still overloaded in core for policy/session metadata, so the ACP seam needed to prefer canonical routing data without changing broader groupId behavior for other channels.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/acp-spawn.test.ts
  • Scenario the test should lock in: ACP thread=true preserves canonical Matrix room casing from both top-level rooms and existing Matrix threads while leaving LINE and Telegram behavior unchanged.
  • Why this is the smallest reliable guardrail: the regression lives at the generic ACP spawn-to-plugin seam, not inside Matrix-only binding code.
  • Existing test that already covers this (if any): existing Discord/Telegram ACP spawn tests cover neighboring thread-binding behavior.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Matrix ACP thread-bound session spawns now bind correctly when the room id casing differs from persisted groupId, including spawns launched from existing Matrix threads.

Diagram (if applicable)

Before:
[sessions_spawn thread=true] -> [ACP spawn uses lowercased groupId for to + conversationId]
-> [Matrix resolves wrong parent room] -> [bind/send can fail]

After:
[sessions_spawn thread=true] -> [ACP spawn passes canonical to + fallback conversationId]
-> [plugin resolves full conversation ref] -> [bind/send uses correct room + thread context]

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local repo dev environment
  • Model/provider: N/A
  • Integration/channel (if any): Matrix ACP thread bindings
  • Relevant config (redacted): channels.matrix.threadBindings.enabled=true

Steps

  1. Start from a Matrix room with a mixed-case room id and persisted lowercased groupId.
  2. Trigger sessions_spawn({ runtime: "acp", thread: true }) from the room or from an existing Matrix thread.
  3. Observe the created ACP binding target.

Expected

  • ACP spawn binds using the canonical Matrix room id, preserving parent conversation context for thread binds.

Actual

  • Before this fix, ACP spawn could bind/send using the lowercased room id or lose the parent room when launched from an existing thread.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • pnpm test src/agents/acp-spawn.test.ts
  • pnpm check

Copilot AI review requested due to automatic review settings April 10, 2026 14:11
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Apr 10, 2026
@greptile-apps

greptile-apps Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes Matrix ACP thread-bound session spawns incorrectly using a lowercased groupId as the transport target instead of the canonical to value. resolvePluginConversationRefForThreadBinding now passes to (the authoritative delivery target) as the primary resolver input and keeps groupId only as a fallback hint for conversationId, which lets the Matrix plugin (or the generic fallback via resolveConversationIdFromTargets) extract the room id with its original casing. parentConversationId is also propagated correctly for existing-thread spawns. Three new seam tests lock in the behavior for top-level rooms, mixed-case room ids, and thread-origin spawns.

Confidence Score: 5/5

Safe to merge — fix is correct, targeted, and covered by new seam tests; only finding is a P2 CHANGELOG placement style issue.

The implementation correctly prioritises the canonical to value over the lossy groupId in resolvePluginConversationRefForThreadBinding, and the generic fallback (resolveConversationIdFromTargets) already handles the "room:" prefix idiom to preserve case. Three new tests lock in the Matrix top-level-room, mixed-case-id, and existing-thread-spawn scenarios. No logic errors or data-integrity risks found.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: CHANGELOG.md
Line: 13

Comment:
**Changelog entry should be appended at the end of the section**

Per the repo's CLAUDE.md guideline ("append new entries to the end of the target section; do not insert new entries at the top of a section"), this entry should appear after the last existing `### Fixes` bullet rather than at the top of the block. Move the Matrix/ACP line to after the final existing fix entry (e.g. after the QQBot/streaming line).

**Context Used:** CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: preserve ACP thread binding targets" | Re-trigger Greptile

Comment thread CHANGELOG.md Outdated

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

Fixes ACP thread-bound session spawn routing for Matrix by preserving canonical delivery targets (including mixed-case room IDs) and retaining parent conversation context when binding threads, using the channel plugin seam instead of a lossy groupId fallback.

Changes:

  • Resolve thread-binding conversation refs via messaging.resolveInboundConversation() while keeping to authoritative and capturing parentConversationId when available.
  • Extend ACP thread-binding flow to persist/pass parentConversationId through bind + delivery-plan matching.
  • Add seam tests covering mixed-case Matrix room IDs (top-level + existing thread) and a regression guard for LINE precedence; refactor Telegram test setup helper.

Reviewed changes

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

File Description
src/agents/acp-spawn.ts Preserves canonical to in plugin conversation resolution and propagates parentConversationId for ACP thread bindings.
src/agents/acp-spawn.test.ts Adds regression tests for Matrix casing/thread parent preservation; keeps LINE/Telegram behavior covered and reduces setup duplication.
CHANGELOG.md Documents the Matrix/ACP thread-binding spawn fix in Unreleased fixes.

@gumadeiras gumadeiras self-assigned this Apr 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c85e46838

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/acp-spawn.ts
@gumadeiras gumadeiras force-pushed the codex/fix-matrix-acp-thread-bindings branch from 5c85e46 to a37b470 Compare April 10, 2026 15:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e198c9263e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/outbound/session-binding-normalization.ts
@gumadeiras gumadeiras force-pushed the codex/fix-matrix-acp-thread-bindings branch 3 times, most recently from 0eb980e to a7312ad Compare April 10, 2026 16:29
@gumadeiras gumadeiras force-pushed the codex/fix-matrix-acp-thread-bindings branch from a7312ad to def7dcd Compare April 10, 2026 16:29
@gumadeiras gumadeiras merged commit 5d22252 into main Apr 10, 2026
8 checks passed
@gumadeiras gumadeiras deleted the codex/fix-matrix-acp-thread-bindings branch April 10, 2026 16:30
@gumadeiras

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @gumadeiras!

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Merged via squash.

Prepared head SHA: def7dcd
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Merged via squash.

Prepared head SHA: def7dcd
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Merged via squash.

Prepared head SHA: def7dcd
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: def7dcd
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Merged via squash.

Prepared head SHA: def7dcd
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Matrix ACP thread-bound sessions fail because room IDs are lowercased during session/binding routing

2 participants