Skip to content

fix(gateway): reject delivery to unconfigured plugin channels in agent handler#2718

Merged
alexey-pelykh merged 1 commit into
mainfrom
fix/reject-unconfigured-plugin-channel-delivery
Jun 15, 2026
Merged

fix(gateway): reject delivery to unconfigured plugin channels in agent handler#2718
alexey-pelykh merged 1 commit into
mainfrom
fix/reject-unconfigured-plugin-channel-delivery

Conversation

@alexey-pelykh

Copy link
Copy Markdown

Problem

When an agent run requests delivery (deliver: true) and the resolved channel is a plugin channel with no configured accounts (e.g. msteams registered but no accounts set up), the agent handler silently accepted the delivery request. isDeliverableMessageChannel() only checks plugin-registry presence, not whether the plugin has configured accounts, and the configured-accounts check (listConfiguredMessageChannels()) was consulted only on the INTERNAL_MESSAGE_CHANNEL fallback path — never for an explicitly-resolved plugin channel. The run was then dispatched to an unusable channel instead of surfacing a proper error.

Fix

src/gateway/server-methods/agent.ts: before internal-channel resolution, if delivery is wanted and the resolved channel is a registered plugin channel (not a built-in CHANNEL_IDS channel, not internal) that has no configured accounts, fall back to INTERNAL_MESSAGE_CHANNEL. The existing channel-selection logic then surfaces the proper "Channel is required" error instead of dispatching to an unusable channel. Built-in channels skip the check (always considered available).

Tests

src/gateway/server.agent.gateway-server-agent-b.test.ts:

  • New"agent falls back to internal delivery when the last channel is an unconfigured plugin channel": asserts res.ok === false, INVALID_REQUEST, and that no agent dispatch occurs.
  • Updated"agent reuses the last plugin delivery route when channel=last" now registers a configured msteams plugin (accountIds: ["default"]). It previously registered an unconfigured plugin yet asserted delivery succeeded — i.e. it encoded the bug.
  • createMSTeamsPlugin gains an optional accountIds parameter to express configured vs. unconfigured.

pnpm check (format + tsgo typecheck + lint + fork guards) passes.

Note: the full gateway suite (including this file) is gated out of the test CI job behind REMOTECLAW_TEST_INCLUDE_GATEWAY=1 due to orthogonal pre-existing failures (see .github/workflows/ci.yml test-gateway-preauth comment), so these assertions run in the gateway lane / locally rather than the default test job. Verified locally: the two new/updated assertions pass; the 2 pre-existing best-effort-downgrade failures are unrelated and present on main.

🤖 Generated with Claude Code

…t handler

When a session's lastChannel points to a plugin channel (e.g. msteams) with no configured accounts, the agent handler silently accepted the delivery request. isDeliverableMessageChannel() only checks plugin-registry presence, not configured accounts, and listConfiguredMessageChannels() was consulted only on the INTERNAL_MESSAGE_CHANNEL fallback path — never for an explicitly-resolved plugin channel.

Now, before internal-channel resolution, a wanted delivery to a registered plugin channel (not a built-in CHANNEL_IDS channel, not internal) with no configured accounts falls back to INTERNAL_MESSAGE_CHANNEL so channel-selection surfaces a proper "Channel is required" error. Built-in channels skip the check.

Adds a gateway test for the unconfigured-plugin fallback and updates the existing "reuses last plugin route" test to register a configured plugin (it previously asserted delivery succeeded with an unconfigured plugin — encoding the bug). createMSTeamsPlugin gains an optional accountIds param.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-pelykh
alexey-pelykh enabled auto-merge (squash) June 15, 2026 14:06
@alexey-pelykh
alexey-pelykh merged commit 113742b into main Jun 15, 2026
17 checks passed
@alexey-pelykh
alexey-pelykh deleted the fix/reject-unconfigured-plugin-channel-delivery branch June 15, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant