Skip to content

fix(matrix): preserve controls during command batching - #58591

Open
bbopen wants to merge 2 commits into
NousResearch:mainfrom
bbopen:codex/matrix-command-active-skill
Open

fix(matrix): preserve controls during command batching#58591
bbopen wants to merge 2 commits into
NousResearch:mainfrom
bbopen:codex/matrix-command-active-skill

Conversation

@bbopen

@bbopen bbopen commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Matrix long-command batching without allowing a following recognized command to be swallowed into the pending batch.

This draft:

  • batches a long Matrix command with its client-split continuation chunks;
  • dispatches recognized built-in, plugin, and skill commands immediately while a long command is pending;
  • keeps unknown command-like continuation text in the pending command batch;
  • preserves command semantics when a long command arrives behind an existing text batch;
  • recognizes routed-profile skills in both active-session guards; and
  • keeps synthetic auto-thread continuation chunks on the same Matrix batch key.

The first commit preserves the original authorship and patch from @liuhao1024's #58565. The second commit contains the additional runner, continuation-ordering, profile-safety, and auto-thread corrections required by the end-to-end regressions and review.

Fixes #58559.

Why?

Matrix clients can split long !command messages near their message-size limit. The initial command must wait briefly for continuation text, but real control/plugin/skill commands arriving during that window must retain their normal immediate routing. Recognition also has to use the routed profile and the same thread identity that the adapter assigns to the synthetic continuation.

Validation

  • scripts/run_tests.sh focused and sibling suites: 407 passed
  • relevant Ruff checks: passed
  • python3 scripts/check-windows-footguns.py ...: passed
  • git diff --check: passed
  • two fresh GPT-5.6 Sol xhigh pre-draft reviews at f3babd2f6735e5e6d5eebe79f2b78573cd7b4ed6: PASS

The required full-suite wrapper was attempted once on an earlier candidate and reached about 640 passing tests with no observed failure before its detached process tree was stopped. That incomplete run is not claimed as a full-suite pass. The final simplified tree was validated with the focused and sibling suites above and will be validated by live CI.

Scope and compatibility

No new public API, dependency, configuration, or general command framework is introduced. The change preserves both gateway active-message guards, Matrix mention/auto-thread behavior, profile boundaries, and cross-platform Python behavior.

This PR remains a draft pending live CI and post-draft review.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery platform/matrix Matrix adapter (E2EE) labels Jul 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Competing with #58565 for the same fix (#58559). #58565 is the narrower/earlier PR (touches plugins/platforms/matrix/adapter.py + hermes_cli/commands.py); this PR is a superset that also adds runner-level active-session handling in gateway/run.py plus underscore/hyphen skill-command normalization. Related, not a duplicate — maintainer should pick which scope to merge.

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

Thanks for extending the Matrix fix through the runner-level active-session path. The underlying gaps are present on current main: Matrix batches only MessageType.TEXT at plugins/platforms/matrix/adapter.py:2785, and dynamic commands are absent from the running-agent resolve_command() path at gateway/run.py:9350 and :9598.

Problems

  • plugins/platforms/matrix/adapter.py:2793 makes any short command received after a buffered long command into a continuation. Since _enqueue_text_event() appends incoming text to the pending event (plugins/platforms/matrix/adapter.py:3469-3473), a genuine /stop or /new during that debounce window is swallowed into the long command rather than dispatched.

Suggested changes

  • Preserve immediate handling for recognized built-in, plugin, and skill commands while retaining batching for unknown command-like continuation text. Add a regression case for a long buffered command followed by /stop or /new.

Automated hermes-sweeper review.

Comment thread plugins/platforms/matrix/adapter.py Outdated
@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 15, 2026
liuhao1024 and others added 2 commits July 18, 2026 20:09
…commands

Matrix bang commands that normalize to /command are MessageType.COMMAND,
which skipped the text-batching buffer. Long commands near _SPLIT_THRESHOLD
now go through batching so continuation chunks are aggregated.

Skill commands (e.g. /arxiv) are resolved through a separate registry and
were not recognized by should_bypass_active_session(), causing them to be
queued as user text instead of dispatched directly.

Fixes NousResearch#58559
@bbopen
bbopen force-pushed the codex/matrix-command-active-skill branch from 16e33c0 to f3babd2 Compare July 19, 2026 03:30
@bbopen bbopen changed the title fix(matrix): complete command batching and active skill bypass fix(matrix): preserve controls during command batching Jul 19, 2026
@bbopen
bbopen marked this pull request as ready for review July 19, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have platform/matrix Matrix adapter (E2EE) sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Matrix bang commands bypass split batching and skill-command active-session dispatch

4 participants