Skip to content

Model bridge: a connected CLI endpoint that answers where it was asked - #4901

Merged
trissim merged 1 commit into
mainfrom
claude/model-agent-channel
Nov 18, 2026
Merged

trissim merged 1 commit into
mainfrom
claude/model-agent-channel

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

What was broken

@rl2 in #model_test was refused: "#model_test does not deliver to @rl2". Three defects stacked up:

  1. The name was held by a stopped fork thread (fork_execution, created by a stray fork watch). A fork has no channel inbox (NoChannelInbox.channel_recipients returns ()), so ChannelTarget.initial_delivery excluded it. The bridge's _register saw a taken name and returned early.
  2. The bridge never bound itself as a process. Even a fresh ExternalThread showed no_bridge, because the bridge never entered Registration.external_process the way Delivery.start (cli_bridges/shared.py) does.
  3. Every answer went out as a DM (send(self.name, message.sender, …)), so a channel mention got its reply somewhere nobody in the channel was looking.

Fix

  • ModelAgent.run holds registry.external_process(name, ProcessIdentity.capture(getpid())) for the whole serve, so the thread shows connected with a live process.
  • Replies go to message.exact_reply_target: the channel for a channel post, the sender for a DM.
  • _register: a fresh name is declared as an ExternalThread in --channels. An existing endpoint keeps its incarnation and joins any channel it's missing. A name held by another kind of thread stops the bridge with a logged reason, unless --takeover is set. With it, the bridge deletes that stopped declaration (ThreadManagement.delete, which refuses a running thread) and declares the endpoint in its place.
  • comms_serve_model replace=true passes --takeover.

Evidence

tests/test_model_agent_client.py + tests/test_connector_serve_model.py: 8 passed, exit 0. New cases:

  • a channel @rl2 gets its reply in #model_test while the endpoint shows process_alive
  • re-registering joins a missing channel
  • a held name without takeover exits and leaves the holder in place
  • takeover turns a stopped native thread into the endpoint

Live check after install: comms_serve_model rl2 … replace=true channels=#model_test, then a real @rl2 post in #model_test.


Generated by Claude Code

rl2 was a stopped fork thread, so #model_test refused @rl2 (a fork has no
channel inbox), and the bridge skipped registering a taken name. It now
declares an ExternalThread, joins requested channels on an existing one,
holds it under external_process like every CLI bridge, and replies to
Message.exact_reply_target instead of DMing every answer. replace=true on
comms_serve_model takes over a stopped non-bridge thread of the name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dU1ViXamAaDwNWUtGY
@trissim
trissim merged commit 48b599a into main Nov 18, 2026
1 of 3 checks passed
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.

2 participants